Yes, BASS can work. I found some discussions using BASS with Realbasic but no projects so far. I’ve never used a dylib file before but a search here led directly to what I needed to know and managed to make it move
This project only works on mac, where the library is a dylib file. I added a Copy Files Build Step to put that dylib into the built apps Frameworks folder and then the library constant for the declares points to that file. I believe if you just do the same with a dll and add the Windows Platform to the library constant it should work on Windows, but I’m not sure if the path will be the same.
Once that got worked out the functions are pretty easy to declare, at least so far. Really only 3 are needed to begin pulling in samples. The thing is there’s 2 ways to get this data: install a callback (which I don’t know if it’ll have the same callback problem as Audio Toolbox (but this discussion with Aaron Ballman makes me think not!?)) or you can poll it using that function you linked above. I guess maybe you already know all this; anyways I chose to poll.
In this project Module BASS wraps all the library stuff. Constants were implemented as methods returning UInt32 (maybe Xojo constants will work instead). WindowSignal tests the Module by drawing part of the incoming waveform. First, in Open, space is made for the sample data retrieved in each polling, which is going to be 44.1khz mono float.
samples = new MemoryBlock(44100 * 4)
Then the start button initializes the device, starts the recording and starts the polling timer.
dim e As boolean = BASS.RecordInit(-1)
hrec = BASS.RecordStart(44100, 1, BASS.kSample_Float, nil, nil)
theTimer.Period = 1000 / 30 //30fps
theTimer.Mode = Timer.ModeMultiple
hrec is some sorta ‘channel’ identifier. In the API for BASS_RecordStart the return type is HRECORD, which I guessed is a Ptr, and named it before knowing what it is. I think it’s really more a channel object, but everywhere else it’s used it’s typed as DWORD.
Then in polling get the bytes available, copy those bytes to the samples Memoryblock and finally draw
dim bytesAvail As UInt32 = BASS.ChannelGetData(hrec, nil, BASS.kData_Available)
dim e As UInt32 = BASS.ChannelGetData(hrec, samples, bytesAvail)
display.Invalidate
WindowFFT is a duplicate of WindowSignal with just theTimer.Action and display.Paint tweaked to draw frequency.
project http://home.comcast.net/~trochoid/bassRec.zip