Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playing a PCM patch changes oscillator's freq #207

Open
dpwe opened this issue Sep 8, 2024 · 1 comment
Open

Playing a PCM patch changes oscillator's freq #207

dpwe opened this issue Sep 8, 2024 · 1 comment

Comments

@dpwe
Copy link
Collaborator

dpwe commented Sep 8, 2024

Currently, pcm patch playback changes the frequency of the osc. It shouldn't do that.

Example:

amy.reset()
amy.send(osc=0, wave=amy.PCM, patch=2, vel=1)  # Plays 808 Snare as expected.
amy.reset()
amy.send(osc=0, wave=amy.PCM, patch=0, vel=1)  # Plays 808 Maracas as expected.
amy.send(osc=0, wave=amy.PCM, patch=2, vel=1)  # We expected the same snare as above, but it's massively slowed down

Somehow, after playing the Maracas, the log_freq_coef[COEF_CONST] becomes 3.98 (so 4 octaves above middle C), but the snare wants it to be 7.647, so the sound is pitched down by the difference (3.6 octaves).

@dpwe
Copy link
Collaborator Author

dpwe commented Sep 8, 2024

I have an idea for how to fix this, which I think also improves the rationality of the whole thing.

Right now, we squirm a little in the tutorial when we say you can set the frequency of an osc with freq= or with note= -- a new user asks, why have both?

I think a nice rationale is that note is purely associated with a given note, i.e. a single vel=1 to vel=0 timespan, after which it is invalid. Currently, midi_note is a property of the osc's synth structure. If you set it for one note, then later send another note-on to the same osc without specifying a note, it will re-use the midi_note from the last note-on.

This is what messes up the PCM voices, which default to different notes depending on the "natural" note of the PCM patch (at least, that's what I think is going on).

Instead, once midi_note has been set, then "consumed" by a note-on/note-off pair, it should be marked invalid. Then if it is explicitly set, it is marked as valid. Then, on a note-on, if the midi_note is not valid, it is cleared before the note is launched. That way, PCM oscs can avoid inheriting the irrelevant default midi_note of their predecessors when the patch in use is changed as in DrumSynth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant