let rootpath = __dirname;
let path = require('path');
const Player = require('../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_StreamCreateFile();
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);