Rubyripper

From Hydrogenaudio Knowledgebase
Rubyripper
{{{logo}}}

Developer(s) Bouke Woudstra
Release information
Initial release {{{released}}}
Stable release 0.2
Preview release 0.1.1
Compatibility
Operating system Linux
Additional information
Use Digital Audio Extraction
License GPL
Website Rubyforge Website

Introduction

What is Rubyripper? Rubyripper is a digital audio extraction algorithm that uses cdparanoia or cdda2wav in a sophisticated way to make sure that a CD rip is done succesfully and accurately. It is very similiar to and inspired by EAC. Rubyripper is written in the ruby programming language.

It's currently available for Linux (partial BSD support). OS X will most likely be supported in the near future. The source (same as executable) is published under the GPL license.

  • UPDATE: New version 0.2 was released on 4 August 2006.
  • UPDATE: New version 0.1.1 was released on 12 February 2006.
  • UPDATE: New version 0.1.0 was released on 5 November 2005.

Features

  • A GTK2 user interface
  • Sophisticated error correction mechanism
  • A command line interface (CLI) available
  • CDDB-info is fetched via the ruby-freedb module
  • Info can be edited after fetching
  • The codecs supported are FLAC, Vorbis, MP3, and Wav
  • Multiple codecs can be used in one run
  • Direct offset support
  • Detailed logfile creation
  • A detailed overview of hard-to-correct positions
  • Create m3u playlists

Correction mechanism

Rubyripper correction mechanism goes beyond that of cdparanoia. Every track gets ripped at least twice and is byte compared with the Ruby cmp feature. If any differences are found, each of the 1,000 bytes of the two files is compared. The next trial run looks to see if differing positions or a match can be found. (1,000 bytes is about 0.006 seconds). The main underlying Philosophy is that an erronous read of an underlying ripper will produce random results. This seems so far to be correct. A possibility still exists that with randomn results the same result will be wrong.

If the full 1,000 bytes are erronous, than a false repair seems to be highly unlikely since there are possibilities in theory. (As a byte consists of 8 bits, 28=256). This would need an infinite amount of trials to match. The main principle however is, the more trials that are needed, consequently the higher a chance of a false repair. Suppose only 3 bytes in a sample of 1,000 bytes give random information. This would still mean possibilities within each of these bytes, really 2 bits could be a problem. This reduces the possibilities to possibilies. So, a false repair still seems to be possible. One has to wonder though: can 3 bytes actually be heard in a wav file that produces 180.000 bytes per second?

In conclusion: Rubyripper won't guarantee a consequent MD5-sum on tracks that needed correction. However it will repair any files so that it's impossible to succesfully blind-test with the original. The log file will report any position that needed more than 3 trials, so you can check the position yourself.

Installation

Make sure to have ruby-freedb, ruby-libglade2 and cdparanoia or cdda2wav installed as a minimum. You can optionally choose for Lame, Vorbis or FLAC, depending on the codec you wish to use.

Then download Rubyripper: http://rubyforge.org/frs/?group_id=1284&release_id=6293

Documentation of some of the ripping logic used can be found at: (somewhat dated)
http://rubyforge.org/docman/view.php/1284/310/Rubyripper's%20ripping%20logic.pdf

Currently there isn't an official installer available. Usage from a terminal or console:

cd <download_dir> (Go to the directory where you saved the downloaded archive)
tar xfj <filename_download> (Unpack the archive)
cd rubyripper-<version> (Move into the just unpacked directory)
chmod +x *.rb (Make all .rb files executable)
./rubyripper_gtk.rb (Launch gtk2 user interface)
./rubyripper_cli.rb (Launch command line user interface)

If Rubyripper doesn't start make sure the dependencies are ok. When launched from a terminal rubyripper should now tell which dependency it's missing.

Screenshots

The theme used in the screenshots is GTK-Qt-theme.

Suggestions for next version

  • Try to rip only parts that contain errors to save time
  • Erronous parts should be matched more than once
  • OS X support. The only developer needs some help, he does not have a Mac. A Mac user could help to get the cli-version working. A ruby programmer could help to make the GUI for OS X. The lead developer would be glad to add support for this task.
  • Let the user choose which freedb hit he/she will use

Known Bugs

  • If the first trial of a track has a different size than the second track, it assumes that the size of the first track is right. We don't know that for sure.


Development API

This section will give some technical information, which should be useful for interested developers. It will outline how the code is structured and what the API of Rubyripper codebase is for adding new user interfaces. Since version 0.2 it is quite simple to add new frontends to the current codebase. Currently there are CLI and GTK2 frontends. A Qt frontend or a Cocoa Mac OS frontend, should not be terribly difficult to implement. He won't implement this himself though, due to the fact that he is more interested in fine tuning the Rubyripper logic codebase.

Becoming a Rubyripper developer

To become a developer you should have:

  • Some basic knowledge of the Ruby programming language. Read for instance the free online book, at least until the chapter "Until Trouble Strikes". This is a somewhat dated version, but still perfectly usable. He doesn't use any new features, therefore it should be fine.
  • Some basic knowledge of a GUI-toolkit in case you want to add a new frontend.

If you're ready, please contact him at rubyripperdev@nospam@gmail.com. You can leave out the @nospam part.

Data files and class structures

