Author Topic: Vumeter crackling  (Read 180 times)

CanK

  • Posts: 2
Vumeter crackling
« on: 28 Jun '18 - 13:24 »
Hi,

i have a problem with Vumeter. I have a channel, added to a default mixer and a master mixer where default mixer is added. (channel -> mixer1 -> master mixer) to be more clear :)
as seen in my code, channel and mixer are in decode mode, and my master mixer is in sample_default mode.

when i get vumeter data from master mixer, all is fine but when i get it from mixer1 or channel, audio gets crackled.

edit: i might say it sounds more like light deep tick sound

i need to get vumeter data from mixer1 because i'll have 3 or 4 more mixers added to master mixer and they'll be playing all the time. so getting vumeter from master mixer is off topic :)

any help appreciated.

thnx in advance



Code: [Select]
let rootpath = __dirname
let path = require('path')
const Player = require('./smg/playerCan/basswrapper').basswrapper
let bass = new Player(rootpath);

bass.BASS_Init(-1, 44100, bass.BASS_DEVICE_SPEAKERS);

let fname = path.join(rootpath, 'test1.mp3');
let channel = bass.BASS_StreamCreateFile(0, fname, 0, 0, bass.BASS_STREAM_DECODE);

//bass.BASS_ChannelPlay(channel, true);
let q = bass.BASS_ErrorGetCode();
console.log(channel);

setInterval(() => {
    let duration = bass.BASS_ChannelBytes2Seconds(channel, bass.BASS_ChannelGetLength(channel, 0));
    let position = bass.BASS_ChannelBytes2Seconds(channel, bass.BASS_ChannelGetPosition(channel, 0));
    console.log(`${position}-${duration}`)
}, 1000)

let mixer = bass.BASS_Mixer_StreamCreate(44100, 2, bass.BASS_STREAM_DECODE);
let masterMixer = bass.BASS_Mixer_StreamCreate(44100, 2, bass.BASS_SAMPLE_DEFAULT);

let addChan = bass.BASS_Mixer_StreamAddChannel(mixer, channel, bass.BASS_STREAM_DECODE);
let addMixer = bass.BASS_Mixer_StreamAddChannel(masterMixer, mixer, bass.BASS_STREAM_DECODE);
bass.BASS_StreamCreateFile();
bass.BASS_ChannelPlay(masterMixer, 0);
let q1 = bass.BASS_ErrorGetCode();


setInterval(() => {
    let data = bass.BASS_ChannelGetLevel(masterMixer);
    let vuleft = bass.BASS_ChannelGetLeftLevel(data);
    let vuright = bass.BASS_ChannelGetRightLevel(data);
   console.log(vuleft - vuright);
},250);

edit: just tried bass.BASS_STREAM_DECODE | bass.BASS_SAMPLE_DEFAULT on channel and mixer1, as buffer or decode might be the problem but its no use in my case
« Last Edit: 28 Jun '18 - 13:33 by CanK »

CanK

  • Posts: 2
found the solution
« Reply #1 on: 28 Jun '18 - 14:11 »
ok guys, it was my bad :)

adding both channel and mixer with BUFFER flag and using Mixer_ChannelGetLevel fixed it for me.
work like a charm
Code: [Select]
let rootpath = __dirname
let path = require('path')
const Player = require('./smg/playerCan/basswrapper').basswrapper
let bass = new Player(rootpath);

bass.BASS_Init(-1, 44100, bass.BASS_DEVICE_SPEAKERS);

let fname = path.join(rootpath, 'lenka.mp3');
let channel = bass.BASS_StreamCreateFile(0, fname, 0, 0, bass.BASS_STREAM_DECODE );

//bass.BASS_ChannelPlay(channel, true);
let q = bass.BASS_ErrorGetCode();
console.log(channel);

setInterval(() => {
    let duration = bass.BASS_ChannelBytes2Seconds(channel, bass.BASS_ChannelGetLength(channel, 0));
    let position = bass.BASS_ChannelBytes2Seconds(channel, bass.BASS_ChannelGetPosition(channel, 0));
    console.log(`${position}-${duration}`)
}, 1000)

let mixer = bass.BASS_Mixer_StreamCreate(44100, 2, bass.BASS_STREAM_DECODE );
let masterMixer = bass.BASS_Mixer_StreamCreate(44100, 2, bass.BASS_SAMPLE_DEFAULT);

let addChan = bass.BASS_Mixer_StreamAddChannel(mixer, channel, bass.BASS_MIXER_BUFFER);
let addMixer = bass.BASS_Mixer_StreamAddChannel(masterMixer, mixer, bass.BASS_MIXER_BUFFER);
bass.BASS_ChannelPlay(masterMixer, 0);
let q1 = bass.BASS_ErrorGetCode();



setInterval(() => {
    let data = bass.BASS_Mixer_ChannelGetLevel(mixer);
    console.log(data)

    let vuleft = bass.BASS_ChannelGetLeftLevel(data);
    let vuright = bass.BASS_ChannelGetRightLevel(data);
    console.log(vuleft, ' - ', vuright ,'-',data );
},250);

Ian @ un4seen

  • Administrator
  • Posts: 21130
Re: Vumeter crackling
« Reply #2 on: 28 Jun '18 - 14:56 »
i have a problem with Vumeter. I have a channel, added to a default mixer and a master mixer where default mixer is added. (channel -> mixer1 -> master mixer) to be more clear :)
as seen in my code, channel and mixer are in decode mode, and my master mixer is in sample_default mode.

when i get vumeter data from master mixer, all is fine but when i get it from mixer1 or channel, audio gets crackled.

The issue there is that the BASS_ChannelGetLevel call is taking data from the decoding channel (to calculate the level), which is then not available for the mixer to play. As you have since found, the solution is indeed to use BASS_Mixer_ChannelGetLevel instead, which gets the level from the mixer's buffered data instead of directly from the source.