Skip to main content


Please be aware that much of the software linked to or mentioned on this forum is niche and therefore infrequently downloaded. Lots of anti-virus scanners and so-called malware detectors like to flag infrequently downloaded software as bad until it is either downloaded enough times, or its developer actually bothers with getting each individual release allow listed by every single AV vendor. You can do many people a great favor when encountering such a "problem" example by submitting them to your AV vendor for examination. For almost everything on this forum, it is a false positive.
Topic: Visualizer data translation (Read 2448 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Visualizer data translation

I'm currently doing a remake of the foo_uie_wmpvis component but for the default user interface.

I've comed to the point where I need to send the wmp visualizer the audio data, and while it *works* it's obviously not correct and not very efficient either.

My current implementation is as follows, note that wmp uses TimedLevels to specifiy playing data.
Code: [Select]
double time;
stream->get_absolute_time(time); // <- visualisation_stream_v3
levels->timeStamp = time * 10;

audio_chunk_impl wave;
for (int channel=0;channel<2 && channel<wave.get_channels();channel++)
    for(int offset=0;offset<1024 && offset<wave.get_data_length();offset++){
        levels->waveform[channel][offset] = wave.get_data()[offset]*255;

audio_chunk_impl fft;
for (int channel=0;channel<2&&channel<fft.get_channels();channel++)
    for (int freq=0;freq<1024 && freq<fft.get_data_length();freq++){
        levels->frequency[channel][freq] = abs(fft.get_data()[freq])*255;


As you can see I don't know how to get the correct channels and every frame two extra copies of the entire data needs to be done, obviously not very fast.

I'm also using the legacy fft mode since the new one resulted in somewhat flat visualizers.

I just like listening to music

Visualizer data translation

Reply #1
In a chunk, channels are stored interleaved. That is, in a stereo file it's on the form of LRLRLR.
The order of the channels in a frame (one sample from each channel) is the order they are defined in the enum in audio_chunk (which incidentally mentions this in a comment).
I wouldn't worry too much about any copying of data, it's likely rather neglible.
Zao shang yong zao nong zao rang zao ren zao.
To, early in the morning, use a chisel to build a bathtub makes impatient people hot-tempered.

SimplePortal 1.0.0 RC1 © 2008-2021