473,402 Members | 2,064 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,402 software developers and data experts.

how to convert pymedia.audio.acodec ACString to ctypes.c_char_p

Hello All Experts,

I am quite new to Ctypes. I am using one c library and writing python
bindings for it.
I need to pass a character pointer to one function.

I am reading one mp3 file and decoding it to raw pcm using pymedia.
Now I need to pass this raw data in to a
C function. Here is my code.

Expand|Select|Wrap|Line Numbers
  1. # /*********
  2. from ctypes import *
  3. import pymedia.audio.acodec as codec
  4.  
  5. dec = None
  6. dm = muxer.Demuxer('mp3')
  7. fp = open('test.mp3', 'rb')
  8. fingerprinting_done = False
  9.  
  10. while  not fingerprinting_done:
  11.     s = fp.read(20000)
  12.     frames = dm.parse(s)
  13.  
  14.     for fr in frames:
  15.         if dec == None:
  16.             dec = codec.Decoder(dm.streams[0])
  17.  
  18.          r = dec.Decode(fr[1])
  19.  
  20.          if r and r.data:
  21.               # pass this r.data to the C function.
  22.               # r.data is ACString object
  23.               # I cannot do pcm_audio = c_char_p(r.data) . gives me  following error
  24.               # TypeError: string or integer address expected instead  of ACString   
  25.               # instance
  26.  
  27. # *************/
I am getting error while converting r.data (which is ACstring object)
in to ctypes.c_char_p.
can you help me solving this problem?

any help would be appericiated,
Thank you,
sanket
Dec 19 '08 #1
1 3091
try this line instead

Expand|Select|Wrap|Line Numbers
  1. pcm_audio = ctypes.py_object(r.data)
hope it helps :)
Jan 11 '09 #2

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

Similar topics

4
by: CptPicard | last post by:
Hi, I am currently trying to use pymedia so to get the following informations (author, song title, ...) from a mp3 file. The documentation I downloaded is quite limited : It gives some clues on...
1
by: Dmitry Borisov | last post by:
> > Thank you for your help! > > "Lawrence Oluyede" <raims@dot.com> wrote in message > news:3x8w4pqd3emo.15wp1jkrwkqua.dlg@40tude.net... > > In data Thu, 05 Aug 2004 02:28:48 GMT, CptPicard ha...
1
by: Dmitry Borisov | last post by:
From: "CptPicard" Date: Thu, 05 Aug 2004 17:48:04 GMT Subject: Re: Re: Need help on how to use Pymedia! > > Here is the code which will give you what you need( from pycar ). It is > modified to...
1
by: Ron Provost | last post by:
Hello, I'm developing a piece of software to assist illiteraate adults to learn to read. I'm trying to figure out how, if possible, to make audio playback asynchrnous but still controllable. ...
1
by: sjdevnull | last post by:
Hey, I'm trying to wrap GNU readline with ctypes (the Python readline library doesn't support the callback interface), but I can't figure out how to set values to a variable inside the library. ...
3
by: Chris AtLee | last post by:
Sorry for the repeat post...I'm not sure if my first post (on May 30th) went through or not. I've been trying to write a PAM module using ctypes. In the conversation function (my_conv in the...
0
by: Carlos Leite | last post by:
Is there any other option to analyze audio frequencies? Or Any here try to use pymedia to a simple audio FingerPrint. A cant understand what the information the asBands() really giveme....
6
by: Jack | last post by:
I'm not able to build IP2Location's Python interface so I'm trying to use ctypes to call its C interface. The functions return a pointer to the struct below. I haven't been able to figure out how...
2
by: Sells, Fred | last post by:
Diez wrote... You're right the ctypes does seem more pythonesque; however I'm still stuck trying return all these parameters that the c api uses. my ctypes code is below. It just quits running...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.