Module: PCM

Defined in:
lib/pcm/version.rb,
ext/pcm/pcm.c

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.mix(channels) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'ext/pcm/pcm.c', line 46

static VALUE
rb_mix(VALUE self, VALUE channels)
{
  long i, num_channels, num_samples;
  VALUE mix;

  num_channels = RARRAY_LEN(channels);
  if (num_channels <= 0)
    return Qnil;

  num_samples = max_array_len(channels);
  if (num_samples == 0)
    return rb_ary_new();

  mix = rb_ary_new2(num_samples);
  
  for (i = 0; i < num_samples; i++)
    rb_ary_store(mix, i, mix_samples(channels, i));

  return mix;
}