The 0.2 release has three ruby files and one glade file included:

  • rr_lib.rb. This contains the Rubyripper codebase. It consists of five classes:
    • Gui_Support. This class handles all feedback communication with the user interface and is used a lot by the other classes (except Cddb). This is were log file is generated and the error analysis takes place.
    • Cddb. This class handles the freedb fetching. It uses the Freedb class (dependent on ruby-freedb) to get info about the disc. The server contact is handled in the Cddb class itself. Some problems of the Freedb class made it impossible to rely on it. The biggest problem with using Freedb class is that, it's using an old contact protocol and never gives away any information on the current year. This is the main reason why the Cddb class handles all server contact.
    • Secure_rip. As might be expected, all error correction logic is put in here.
    • Encode. As might be expected, this handles the encoding of the different formats supported.
    • Rubyripper. Handles the usage of the different classes. It also performs some logical checks before starting at all.
  • rubyripper_cli.rb. It has one class that contains the code for the command line interface frontend.
  • rubyripper_gtk.rb.M It has one class that contains the code for the GTK2 user interface frontend.
  • rubyripper.glade. This is a help file for the GTK interface. It's made with Glade, a program for designing user interfaces for GTK2.

Adding a new frontend

New frontends are encouraged and shouldn't be difficult to make. Take for instance, the current GTK2 frontend, which consists of only 350 lines of code (+ the glade file, but this code is automatically created)'. Being the only lead developer, the hope is you will be consistent with the current GTK2 interface design. If there are valid reasons to make any adjustments, please consult with him first. From a starting point it would be best to use the current GTK2 code and just plainly rewrite it for the other toolkit. The basic ideas should be more or less the same.

What requirements would code for a new GUI have to work correctly with the Rubyripper codebase?

  1. Load the Rubyripper codebase -> 'require ./rr_lib.rb'
  2. Make a class of the GUI code, we will later pass this to the Rubyripper codebase.
  3. Get info from the user which cdrom should be used (load it from $HOME/rubyripper_settings if it exists)
  4. Start a new instance of Cddb class -> @instance = Cddb.new(cdrom <string>, self <class>, multiple_freedb_hits? <bool>, verbose? <bool>)
  5. Test if @instance.disc_ok <bool> is true. If so, you can use @instance.track_numbers <int> and @instance.tracks_length <string> to update the amount and playlength of the tracks into the GUI. Also start @instance.make_internet_contact()
  6. Test if @instance.internet_ok <bool> is true. If so, update the info of @instance.artist <string>, @instance.album <string>, @instance.year <string>, @instance.genre <string> and tracklist <array_of_strings> in the GUI.
  7. As soon as the user wants to start the ripping process, start a new instance of the Rubyripper class. This is done by passing the settings Hash as an argument. (In other languages sometimes called a dictionary)
  8. The hash should contain all settings:
    • @settings['instance'] = the Gui instance -> self
    • @settings['cd_info'] = the Cddb instance -> @instance
    • @settings['verbose'] = bool
    • @settings['debug'] = bool
    • @settings['flac'] = bool
    • @settings['vorbis'] = bool
    • @settings['mp3'] = bool
    • @settings['wav'] = bool
    • @settings['flacsettings'] = string
    • @settings['vorbissettings'] = string
    • @settings['mp3settings'] = string
    • @settings['playlist'] = bool (m3u playlist wanted?)
    • @settings['use_threading'] = bool (ripping and encoding don't wait for each other)
    • @settings['ripper'] = string (cdda2wav or cdparanoia)
    • @settings['rippersettings'] = string or false
    • @settings['max_tries'] = int
    • @settings['cdrom'] = string (same as the one passed to Cddb instance)
    • @settings['offset'] = int
    • @settings['temp_dir'] = string
    • @settings['destination_dir'] = string
    • @settings['save_log'] = bool
    • @settings['tracklist'] = array of integers (which tracks should be ripped)
  9. All communication back to the GUI happens via the update function, that should be in the GUI, accepting two parameters: modus <string> and value <can be anything, dependent on the modus>. Notice that this is a great ruby feature! The different modus are:
    • ripping_progress. value is a float. Used to update the progress bar.
    • encoding_progress. value is a float. Used to update the progress bar.
    • log_change. value is a string. Used to update the status screen.
    • track_finished. value is an integer. Used to deselect the track in the GUI.
    • finished. value is not important. This means that the ripping and encoding are finished. Used to unlock the GUI-buttons.
    • error. value is a string. Used to bring up a popup window with the error message.
    • cddb_hit. value is an array of strings with the multiple hits. Return the index of the array.
  10. Using a new thread for launching instances is an effective way of getting a responsive GUI.

Mac OS/X support

Since the lead developer doesn't have a Mac, he cannot test anything. Therefore support from someone who knows Mac OS/X core audio very well and can test any code if needed is a necessity. The main differences with Mac OS/X and Linux support are:

  • Audio cd's may have to be unmounted before they can be ripped.
  • Linux doesn't mount audio cd's at all.
  • In cdparanoia an option to set the cdrom device is missing, which is there in Linux.

Development progress

This section was added in order to figure out the right way to implement features into Rubyripper. Currently work is being done on:

  • The tracklist presentation. Someone on the forums suggested, the interface isn't perfect. It was improved by opening the main window with a fixed size. The tracklist becomes scrollable, if it is to large too fit. Screenshots:
  • A separate status window was added, instead of a tab. This can be seen in the previous screenshots.
  • He also removed the status bars and the status tab from the main view. They were moved to a separate ripping window, like EAC. The task that is being decided upon is, which buttons should remain visible. If you have any ideas how to improve the GUI shown in the next screenshot, feel free to share your opinion!

External links