After many researches I found this solution:
#include <cstddef>
#include <stdio.h>
#include <stdlib.h>
#include "bass.h"
int main(int argc, char **argv) {
BASS_Init(0 /* "NO SOUND" device */, 44100, 0, 0, NULL);
if (argc == 3) {
int block = atoi(argv[2]); // take levels every argv[2] ms
if (block < 20)
block = 20;
HSTREAM chan = BASS_StreamCreateFile(FALSE, argv[1], 0, 0,
BASS_STREAM_DECODE);
if (chan) {
// BASS_ChannelGetLevel takes 20ms from the channel
QWORD len = BASS_ChannelSeconds2Bytes(chan,
(float) block / (float) 1000 - (float) 0.02);
char data[len];
DWORD level, left, right;
while (-1 != (level = BASS_ChannelGetLevel(chan))) // takes 20ms
{
left = LOWORD(level); // the left level
right = HIWORD(level); // the right level
printf("%i, %i\n", left, right);
BASS_ChannelGetData(chan, data, len); // get data away from the channel
}
BASS_StreamFree(chan);
}
}
BASS_Free();
return 0;
}
This code to get levels and output it to STDOUT.
to run it : ./levels 1.mp3 5000 >levels.txt