| View previous topic :: View next topic |
| Author |
Message |
f.e Newbie
Joined: 02 Mar 2006 Posts: 8
|
Posted: Thu Mar 02, 2006 2:06 am Post subject: pyMedia cdda bytes length |
|
|
Hello,
i'm stuck on how to know what is the total length in bytes of a cdda track. I guess i need to know that in order to grab the entire track correctly, do i ?
The read_cdda_track.py from the CVS doesn't appear to clear the problem for me...
Why couldn't i set the bytes to -1 in order to say : "read all the track" ?
Best regards
f.e |
|
| Back to top |
|
 |
f.e Newbie
Joined: 02 Mar 2006 Posts: 8
|
Posted: Thu Mar 02, 2006 6:50 am Post subject: |
|
|
ok.
i made something like this :
def getLenFromToc(self, track):
c=cd.CD(0)
props= c.getProperties()
toc=str(props['TOC'][track-1])
trLen=str.strip(toc, "( )")
trLen=str.replace(trLen, "L", "")
trLen=str.split(trLen,",")
trackLen=int(trLen[1])*2352 # length in bytes
return trackLen
where 'track' is an int.
nb:'self' is only here because this function is implemented in a wrapper for another software (currently max/msp through pyext object)
thanks anyway
f.e |
|
| Back to top |
|
 |
jbors Site Admin

Joined: 12 Nov 2004 Posts: 1675
|
Posted: Thu Mar 02, 2006 7:57 am Post subject: |
|
|
cdda object exports file like object. So you can do f.seek( 0, pymedia.removable.cd.SEEK_END ) and then f.tell(). Try that
Another option would be to get TOC and do the math like you mentioned.
Here is the sample code: | Code: | import pymedia.removable.cd as cd
cd.init()
cd.getCount()
c= cd.CD(0)
f= c.open( 'Track 02' )
f.seek( 0, cd.SEEK_END )
print 'Track 2 size:', f.tell() |
|
|
| Back to top |
|
 |
f.e Newbie
Joined: 02 Mar 2006 Posts: 8
|
Posted: Thu Mar 02, 2006 8:51 am Post subject: |
|
|
That's great ! It works quiet well and it's shorter than my math solution...
Thanks a lot, jbors
by the way, why all the methods aren't listed in the doc ? i really like pymedia module but a few enhancements in the documentation would be great. And more examples too...
best regards
f.e |
|
| Back to top |
|
 |
jbors Site Admin

Joined: 12 Nov 2004 Posts: 1675
|
Posted: Thu Mar 02, 2006 10:28 am Post subject: |
|
|
This is OS project. Feel free to send docs, or anything you can  |
|
| Back to top |
|
 |
|