audio equaliser
BlitzMax Forums/BlitzMax Programming/audio equaliser
| ||
what would be the best way of creating a graphic equalizer using Blitzmax? or at least get real time audio data for visualizations. there are quite a few audio libraries available for BM now, would one be better than another for this sort of thing? Cheers Charlie |
| ||
Most of them (well, all the ones I've done) give some kind of access to the live data. Perhaps just the current levels for L/R, or full access to the PCM data stream. For example, BASS has BASS_ChannelGetLevel, which returns a 32bit number. The low and high words (16bits/0-32767) give the left and right levels. I use that for the bouncy wotsit thing in my little net-radio app. |
| ||
You mean sound spectrum? FMOD supports this, give bruceys module a check on it - i've been successful in using it for visualizations based on target sound channels, as where BASS module doesn't (or didn't a few months ago) support sound spectrum for audio output...boo that. Good luck. |
| ||
where BASS module doesn't support sound spectrum You mean like FFT data? I'm sure that's what BASS_ChannelGetData() is for? |
| ||
I'll take a look at BASS then if it can do that (FFT spectrum stuff). i couldn't see it on your modules page though Brucey, where can i find it? Cheers Charlie |
| ||
i couldn't see it on your modules page though Brucey, where can i find it? It's not "officially" released yet... :-) But if you can figure out SVN, all mods, released and WIP, are to be found lurking around here : http://code.google.com/p/maxmods/source/checkout Note, you may not want to checkout all the modules, as there is a lot there. Pick and choose - unless you've plenty of bandwidth to waste :-) If you aren't up on SVN, then you'll have to wait a bit longer for the release. Still some things to tidy up - although it's working rather well (at least for my uses). |
| ||
BASS gives access to the FFT stuff :) Pseudo code :- Global spectrum:TBank = CreateBank(2048) ' bank for data transfer .. . Function UpdateSpectrum() ' grab the FFT table BASS_ChannelGetData(<channel>, spectrum.Buf(), BASS_DATA_FFT512) ' Step thru the 512 For Local i:Int = 0 To 512 Step 16 ' Local val# = PeekFloat(spectrum, I) ' grab data in the range Next End Function ChannelGetData can also grab the sample source too Other options for getData BASS_DATA_FFT256 = &H80000000 ' 256 sample FFT BASS_DATA_FFT512 = &H80000001 ' 512 sample FFT BASS_DATA_FFT1024 = &H80000002 ' 1024 sample FFT BASS_DATA_FFT2048 = &H80000003 ' 2048 sample FFT BASS_DATA_FFT4096 = &H80000004 ' 4096 sample FFT BASS_DATA_FFT8192 = &H80000005 ' 8192 sample FFT adjust your spectrum:Tbank size to accomodate the table size of course. |
| ||
ok, i've downloaded and built the BASS module, however i can't get any of the examples to work because it can't find BASS.dll. Bass.dll is there in the lib/win32 folder, and i also copies it to the examples directroy to no avail. what am i missing? and thanks stu, that looks like useful code :) Cheers Charlie |
| ||
Copy the BASS.DLL into the same folder that you compile and run your EXE from. |
| ||
I'm sure that's what BASS_ChannelGetData() is for? Hmm...when I was comparing bass and fmod looking to get this working the main dev of bass claimed it was only possible through recording devices and not sound output yet, maybe I misunderstood, or read an outdated post. Bass is definitely a top choice then =p edit: woops, i'm an idiot - I believe that was irrklang. |
| ||
using Stus code, i get an error message (unable to convert bah.bass.tbasschannel to int on this line: BASS_ChannelGetData(channel, spectrum.Buf(), BASS_DATA_FFT512) the docs say i shouldbe sending a channel parameter, so i don't really understand what the problem is. Cheers Charlie |
| ||
The module is wrapped in an OOP style - my preference, rather than a flat procedural style... although you can probably access most of it flat, if you really want to. So, to use a channel, a TBassChannel, you would do something like : channel.GetData(bytearray, length) which also returns number of bytes read. Generally with all my mods, things like handles and pointers are hidden away, and you use Objects to access everything. Anyhoo, that should work :-) |
| ||
If your using Bruceys' OOP style and you want to call it direct use BASS_ChannelGetData(channel.handle, spectrum.Buf(), BASS_DATA_FFT512) I use Bruceys wrapper - but not the OOP stuff, as Im comfortable with the BASS raw calls. If your just starting with BASS, then Id stick with Bruceys Objects. |
| ||
thanks guys :) so far i've come up with this: Global spectrum:TBank = CreateBank(2048) ... channel.getdata(spectrum.Buf(),BASS_DATA_FFT512) For Local i:Int=0 To 512 Local h:Float=PeekFloat(spectrum,i) h=-Sqr((h))*3*100 If h<100 And h>-100 DrawRect i,300,1,h End If Next added to the example6.bmx example that comes with the mod. some of the numbers that BASS produces are really big/small, so i'm having to cap the height quite a bit and not draw those. otherwise it looks ok. i'm guessing there is a better way of using the data, but i can't figure out how to make those values it returns more usable. Cheers Charlie |
| ||
throwing a step 4 at the for loop produces nicer results. It's really cool that this works with internet streams too. Awesome module Brucey :) Cheers Charlie |
| ||
some pics of a day not doing what i should be doing... having fun :) |
| ||
Oooh. Pretty :-) |
| ||
more pics, this time with an itunes-ey feel :) |