473,320 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help with this code

28
I use ctypes to play AUDIO using bass.dll found here:
Un4seen Developments - 2MIDI / BASS / MID2XM / MO3 / XM-EXE / XMPlay
I have gone so far and tried as they advised me at their forum entry here:
New Python Developer with Bass
But I still get errors. Can anyone take code and analyze to point out source of error?
Here is the code, pse ignore any useless comment, I was using the editor as scratch pad too :D
Expand|Select|Wrap|Line Numbers
  1. #import ctypes module
  2. import ctypes as ct
  3. #import OS
  4. import os
  5. #get BOOL C++ value from ctypes
  6. from ctypes.wintypes import BOOL
  7. from ctypes.wintypes import HANDLE
  8. #Loading the DLL see: http://www.daniweb.com/forums/thread160430.html
  9. bass_dll = ct.windll.bass
  10. #initialize the DLL 
  11. # sample I got somehwere: BASS_Init(-1,44100,0,win,NULL) win The application's main window... 0 = the current foreground window (use this for console applications). 
  12. #function to intialize the DLL
  13.  
  14. def onInit_Lib():
  15.     #define arg types
  16.     bass_dll.BASS_Init.argtypes = [ct.c_int, ct.c_int, ct.c_int, ct.c_int, ct.c_int]
  17.     #define result types
  18.     bass_dll.BASS_Init.restype = ct.c_int
  19.     #call function with args
  20.     c= bass_dll.BASS_Init(-1, 44100, 0,0, 0)
  21.     print c
  22.  
  23. def onStream():
  24.     #arg definitions
  25.     #HSTREAM BASS_StreamCreateFile(BOOL mem, void *file, QWORD offset, QWORD length, DWORD flags);
  26.     bass_dll.BASS_StreamCreateFile.argtypes = [BOOL, ct.c_char_p, ct.c_int , ct.c_int, ct.c_int]
  27.     #defining restypes
  28.     bass_dll.BASS_StreamCreateFile.restype = HANDLE
  29.     path = os.getcwd()
  30.     full = os.path.join(path, "test.mp3")
  31.     print full
  32.     stream = bass_dll.BASS_StreamCreateFile(False, full, 0, 0, 0)
  33.     print stream
  34.     return stream
  35.  
  36. def onPlay(stream):
  37.     #define args
  38.     #BASS_ChannelPlay(stream, FALSE); // play the stream
  39.     bass_dll.BASS_ChannelPlay.argtypes = [HANDLE, BOOL]
  40.     #call function
  41.     bass_dll.BASS_ChannelPlay(stream, False)
  42.  
  43. onInit_Lib()
  44. stream = onStream()
  45. onPlay(stream)
  46.  
With thanks,
Dec 18 '08 #1
0 1288

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Edward King | last post by:
Hi! I am trying to achieve the following: I have a number of help pages (in the format help_nn.php where nn=helpid). I want to be able to open a particular help page by calling the function...
2
by: sunfox | last post by:
Please help!! I have a difficulty in writing an assignment which is related to Visual C++ V6.0. Can anybody here assist me to write a program which is able to run under DOS? The program will be...
6
by: d.warnermurray | last post by:
I am doing a project for school that involves creating help files for a html authoring tool. If you could help me with answers to some questions it would really help. 1. What tasks do you expect...
4
by: dixie | last post by:
Help, I'm really out of my depth here (not unusual I hear you say :-). I have just installed HTML Help in an application. I told it in the Project Properties the path to the help file. I then...
1
by: Paul Rubin | last post by:
In Windows if you click the Help dropdown, IDLE launches a help window as it should. The help contents are included in the installation. In Linux, clicking Help launches a web browser, which is...
1
by: glenn123 | last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre...
10
by: JonathanOrlev | last post by:
Hello everybody, I wrote this comment in another message of mine, but decided to post it again as a standalone message. I think that Microsoft's Office 2003 help system is horrible, probably...
45
by: davy.zou | last post by:
I have started learning c++ and I need help. I need to write a program, the question is as follows. At a post office, there are a certain number of 2, 7, and 9cents stamps, now, given a total...
1
by: dsoutherland | last post by:
I am so new to ASP I'm not sure I am breathing. A company one of my clients deals with provides information over the web. They provided the ASP code for a default web site that is used to...
1
by: menyki | last post by:
help 'e debug -------------------------------------------------------------------------------- I wrote the below code to input new data from name and address textbox of a form to microsoft...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.