Scope visualisation of complexe waveform

Started by RisingMoon,

RisingMoon

Hi Ian,

in an multi-audio-generator, I implemented 8 single Bass streams and mix them into one Bass mixer. Each stream[0..7] can make its own waveform (sinus, sawtooth, etc) and can be individually muted. Two graphes are added to show waveform in time and freq domains (scope and spectrum).

Following proc is called every 100 ms on one timer event :

SetLength(BufScope, ScopeWidth);            // mixer main output
iRet := BASS_ChannelGetData(FAudioGens.MainOut.BassMixer, BufScope, SizeOf(SmallInt) * ScopeWidth); // get the sample data
if iRet > -1 then
begin
  // optional filtering (low-pass filter, cutoff after lowest used freq)
  // ...
  // wait rising amp and amp > 0
  // ...
  // trig when amp > threshold
  // ...
  // draw scope with fixed size
end;

All works fine for scope and spectrum for single activated gen, but scope drawing is instable when several gens (different freqs) are activated - without surprise.
I tried several triggering methods (single threshold, with or without filter to catch lowest freq component), none of them really works in all cases.

Please, can you advise a method to allow stable triggering with complex waveform ?
Do you think Auto-correlation is the best way ?

Thanks,
Remy

Ian @ un4seen

It isn't clear to me what you want to do. Are you trying to detect the source waveforms in the mix? If so, perhaps you could simply use BASS_Mixer_ChannelGetData to get them individually (after adding BASS_MIXER_CHAN_BUFFER to the BASS_Mixer_StreamAddChannel calls).

RisingMoon

Hi Ian,

thanks for your answer.

In my project, there are 8 individual streams, each of them allow built sinus, square, triangle, sawtooth, with individual freq and amplitude (and they can be activated or muted with Mute/Solo buttons as in a traditionnal audio mixer). The 8 streams are mixed together with a Bass_Mixer (and associated BASS_Mixer_StreamAddChannel proc) and the result (mixed stream) go to main audio device output. All works fine on that side.



Showing individual stream waveform is not a problem and work as expected, using BASS_ChannelGetData for samples buffer reading (for Time and Spectrum) :
BASS_ChannelGetData(FAudioGens.MainOut.BassMixer, BufScope, SizeOf(SmallInt) * ScopeWidth);
BASS_ChannelGetData(FAudioGens.MainOut.BassMixer, @BufFFT, BASS_DATA_FFT4096);

What I want to show on graphes are time and spectrum representation of MIXED stream.
Absolutely no problem for spectrum, and no problem when only one stream is activated ("simple" waveform at mixer output). But when activating several streams with differents waveforms, instability can be observed for Scope/Time visualisation. Absolutely normal, as start of drawing triggering point can occur at differents places for the same mixed signal.

What I search do do now is get better triggering function to allow better stability of the scope/Time graph for "hard to trig" waveforms.

Exemple of waveform that is correctly triggered :


Exemple of waveform that is not always correctly triggered :


I regulary use hardware analog or digital scopes and know complex waveform are sometimes difficult to stabilize without filtering or external triggering. So I think that what I want to do is not  simple task ;)

Ian @ un4seen

Oh, so you basically want your display to freeze for the same waveform? You could keep your existing trigger code but then also check how closely the data at the trigger point matches the displayed data. That could mean just summing the differences in the data, so lower total = closer match. You should also request more data from BASS_ChannelGetData, so that you can search for trigger points (not only at the start of the data). If you find a very close match, you can leave the display as it is, otherwise replace it with the data at a trigger point (if found).

BASS_ChannelGetData(FAudioGens.MainOut.BassMixer, BufScope, SizeOf(SmallInt) * (ScopeWidth + SearchWindow));

I haven't tried this myself, but it seems like it should work :)

RisingMoon

Thank you, Ian, I'll try this.

I have to say I want time display (scope) don't freeze if I activate two single sinus waves with low frequency difference (for example 800.0 Hz and 800.1 Hz) to show Beat phenomenon on long periode.

Remy