BASS_MP3_SETPOS very slow...

Started by fredvs,

fredvs

Hello Folks
I dot know how to use nBASS_MP3_SETPOS in Bass_StreamCreateFile(FALSE, f, 0, 0, BASS_MP3_SETPOS);
I try to use it to catch the volume at certain positions,
 put that in a array to design the song quicker than the other stream (the same) who is playing.

With a loop, it doesnt work ut with a timer on 1 you have the correct

fredvs

Sorry Pc crashed...
Hemm, o yes, i said  that the stream who catch the position take nearly the same time that the song who play.

I want a array quicker that the song.
Who can explain me how to catch quick the volume of a stream,

now i play the stream, set position, catch volume in array, set position to next,etc till the end.

I get correct values, perfect for design, ut it is verry slow, only a litle it quicker than the song.

Perhaps it is not the good way....

Ian @ un4seen

You probably don't need to use the BASS_MP3_SETPOS flag for what you're trying to do - it should be accurate enough without it.

fredvs


QuoteYou probably don't need to use the BASS_MP3_SETPOS flag for what you're trying to do - it should be accurate enough without it.
Alright, but too slow.
Do you know a other way to design a wave form, quick (max  3 sec) before playing ?

Ian @ un4seen


fredvs

#5
Hello, here how i do to catch the waveform (while a other stream play the same song). It is not a oscilloscope, i want to have the waveform of 2 streams to see where you begin the mix of second song, where finish first song. Then you can change the end-position of first song on the waveform and begin-pos of second song on second waveform and give it to Bass. (You can also test your mix with headphones with the second sound card and bass2.dll).


. I use this procedures for first song and for song to mix. Here folows only for one, for the second it is the same.
( They are not very akademikstish, but i get my waveform  :), 'f course it will be better to have the same result quicker  :'( :'( :'()  

procedure Tmixk.Button1Click(Sender: TObject);
begin

x1 := 0;  ///first position or else for zoom
BASS_ChannelStop(strima);
BASS_StreamFree(strima);
strima := Bass_StreamCreateFile(FALSE, f2, 0, 0, BASS_MP3_SETPOS); //Open the file to decode (f2 = f = the stream playing). With BASS_STREAM_DECODE, my array is alway 0....?!!! with BASS_MP3_SETPOS, it process a litle quicker.//

form2.canvas.pen.width := 1 ;// setup canvas//
form2.Canvas.Pen.Color := clsilver;// setup canvas//

 
BASS_StreamPlay(strima, FALSE, 0)  ; ///its what do the procedure so slow, without Play i get a array = 0...//
timer1i.Enabled := true; ///timer on 1/1000 sec, (with do while it does not work, my array is null).//

end;


procedure Tmixk.Timer1iTimer(Sender: TObject);
var
volu, fre : dword ;
pa : integer ;
begin

timer1i.Enabled := false;
if  timer1i.tag =  0  then
  begin

BASS_ChannelSetPosition(strima, round((x1 * ledi) /1000)) ; /// ledi lenght of stream (or part for zoom), 1000 the lenght of canvas...//

BASS_ChannelGetAttributes(strima, fre, volu, pa); //or BASS_ChannelGetLevel(strima), it is the same//

  if volu < 0 then volu := -1 * volu ;/// sometimes i get volu < 0 ?????///

form2.Canvas.PolyLine([Point(x1,volu div 2), Point(x1,(volu + (volu div 2))]); ///  volu div 2 to have the waveform in center....//

   volume[x1] :=  volu ;// put volu in array volume[0..1000] for refresh the waveform later....

   application.ProcessMessages; //  Yield to system

 x1 := x1 + 1 ; // next position

 timer1i.Enabled := true;

if x1 = 1000 then
begin
  timer1i.Enabled := false;
 timer1i.tag :=  1 ;

BASS_ChannelStop(strima);
    BASS_StreamFree(strima);

  end;
  end;


It design a correct waveform, But too slow, only a few quicker than the song playing, it would Be Better with stream decode, But it does not work with me...

Ian @ un4seen

I'm not sure where to start :D

If you're wanting to "catch the waveform" in advance (and at speed), you should probably really use a decoding channel (BASS_STREAM_DECODE) and BASS_ChannelGetData. But if you're unfamiliar with PCM sample data, then you can probably get away with using a normal stream and BASS_ChannelGetLevel, by playing the stream with it's volume set to 0.

You should certainly not be using BASS_ChannelGetAttributes.

Anyway, the reason it's apparently slow is that, even though you may request a 1ms timer period, you will not get that on Win2k/XP unless you use a multimedia timer and increase the timer resolution to 1ms. Else, the period will be atleast 10ms, so it'll take atleast 10 seconds for your timer to be called 1000 times. But I don't think you should use a timer anyway - just do the processing in a loop until you reach the end :)

fredvs

'f Course i dont want to use a timer. :-[ Then for a song of 3 min, it will taken 30 sec, it is much too much.
I have to use getdata, But how, it is The question (i need only the volume)... :'(