Class: Audio::MPEG::Decoder
- Inherits:
-
Object
- Object
- Audio::MPEG::Decoder
- Defined in:
- lib/icanhasaudio/version.rb,
lib/icanhasaudio/mpeg/decoder.rb,
ext/icanhasaudio/audio_mpeg_decoder.c,
ext/icanhasaudio/audio_mpeg_decoder_mp3data.c
Defined Under Namespace
Classes: MP3Data
Constant Summary collapse
- VERSION =
'0.1.3'
Instance Attribute Summary collapse
-
#bits ⇒ Object
Number of bits, 8 or 16.
-
#mp3data ⇒ Object
readonly
Returns the value of attribute mp3data.
Class Method Summary collapse
-
.Audio::MPEG::Decoder.lame_version ⇒ Object
Returns the version of lame you are using.
Instance Method Summary collapse
- #decode(input, output) ⇒ Object
-
#in_samplerate ⇒ Object
Get the input samplerate.
-
#initialize {|_self| ... } ⇒ Decoder
constructor
A new instance of Decoder.
-
#num_samples=(number) ⇒ Object
Set the number of samples.
Constructor Details
Instance Attribute Details
#bits ⇒ Object
Number of bits, 8 or 16
5 6 7 |
# File 'lib/icanhasaudio/mpeg/decoder.rb', line 5 def bits @bits end |
#mp3data ⇒ Object (readonly)
Returns the value of attribute mp3data.
6 7 8 |
# File 'lib/icanhasaudio/mpeg/decoder.rb', line 6 def mp3data @mp3data end |
Class Method Details
.Audio::MPEG::Decoder.lame_version ⇒ Object
Returns the version of lame you are using.
42 43 44 45 |
# File 'ext/icanhasaudio/audio_mpeg_decoder.c', line 42 static VALUE method_lame_version(VALUE klass) { const char * version = get_lame_version(); return rb_str_new(version, strlen(version)); } |
Instance Method Details
#decode(input, output) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/icanhasaudio/mpeg/decoder.rb', line 15 def decode input, output buf = skip_id3_header(input) decode_headers_for(buf) while !mp3data.header_parsed? decode_headers_for(input.read(100)) end mp3data.nsamp = MP3Data::MAX_U_32_NUM unless mp3data.total_frames > 0 wav = WAV::File.new(output) wav.write_header(0x7FFFFFFF, 0, num_channels, in_samplerate) if !@raw native_decode(input, wav) if !@raw && attempt_rewind(wav) wav.write_header(@wavsize + 44, 0, num_channels, in_samplerate) end end |
#in_samplerate ⇒ Object
Get the input samplerate
195 196 197 198 199 200 |
# File 'ext/icanhasaudio/audio_mpeg_decoder.c', line 195
static VALUE get_in_samplerate(VALUE self)
{
lame_global_flags * gfp;
Data_Get_Struct(self, lame_global_flags, gfp);
return INT2NUM(lame_get_in_samplerate(gfp));
}
|
#num_samples=(number) ⇒ Object
Set the number of samples
181 182 183 184 185 186 187 |
# File 'ext/icanhasaudio/audio_mpeg_decoder.c', line 181
static VALUE set_num_samples(VALUE self, VALUE sample_count)
{
lame_global_flags * gfp;
Data_Get_Struct(self, lame_global_flags, gfp);
lame_set_num_samples(gfp, NUM2INT(sample_count));
return sample_count;
}
|