i'm working on a project and i need to get the level of an audio track, for that I'm using the method BASS_ChannelGetLevel from BASS audio library (C++). But the problem is that it always return a 0 for me and I don't understand why! The documentation says that the method will return 0 when a channel is stalled.
Please find the code that i'm using below:
#include <iostream>
#include "bass.h"
using namespace std;
int main() {
DWORD level, left, right;
double pos;
if (BASS_Init(-1, 44100, BASS_DEVICE_DEFAULT, 0, NULL)) {
// create the stream
int stream = BASS_StreamCreateFile(FALSE, "test.ogg", 0,
BASS_STREAM_DECODE, BASS_SAMPLE_FLOAT);
if (stream != 0) {
BASS_ChannelPlay(stream, FALSE);
level = BASS_ChannelGetLevel(stream);
} else
cout << "error 1: " << BASS_ErrorGetCode() << endl;
left = LOWORD(level); // the left level
right = HIWORD(level); // the right level
cout << " low word : " << left << endl;
cout << " high word : " << right << endl;
cout << "error 3: " << BASS_ErrorGetCode() << endl;
// free the stream
BASS_StreamFree(stream);
// free BASS
BASS_Free();
}
}