1

i've got the following problem: I want to create bindings for the bass library (http://www.un4seen.com/) in python and ran into the following problem: The library allows to create streams to files laying in memory. But the documentation just says that it requests a void *file pointer, nothing about the containing format, nothing. I tried several things, played around with ctypes, tried the following (using python 2.7 on a Windows 7 x64 machine):

import ctypes
data=open('my filename.wav').read()
pointer=ctypes.POINTER(data)
cdata=ctypes.c_char_p(data)
cpointer=ctypes.byref(cdata)

however, whatever I pass into my function, it causes a pythonic exception or bass returns an error because an illegal parameter type has been specified. You can find my programmed code at https://github.com/Timtam/Bass4Py That's where I want to pass a file into. Probably I want to make it as easy as possible, giving a string with the files content to the function and converting this string into a format I can give to bass so it will create the stream. But for now I stuck with the simple acceptance from bass and my pointer problem... It would be very nice if someone could read into my code and explain what to do, maybe someone has already used bass, maybe with python too? Of course I searched in here and tried search patterns like "passing string pointers with ctypes" and such things and tried everything I found, but I actually don't know what bass wants from me... Thank you in advance.

Toni Barth
  • 53
  • 9

1 Answers1

0

I didn't look through the code. However, based on what you have described, I would suggest you to take a look at the WinApi functions CreateFile, CreateFileMapping, OpenFile (and so on) and PyWin32. The way it's done in Linux is identical.

Community
  • 1
  • 1
Max Malysh
  • 29,384
  • 19
  • 111
  • 115
  • The thing is, that I can't use pywin32, because the bass api is cross-platform. It would be nice to know a way it can be done on windows, linux and probably mac too. – Toni Barth Apr 21 '14 at 15:35