Marc, That is interesting and you've given me something to consider and perhaps adjust. Thank you.
Also with regards to attack and release, I've opted to call it just attack. That is when the note is starting to play, or ending playing, I perform a short fade of the wave form on both ends using the same value. I also mix in a sustain which I am using to fade the note out over time after the initial attack. So the formula I am using is assuming a note is playing (StartTime >= CurrentTime): if StartTime - CurrentTime < Attack then Mix := StartTime - CurrentTime / Attack else Mix := 1; Then I used the Mix blend variable to adjust the wave amplitude (Volume) by multiplying it against the left and right channels. // Sample Left and Right are a 16 bit signed integers Sample.Left := Trunc(AudioWave(F) * Volume * Mix); Sample.Right := -Sample.Left; Where: F is the a value between 0.0..1.0 representing the current wave cycle AudioWave is the user defined function to convert F into a wave shape returning a value between -1.0..1.0 Volume is the peak we allow for the Left or Right on Sample (in my case the constant value 2048) Mix is between 0.0..1.0 and is used to fade in for attack, fade out for release, and fade out using sustain So I should fix this by adding a tiny bit of phase change to F based on which keyboard key is being processed.
-- _______________________________________________ lazarus mailing list lazarus@lists.lazarus-ide.org https://lists.lazarus-ide.org/listinfo/lazarus