class RemiAudio::Cue

Overview

A virtual representation of a CUE sheet.

Example that lists the files/tracks of a CUE sheet, then saves the CUE sheet to a new file.

require "remiaudio/cue"

cue = RemiAudio::Cue.load("/path/to/file.cue")
cue.files.each do |file|
  puts "File: #{file.filename}"
  file.tracks.each do |track|
    if title = track.title
      puts "  #{title}"
    else
      puts "  Unnamed track, number #{track.trackNumber}"
    end
  end
end

# Write the CUE to a new file
File.open("/path/to/newcue.cue", "w") do |file|
  cue.write(file)
end

Documentation for the CUE sheet format can be found at these sources:

Defined in:

remiaudio/cue.cr

Constant Summary

CATALOG_LEN = 13

The expected length of the CATALOG field, in bytes.

MAX_PERFORMER_LEN = 80

The maximum length of the PERFORMER field, in bytes.

MAX_SONGWRITER_LEN = 80

The maximum length of the SONGWRITER field, in bytes.

MAX_TITLE_LEN = 80

The maximum length of the TITLE field, in bytes.

MIN_PERFORMER_LEN = 1

The minimum length of the PERFORMER field, in bytes.

MIN_SONGWRITER_LEN = 1

The minimum length of the SONGWRITER field, in bytes.

MIN_TITLE_LEN = 1

The minimum length of the TITLE field, in bytes.

Constructors

Instance Method Summary

Constructor Detail

def self.load(filename : Path | String, *, strict : Bool = false) : Cue #

Creates a new Cue instance by loading and parsing the specified file.

See .parse(io : IO, *, strict : Bool = false) for information about the strict parameter.


[View source]
def self.new #

Creates a new, blank Cue instance.


[View source]
def self.parse(io : IO, *, strict : Bool = false) : Cue #

Creates a new Cue instance by parsing data from io. If strict is true, then certain restrictions are in place for the following cases:

  • Unrecognized commands in the FILE section will not be accepted.
  • Unrecognized commands in the TRACK section will not be accepted.
  • Unrecognized FLAGS on a FLAG line within a TRACK will not be accepted.

When strict is false, then these cases are silently ignored.


[View source]
def self.parse(string : String, *, strict : Bool = false) : Cue #

Creates a new Cue instance by parsing data from the given string.

See .parse(io : IO, *, strict : Bool = false) for information about the strict parameter.


[View source]

Instance Method Detail

def addFile(&) : File #

Creates a new RemiAudio::Cue::File and yields it to the block. When the block exits, the new file is added to this Cue. The new file is returned.


[View source]
def catalog : String | Nil #

The "Media Catalog Number" for this CUE sheet. This is generally a UPC or EAN code.


[View source]
def catalog=(value : String) : Nil #

Sets the "Media Catalog Number" for this CUE sheet. This is generally a UPC or EAN code. This must be exactly CATALOG_LEN bytes in length.


[View source]
def cdTextFile : String | Nil #

The path to an external file that contains CD-TEXT information for this CUE sheet.


[View source]
def cdTextFile=(cdTextFile : String | Nil) #

The path to an external file that contains CD-TEXT information for this CUE sheet.


[View source]

The RemiAudio::Cue::Files for this CUE sheet.


[View source]
def files=(files : Array(RemiAudio::Cue::File)) #

The RemiAudio::Cue::Files for this CUE sheet.


[View source]
def performer : String | Nil #

The performer of this CUE sheet.


[View source]
def performer=(value : String | Nil) : Nil #

Sets the name of the performer for this track. The value must be between MIN_PERFORMER_LEN and MAX_PERFORMER_LEN bytes long.


[View source]
def songwriter : String | Nil #

The songwriter of this CUE sheet.


[View source]
def songwriter=(value : String | Nil) : Nil #

Sets the name of the songwriter for this track. The value must be between MIN_SONGWRITER_LEN and MAX_SONGWRITER_LEN bytes long.


[View source]
def sortAndCheckTracks : Bool #

Sorts all RemiAudio::Cue::File#tracks in all #files, then attempts to sort #files according to their tracks, then ensures that that all of the tracks are in sequential order. If the tracks are not sequential after sorting, or there are duplicates, this returns false. Otherwise it returns true.


[View source]
def title : String | Nil #

The title of this CUE sheet.


[View source]
def title=(value : String | Nil) : Nil #

Sets the name of the title for this track. The value must be between MIN_TITLE_LEN and MAX_TITLE_LEN bytes long.


[View source]
def write(io : IO) : Nil #

Writes this CUE sheet to io. This will automatically call #sortAndCheckTracks before writing any data.


[View source]
def write : String #

Writes this CUE sheet to a string and returns it. This will automatically call #sortAndCheckTracks before writing any data.


[View source]