Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Visualizer data translation (Read 3099 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;
stream->get_chunk_absolute(wave,time,2048);
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;
stream->get_spectrum_absolute(fft,time,2048);
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.

Thanks!
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.
Stay sane, exile.