2 new revisions:
Revision: 8f6b156121c6
Author: Bouke Woudstra <
boukew...@gmail.com>
Date: Sun May 12 10:41:04 2013
Log: Explain the magic number of 588.
http://code.google.com/p/rubyripper/source/detail?r=8f6b156121c6
Revision: 5575f634bb27
Author: Bouke Woudstra <
boukew...@gmail.com>
Date: Sun May 12 10:47:32 2013
Log: Also explain the magic number "4".
http://code.google.com/p/rubyripper/source/detail?r=5575f634bb27
==============================================================================
Revision: 8f6b156121c6
Author: Bouke Woudstra <
boukew...@gmail.com>
Date: Sun May 12 10:41:04 2013
Log: Explain the magic number of 588.
http://code.google.com/p/rubyripper/source/detail?r=8f6b156121c6
Modified:
/lib/rubyripper/modules/audioCalculations.rb
/lib/rubyripper/secureRip.rb
=======================================
--- /lib/rubyripper/modules/audioCalculations.rb Wed Jan 9 14:11:49 2013
+++ /lib/rubyripper/modules/audioCalculations.rb Sun May 12 10:41:04 2013
@@ -17,8 +17,7 @@
# A shared module for all kinds of audio calculations and standard values
module AudioCalculations
-
- # Wave files have 75 audio frames for each second
+ # Wave files have 75 audio frames / sectors for each second
FRAMES_A_SECOND = 75
# That makes up 60x75 frames for each minute
@@ -35,6 +34,16 @@
# Amount of bytes a frame is 176400 / 75 = 2352
BYTES_AUDIO_FRAME = 2352
BYTES_AUDIO_SECOND = 2352 * FRAMES_A_SECOND
+
+ # Each frame exists of 588 audio samples of 4 bytes
+ # Samples are used to correct the drive reading offset
+ # Note that offsets in cdparanoia can't be as big as a frame
+ # The following commands return the same output, no matter the device
+ # cdparanoia [.1000]-[.1000] -O 0 001.wav
+ # cdparanoia [.1000]-[.1000] -O 588 002.wav
+ # cdparanoia [.1000]-[.1000] -O -588 003.wav
+ SAMPLES_A_FRAME = 588
+ BYTES_AUDIO_SAMPLE = 4
# minutes:seconds:sectors to sectors
def toSectors(time)
=======================================
--- /lib/rubyripper/secureRip.rb Thu Apr 11 13:55:39 2013
+++ /lib/rubyripper/secureRip.rb Sun May 12 10:41:04 2013
@@ -370,7 +370,8 @@
end
# What start/length do we expect?
- start = @disc.getStartSector(track) + @prefs.offset / 588
+ # Correct for whole frames if necessary (cdparanoia doesn't do this)
+ start = @disc.getStartSector(track) + @prefs.offset / SAMPLES_A_FRAME
length = @disc.getLengthSector(track) - 1
if start < 0 and @prefs.offset < 0
@@ -379,7 +380,7 @@
noOffset = true
elsif @prefs.offset > 0 && (@prefs.image || track == @disc.audiotracks)
# Adjust the start so that we never read into the lead-out.
- start -= @prefs.offset / 588
+ start -= @prefs.offset / SAMPLES_A_FRAME
noOffset = true
end
command += " [.#{start}]-[.#{length}]"
==============================================================================
Revision: 5575f634bb27
Author: Bouke Woudstra <
boukew...@gmail.com>
Date: Sun May 12 10:47:32 2013
Log: Also explain the magic number "4".
http://code.google.com/p/rubyripper/source/detail?r=5575f634bb27
Modified:
/lib/rubyripper/waveFile.rb
=======================================
--- /lib/rubyripper/waveFile.rb Wed Jan 9 14:11:49 2013
+++ /lib/rubyripper/waveFile.rb Sun May 12 10:47:32 2013
@@ -56,7 +56,7 @@
# Read a CD-audio sector (padding with 0's, regardless of
padMissingSamples)
def read(sector)
- start = BYTES_WAV_CONTAINER + sector * BYTES_AUDIO_FRAME + @offset * 4
+ start = BYTES_WAV_CONTAINER + sector * BYTES_AUDIO_FRAME + @offset *
BYTES_AUDIO_SAMPLE
if @newSectors.has_key?(sector)
@newSectors[sector]
@@ -125,7 +125,7 @@
else
audioSize = @file.stat.size - BYTES_WAV_CONTAINER
if @offset != 0
- audioSize -= @offset.abs * 4
+ audioSize -= @offset.abs * BYTES_AUDIO_SAMPLE
end
end
@@ -157,7 +157,7 @@
end
else
# Padding is at the beginning.
- bytesWritten = @offset * 4
+ bytesWritten = @offset * BYTES_AUDIO_SAMPLE
(1..numSectors).each do |sector|
if bytesWritten <= -BYTES_AUDIO_FRAME
# Don't bother writing out the sector at all