mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-18 13:04:25 -04:00
Separate Synth and SynthState: SynthState is the part that Render changes.
This should make testing easier, as Synth can be assumed to stay the same during each call. Synth is also the part that we can parse from .asm/.json file and a Patch can be compiled into a synth. Synth can be eventually made quite opaque to the user. The user should not need to worry about opcodes etc.
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
const int su_max_samples = SAMPLES_PER_ROW * TOTAL_ROWS;
|
||||
|
||||
void CALLCONV su_render_song(float* buffer) {
|
||||
Synth* synth;
|
||||
SynthState* synthState;
|
||||
const unsigned char commands[] = { su_envelope_id, // MONO
|
||||
su_envelope_id, // MONO
|
||||
@ -29,17 +30,23 @@ void CALLCONV su_render_song(float* buffer) {
|
||||
95, 64, 64, 80, 128, // envelope 2
|
||||
128};
|
||||
int retval;
|
||||
synthState = malloc(sizeof(SynthState));
|
||||
// initialize Synth
|
||||
synth = (Synth*)malloc(sizeof(Synth));
|
||||
memcpy(synth->Commands, commands, sizeof(commands));
|
||||
memcpy(synth->Values, values, sizeof(values));
|
||||
synth->NumVoices = 1;
|
||||
synth->Polyphony = 0;
|
||||
// initialize SynthState
|
||||
synthState = (SynthState*)malloc(sizeof(SynthState));
|
||||
memset(synthState, 0, sizeof(SynthState));
|
||||
memcpy(synthState->Commands, commands, sizeof(commands));
|
||||
memcpy(synthState->Values, values, sizeof(values));
|
||||
synthState->RandSeed = 1;
|
||||
synthState->NumVoices = 1;
|
||||
synthState->Synth.Voices[0].Note = 64;
|
||||
retval = su_render(synthState, buffer, su_max_samples / 2);
|
||||
synthState->Synth.Voices[0].Release++;
|
||||
// triger first voice
|
||||
synthState->SynthWrk.Voices[0].Note = 64;
|
||||
retval = su_render(synth, synthState, buffer, su_max_samples / 2);
|
||||
synthState->SynthWrk.Voices[0].Release++;
|
||||
buffer = buffer + su_max_samples;
|
||||
retval = su_render(synthState, buffer, su_max_samples / 2);
|
||||
retval = su_render(synth, synthState, buffer, su_max_samples / 2);
|
||||
free(synth);
|
||||
free(synthState);
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user