mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-25 18:00:37 -04:00
The commands and values were not very good names to what the byte sequences actually are: opcodes and their operands. In many other places, we were already calling the byte in the Command stream as Opcode, so a logical name for a sequence of these is Opcodes. Values is such a generic name that it's not immediately clear that this sequence is related to the opcodes. Operands is not perfect but clearly suggests that this sequence is related to the Opcodes.
42 lines
1.4 KiB
C
42 lines
1.4 KiB
C
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <sointu.h>
|
|
#include "test_render_samples.h"
|
|
|
|
void SU_CALLCONV su_render_song(float *buffer)
|
|
{
|
|
Synth *synth;
|
|
const unsigned char opcodes[] = {SU_ENVELOPE_ID, // MONO
|
|
SU_ENVELOPE_ID, // MONO
|
|
SU_OUT_ID + 1, // STEREO
|
|
SU_ADVANCE_ID}; // MONO
|
|
const unsigned char operands[] = {64, 64, 64, 80, 128, // envelope 1
|
|
95, 64, 64, 80, 128, // envelope 2
|
|
128};
|
|
int retval;
|
|
int samples;
|
|
int time;
|
|
// initialize Synth
|
|
synth = (Synth *)malloc(sizeof(Synth));
|
|
memset(synth, 0, sizeof(Synth));
|
|
memcpy(synth->Opcodes, opcodes, sizeof(opcodes));
|
|
memcpy(synth->Operands, operands, sizeof(operands));
|
|
synth->NumVoices = 1;
|
|
synth->Polyphony = 0;
|
|
synth->RandSeed = 1;
|
|
// triger first voice
|
|
synth->SynthWrk.Voices[0].Note = 64;
|
|
synth->SynthWrk.Voices[0].Sustain = 1;
|
|
samples = SU_LENGTH_IN_SAMPLES / 2;
|
|
time = INT32_MAX;
|
|
retval = su_render(synth, buffer, &samples, &time);
|
|
synth->SynthWrk.Voices[0].Sustain = 0;
|
|
buffer = buffer + SU_LENGTH_IN_SAMPLES;
|
|
samples = SU_LENGTH_IN_SAMPLES / 2;
|
|
time = INT32_MAX;
|
|
retval = su_render(synth, buffer, &samples, &time);
|
|
free(synth);
|
|
return;
|
|
}
|