| Class | Audio::Sound |
| In: |
lib/audio.rb
|
| Parent: | NArray |
A Sound is a NArray with some audio convenience methods. It should always have the shape [frames,channels]. (Even when m=1)
Notice for NArray users: because most audio libraries do not agree with NArray on type names, Sound.float has a different meaning than NArray.float. Also, the shape of a new Sound is different than you might expect:
s = Sound.float(10) n = NArray.float(10) s.shape #=> [10,1] n.shape #=> [10] s.typecode #=> 4 n.typecode #=> 5
| TYPES | = | [nil,:char,:short,:long,:float,:double] | Mapping from typecode to type symbols |
| char | -> | byte |
| short | -> | sint |
| long | -> | int |
| float | -> | sfloat |
Creates a new Sound with the specified number of channels from the interleaved data in narray. narray should be evenly divisible by channels.
Return a Sound with the channels interleaved.
Sound[[0,1],[2,3]].interleaved #=> Sound[[0,2,1,3]]
For a two-channel sound:
s.set_frame(i,[0.42,0.24]) s.set_frame(i,0.42) #=> s.set_frame(i,[0.42,0.42])
You may prefer to do this the NArray way: s[i,false] = val