Author Topic: Bass.dll crash on Windows 10 which recording mic data  (Read 192 times)

genosha

  • Posts: 9
Looong time since I last posted.

Been trying to get bass.dll to work from Nim - http://nim-lang.org. I've gotten the callback mechanism to work via RecordStart() but considering I want the FFT data, I was trying to use ChannelGetData() but after a few loops, my program crashes. The faster I poll, the faster it crashes. I've adjusted the buffer size to accommodate slower polls and am not filling it up beyond a point, but still see crashes happening.

Here's the code in question:-

while true:
    len = BASS_ChannelGetData(ch, nil, BASS_DATA_AVAILABLE)
    if len > dword(0):
        len = BASS_ChannelGetData(ch, buffer, 16384)
        discard f.writeBuffer(buffer, len)
    elif len == dword(0):
        echo "Waiting"
    else:
        break

    sleep(100)


I don't get any stack trace so suspect there's something fishy in bass.dll or how I'm invoking it.

Any tips will be appreciated!

Thanks in advance.

Ian @ un4seen

  • Administrator
  • Posts: 20272
I'm not familiar with Nim, but I guess you had to create a header/module to use BASS with it yourself? Make sure that's using the "stdcall" calling convention on Windows.

Have you confirmed that the crash is happening in a BASS_ChannelGetData call, and which one? If a debugger doesn't give a call stack, you could use logging instead to confirm it, ie. write log entries (or "echo" lines like you have for "Waiting") just before and after the calls.

genosha

  • Posts: 9
That worked! ChannelGetData() no longer crashes if it is called using stdcall.

There was no way to tell if the crash was in my code or BASS, i would keep echoing the read length that was read on each call and after some time, it would just die.

Thanks a bunch :D