473,739 Members | 4,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with this code

28 New Member
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 1308

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

Similar topics

6
2667
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 gethelp(nn) where nn is the helpid. The function is contained in a header file called funcs.inc that each page
2
1403
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 used in Car Park Management, Library Management and Yellow Page Management. For the purpose of fully understanding explanatory notes should be added for each Source Code. Many thanks in advance!!!!
6
3022
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 an html authoring tool to help you accomplish? 2. What do you expect from online help for a html authoring tool? 3. What audience do you think a freeware html authoring tool is directed towards?
4
2635
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 type in a command line that runs the help in the correct Context from a button on each form. It all worked fine - HERE. The problem is that when I sent it out to a site, the help file was not able to be accessed because it was my path in the...
1
1635
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 a perfectly good UI for viewing help. However, instead of loading a static HTML file from the disk like the Windows version does, it visits the doc directory on python.org over the internet. Is there any reason for that? It's noticably slower...
1
2289
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 button the list is populated with a list of that genre. I have got the interface done to satisfaction, my problem is that when i press the change genre button nothing happens and when i select a track to play from the list which is setvisible and...
10
3364
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 the worst I ever seen. I almost cannot find anything I need, including things I
45
4288
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 number of cents required, find the correct and most effective combination of stamps. meaning that if you were to need 14cents, the correct output should be 2 seven cents not 7 two cents.
1
1440
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 communicate with them and I have installed it and coded a VB6 app to provide the interface. Here is the problem. The ASP gets an error "Exception occurred" message. When I respond to the error, the returned XML is not received. Also, the ASP stops via the...
1
1057
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 access but there are alot of error. the name of the table in the access is Hotel and the the fields are HotelName and HotelAddress . Please can somebody help me and debug. i used vb.net Note: almost all the line is underlined with red line indicating...
0
8792
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9479
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9266
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6754
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.