Author Topic: BASSFX / Bpm detection (Jobnik ??? :) )  (Read 6640 times)

Led

  • Posts: 40
BASSFX / Bpm detection (Jobnik ??? :) )
« on: 27 Jul '03 - 23:23 »
Jobnik :
I've browsed the BassFX project-files quickly,
and as far as I've understood the BPM-detection only works on certain types of channels.

It would be nice if I could just point it to a memorybuffer instead, so I could grab the line-input data, buffer it, and try to detect BPM for a buffer of let's say 8 seconds.

(I'd like to have some sort of bpm-detection on audio *not* played by the pc )

Any chance ..? :)

Ian @ un4seen

  • Administrator
  • Posts: 26079
Re: BASSFX / Bpm detection (Jobnik ??? :) )
« Reply #1 on: 28 Jul '03 - 18:12 »
You could stick a WAVE header at the front of the data, and "load" it with BASS_StreamCreateFile. Or you could create a custom stream and feed the data to that :)

Led

  • Posts: 40
Re: BASSFX / Bpm detection (Jobnik ??? :) )
« Reply #2 on: 29 Jul '03 - 10:45 »
Any thoughts about what would be the fastest method ?

Ian @ un4seen

  • Administrator
  • Posts: 26079
Re: BASSFX / Bpm detection (Jobnik ??? :) )
« Reply #3 on: 29 Jul '03 - 23:01 »
There shouldn't be any real performance difference between the 2 methods... just do whichever is simplest to implement in your code :)

Led

  • Posts: 40
Re: BASSFX / Bpm detection (Jobnik ??? :) )
« Reply #4 on: 30 Jul '03 - 00:56 »
K, I'l have a go with it as soon as I have some spare time :(

Most important thing is that it doesn't keep me from using 99% of my cpu-cycles for graphic-effects :-/

Thanks for the help!
(But if anyone has any other sugestions - I always like to keep my options open :))

Ian @ un4seen

  • Administrator
  • Posts: 26079
Re: BASSFX / Bpm detection (Jobnik ??? :) )
« Reply #5 on: 31 Jul '03 - 12:08 »
Both the above methods will take negligible amounts of CPU.

If you're dealing with a steady flow of sample date (eg. recording), another thing you could try is using a custom decoding stream. And set a BPM callback on that, so as you feed sample data to the stream, you will be notified of the BPM at regular intervals in the data. This method will probably take the least additional CPU of all.
Code: [Select]
HSTREAM dummystream;

DWORD CALLBACK dummystreamproc(HSTREAM handle, void *buffer, DWORD length, DWORD user)
{
// the data is already in "buffer", so just return
     return length;
}

...

// create dummy stream
dummystream=BASS_StreamCreate(samplerate,BASS_STREAM_DECODE,&dummystreamproc,0); // add MONO/8BITS/FLOAT flags if appropriate
// set BPM callback on it
BASS_FX_BPM_CallbackSet(dummystream,...);

Then, to pass data through the dummy stream (and so the BPM calculating stuff too), simply do this...
Code: [Select]
BASS_ChannelGetData(dummystream,buffer,length);
This method can be used to apply DSP/FX to any sample data. I've not tried it with the BPM stuff myself, but it should work in theory :D