InDashPC.org Forum Index InDashPC.org
In Dash Car PC forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

pyMedia cdda bytes length

 
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software
View previous topic :: View next topic  
Author Message
f.e
Newbie


Joined: 02 Mar 2006
Posts: 8

PostPosted: Thu Mar 02, 2006 2:06 am    Post subject: pyMedia cdda bytes length Reply with quote

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
View user's profile Send private message
f.e
Newbie


Joined: 02 Mar 2006
Posts: 8

PostPosted: Thu Mar 02, 2006 6:50 am    Post subject: Reply with quote

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
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Thu Mar 02, 2006 7:57 am    Post subject: Reply with quote

cdda object exports file like object. So you can do f.seek( 0, pymedia.removable.cd.SEEK_END ) and then f.tell(). Try that Smile
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
View user's profile Send private message
f.e
Newbie


Joined: 02 Mar 2006
Posts: 8

PostPosted: Thu Mar 02, 2006 8:51 am    Post subject: Reply with quote

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
View user's profile Send private message
jbors
Site Admin


Joined: 12 Nov 2004
Posts: 1675

PostPosted: Thu Mar 02, 2006 10:28 am    Post subject: Reply with quote

This is OS project. Feel free to send docs, or anything you can Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    InDashPC.org Forum Index -> Software All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group