separate audio stream per midi channel
Hi,
i use your formidable tsf.h without tml.h.
with
tsf_channel_note_on(g_TinySoundFont, chn, bData1, 1.0 / 127 * bData2);
tsf_channel_note_off(g_TinySoundFont, chn, bData1);
i play midi note (on/off) and with
int SampleCount = (size / (2 * sizeof(short))); //2 output channels
tsf_render_short(g_TinySoundFont, (short*)stream, SampleCount, 0);
i get the actual audio stream for the whole tsf backend.
Is it possible to get an separate audio stream for a (midi) channel? So I can use my own audio effects per MIDI channel and then mix them finally.
thx - kmatze
I'm doing it in my code to support effects per channel.
tsf* f = ...;
struct tsf_voice* v = f->voices, * vEnd = v + f->voiceNum;
for (; v != vEnd; v++)
{
if (v->playingPreset != -1)
{
TSF_MEMSET(buffer2, 0, sizeof(float) * SamplesMix);
tsf_voice_render(f, v, buffer2, samples);
``` ....
Thx, that`s a good entry, but i get only crazy noise.
So far I had used the following code:
SFGetSample(sndSF2, waveBufLen); // get synth data streams ...
tal_effect(sndSF2, waveBufLen, sfxSF2); // ... process them with effects
tal_mixer(soundbuf[i], snd1, sndSF2, snd3, waveBufLen); // ... an mixing together
void SFGetSample1(void *stream, long size) {
int SampleCount = (size / (2 * sizeof(short))); //2 output channels
tsf_render_short(g_TinySoundFont, (short*)stream, SampleCount, 0);
}
i change it to:
void SFGetSample(void *stream, long size) {
int SampleCount = (size / (2 * sizeof(short))); //2 output channels
struct tsf_voice *v = g_TinySoundFont->voices;
struct tsf_voice *vEnd = v + g_TinySoundFont->voiceNum;
for (; v != vEnd; v++) {
if (v->playingPreset != -1) {
TSF_MEMSET(stream, 0, sizeof(float)* SampleCount);
tsf_voice_render(g_TinySoundFont, v, stream, SampleCount);
}
}
}
and get crazy noise
i don`t understand the logic of voice and channels, is it the same? Can you explain it please and the use of effect support.
thank you very much - greetings - kmatze