Giter Club home page Giter Club logo

rubycue's Introduction

RubyCue: A library to parse cuesheet song files

RubyCue is a Ruby interface for parsing and accessing cuesheet data.

Usage:

Basic usage

require 'rubycue'

cuesheet = RubyCue::Cuesheet.new(File.read("cuesheet.cue"))
cuesheet.parse!

cuesheet.songs.each do |song|
  puts "#{song[:performer]} - #{song[:title]} at #{song[:index]}"
end

Calculated Song Durations

RubyCue will also calculate song durations. In order to calculate the last song’s duration, you must pass the optional track duration (in seconds) for the entire file.

cuesheet = RubyCue::Cuesheet.new(File.read("cuesheet.cue"), 7143)

Current Song Position

After a cuesheet is instantiated, you can pass a current track position, and the cuesheet will return which song is currently playing at that position:

 # with seconds
 cuesheet.position(4352)
  => {:index=>#<RubyCue::Index:0x101025240 @seconds=7, @minutes=71, @frames=31>, :track=>32, :performer=>"Netsky", :title=>"Iron Heart", :duration=>#<RubyCue::Index:0x10100f2d8 @seconds=55, @minutes=2, @frames=38>} 

# with an array [minutes, seconds, frames]
cuesheet.position([43, 23, 45])
 => {:index=>#<RubyCue::Index:0x101027590 @seconds=27, @minutes=39, @frames=57>, :track=>19, :performer=>"Legion feat. Adam Wright", :title=>"Both Sides", :duration=>#<RubyCue::Index:0x101013130 @seconds=45, @minutes=4, @frames=13>}

Index objects

Index objects are a time representation of the position in a track. They are represented with fields [minutes, seconds, frames]. There are 75 frames in each second. You can access the values of the index object like so:

index = Index.new([30, 23, 73])
index.minutes => 30
index.seconds => 23
index.frames => 73
index.to_i => 1823
index.to_f => 1823.97333333333

There’s other stuff you can do with them, check out the source for more in-depth usage.

rubycue's People

Contributors

attilagyorffy avatar blakesmith avatar kvn47 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.