Class: Audio::MPEG::Decoder

Inherits:
Object
  • Object
show all
Defined in:
ext/icanhasaudio.c,
lib/icanhasaudio/mpeg.rb

Constant Summary collapse

VERSION =

VERSION = ‘0.0.2’

rb_str_new2("0.0.2")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Decoder

Returns a new instance of Decoder.

Yields:

  • (_self)

Yield Parameters:



7
8
9
10
# File 'lib/icanhasaudio/mpeg.rb', line 7

def initialize
  @bits = 16
  yield self if block_given?
end

Instance Attribute Details

#bitrateObject (readonly)

Returns the value of attribute bitrate.



2
3
4
# File 'lib/icanhasaudio/mpeg.rb', line 2

def bitrate
  @bitrate
end

#bitsObject

Number of bits, 8 or 16



5
6
7
# File 'lib/icanhasaudio/mpeg.rb', line 5

def bits
  @bits
end

#framesizeObject (readonly)

Returns the value of attribute framesize.



2
3
4
# File 'lib/icanhasaudio/mpeg.rb', line 2

def framesize
  @framesize
end

#modeObject (readonly)

Returns the value of attribute mode.



2
3
4
# File 'lib/icanhasaudio/mpeg.rb', line 2

def mode
  @mode
end

#mode_extObject (readonly)

Returns the value of attribute mode_ext.



2
3
4
# File 'lib/icanhasaudio/mpeg.rb', line 2

def mode_ext
  @mode_ext
end

#samplerateObject (readonly)

Returns the value of attribute samplerate.



2
3
4
# File 'lib/icanhasaudio/mpeg.rb', line 2

def samplerate
  @samplerate
end

#stereoObject (readonly)

Returns the value of attribute stereo.



2
3
4
# File 'lib/icanhasaudio/mpeg.rb', line 2

def stereo
  @stereo
end

Class Method Details

.Audio::MPEG::Decoder.lame_versionObject

Returns the version of lame you are using.



61
62
63
64
# File 'ext/icanhasaudio.c', line 61

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_io, output_io) ⇒ Object

Decode the input IO and write it to the output IO.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'ext/icanhasaudio.c', line 138

static VALUE method_lame_decode(VALUE self, VALUE file, VALUE outf) {
  mp3data_struct mp3data;
  lame_global_flags * gfp;

  memset(&mp3data, 0, sizeof(mp3data_struct));
  lame_decode_initfile(file, &mp3data);

  Data_Get_Struct (self, lame_global_flags, gfp);

  rb_iv_set(self, "@stereo", INT2NUM(mp3data.stereo));
  rb_iv_set(self, "@samplerate", INT2NUM(mp3data.samplerate));
  rb_iv_set(self, "@bitrate", INT2NUM(mp3data.bitrate));
  rb_iv_set(self, "@mode", INT2NUM(mp3data.mode));
  rb_iv_set(self, "@mode_ext", INT2NUM(mp3data.mode_ext));
  rb_iv_set(self, "@framesize", INT2NUM(mp3data.framesize));

  lame_decoder(self, file, outf, &mp3data);

  return Qnil;
}