Class: Cdio::Track
- Inherits:
-
Object
- Object
- Cdio::Track
- Defined in:
- lib/cdio.rb
Overview
CD Input and control track class
SYNOPSIS
require "cdio"
d = Device.new("/dev/cdrom")
t = d.first_track()
first_track = t.track
num_tracks = d.num_tracks()
last_track = first_track+num_tracks-1
for i in first_track .. last_track
t = d.track(i)
puts "%3d: %06u %-6s %s" % [t.track, t.lsn(), t.msf(), t.format()]
end
puts "%3X: %06u leadout" % [Rubycdio::CDROM_LEADOUT_TRACK, d.disc_last_lsn()]
Instance Attribute Summary collapse
-
#track ⇒ Object
Returns the value of attribute track.
Instance Method Summary collapse
-
#audio_channels ⇒ Object
Returns: Fixnum Return number of channels in track: 2 or 4.
- #cdtext ⇒ Object
-
#copy_permit? ⇒ Boolean
Returns: bool.
-
#format ⇒ Object
Returns: format (String).
-
#green? ⇒ Boolean
Return true if we have XA data (green, mode2 form1) or XA data (green, mode2 form2).
-
#initialize(device, track_num) ⇒ Track
constructor
A new instance of Track.
-
#last_lsn ⇒ Object
Returns: Fixnum (lsn) Return the ending LSN for a track.
-
#lba ⇒ Object
Returns: Fixnum (lba).
-
#lsn ⇒ Object
Returns: Fixnum (lsn).
-
#msf ⇒ Object
Returns: String .
-
#preemphasis ⇒ Object
Returns: String.
-
#sec_count ⇒ Object
Returns: Fixnum.
Constructor Details
#initialize(device, track_num) ⇒ Track
Returns a new instance of Track.
856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 |
# File 'lib/cdio.rb', line 856 def initialize(device, track_num) if track_num.class != Fixnum raise TrackError('track number parameter is not an integer') end @track = track_num # See if the device parameter is a string or # a device object. if device.class == String @device = Device.new(device) else @device = device end end |
Instance Attribute Details
#track ⇒ Object
Returns the value of attribute track.
854 855 856 |
# File 'lib/cdio.rb', line 854 def track @track end |
Instance Method Details
#audio_channels ⇒ Object
Returns: Fixnum
Return number of channels in track: 2 or 4. Not meaningful if track is not an audio track. An exception can be raised on error.
877 878 879 880 881 882 883 884 885 886 |
# File 'lib/cdio.rb', line 877 def audio_channels() channels = Rubycdio::get_track_channels(@device, @track) if -2 == channels raise DriverUnsupportedError elsif -1 == channels raise TrackError else return channels end end |
#cdtext ⇒ Object
888 889 890 |
# File 'lib/cdio.rb', line 888 def cdtext return CDText.new(Rubycdio::get_cdtext(@device, @track)) end |
#copy_permit? ⇒ Boolean
Returns: bool
Return copy protection status on a track. Is this meaningful not an audio track?
896 897 898 |
# File 'lib/cdio.rb', line 896 def copy_permit?() return Rubycdio::track_copy_permit?(@device, @track) end |
#format ⇒ Object
Returns: format (String)
Get the format (e.g. ‘audio’, ‘mode2’, ‘mode1’) of track.
903 904 905 |
# File 'lib/cdio.rb', line 903 def format() return Rubycdio::get_track_format(@device, @track) end |
#green? ⇒ Boolean
Return true if we have XA data (green, mode2 form1) or XA data (green, mode2 form2). That is track begins: sync - header - subheader 12 4 - 8
992 993 994 |
# File 'lib/cdio.rb', line 992 def green?() return Rubycdio::track_green?(@device, @track) end |
#last_lsn ⇒ Object
Returns: Fixnum (lsn)
Return the ending LSN for a track. A TrackError or IOError exception may be raised on error.
911 912 913 914 915 916 917 |
# File 'lib/cdio.rb', line 911 def last_lsn() lsn = Rubycdio::get_track_last_lsn(@device, @track) if lsn == Rubycdio::INVALID_LSN raise TrackError('Invalid LSN returned') end return lsn end |
#lba ⇒ Object
Returns: Fixnum (lba)
Return the starting LBA for a track A TrackError exception is raised on error.
923 924 925 926 927 928 929 |
# File 'lib/cdio.rb', line 923 def lba() lba = Rubycdio::get_track_lba(@device, @track) if lba == Rubycdio::INVALID_LBA raise TrackError('Invalid LBA returned') end return lba end |
#lsn ⇒ Object
Returns: Fixnum (lsn)
Return the starting LSN for a track A TrackError exception is raised on error.
935 936 937 938 939 940 941 |
# File 'lib/cdio.rb', line 935 def lsn() lsn = Rubycdio::get_track_lsn(@device, @track) if lsn == Rubycdio::INVALID_LSN raise TrackError('Invalid LSN returned') end return lsn end |
#msf ⇒ Object
Returns: String
Return the starting MSF (minutes/secs/frames) for track number track. Track numbers usually start at something greater than 0, usually 1.
Returns string of the form mm:ss:ff if all good, or string nil on error.
950 951 952 |
# File 'lib/cdio.rb', line 950 def msf() return Rubycdio::get_track_msf(@device, @track) end |
#preemphasis ⇒ Object
Returns: String
Get linear preemphasis status on an audio track. This is not meaningful if not an audio track? A TrackError exception is raised on error.
959 960 961 962 963 964 965 966 967 968 969 970 |
# File 'lib/cdio.rb', line 959 def preemphasis() rc = Rubycdio::get_track_preemphasis(@device, @track) if rc == Rubycdio::TRACK_FLAG_FALSE return 'none' elsif rc == Rubycdio::TRACK_FLAG_TRUE return 'preemphasis' elsif rc == Rubycdio::TRACK_FLAG_UNKNOWN return 'unknown' else raise TrackError('Invalid return value %d' % d) end end |
#sec_count ⇒ Object
Returns: Fixnum
Get the number of sectors between this track an the next. This includes any pregap sectors before the start of the next track. Track numbers usually start at something greater than 0, usually 1.
A TrackError exception is raised on error.
980 981 982 983 984 985 986 |
# File 'lib/cdio.rb', line 980 def sec_count() sec_count = Rubycdio::get_track_sec_count(@device, @track) if sec_count == 0 raise TrackError end return sec_count end |