Skip to content

Commit

Permalink
fix: pulse start phase calculation (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
kahojyun authored Apr 19, 2024
1 parent 8009939 commit a480852
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Bosing/WaveformUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public static PooledComplexArray<T> SampleWaveform<T>(PulseList pulseList, doubl
var tStart = time + delay;
var iFracStart = TimeAxisUtils.NextFracIndex(tStart, sampleRate, alignLevel);
var iStart = (int)Math.Ceiling(iFracStart);
var envelopeInfo = new EnvelopeInfo(iStart - iFracStart, sampleRate);
var indexOffset = iStart - iFracStart;
var envelopeInfo = new EnvelopeInfo(indexOffset, sampleRate);
var envelopeSample = WaveformSampler<T>.GetEnvelopeSample(envelopeInfo, binKey.Envelope);
if (envelopeSample is null)
{
Expand All @@ -35,7 +36,7 @@ public static PooledComplexArray<T> SampleWaveform<T>(PulseList pulseList, doubl
var localFrequency = binKey.LocalFrequency;
var totalFrequency = globalFrequency + localFrequency;
var dt = 1 / sampleRate;
var phaseShift = Math.Tau * globalFrequency * (iStart * dt - delay);
var phaseShift = Math.Tau * (globalFrequency * (iStart * dt - delay) + localFrequency * indexOffset * dt);
var amplitude = pulse.Amplitude * pulseList.AmplitudeMultiplier * Complex.FromPolarCoordinates(1, phaseShift);
var complexAmplitude = amplitude.Amplitude;
var dragAmplitude = amplitude.DragAmplitude * sampleRate;
Expand Down

0 comments on commit a480852

Please sign in to comment.