Class: Seal::Buffer

Inherits:
Object
  • Object
show all
Defined in:
src/rubyext.c,
src/rubyext.c

Overview

Interfaces for manipulating buffers. Buffers are essentially abstract representations of (raw) audio data and are used by sources. Buffers are most suitable for small-sized sound effect which can be efficiently loaded to memory at once. Streams, on the other hand, are more suitable for massive audio such as background music.

In order to have 3D sound effect on the buffer, the audio file needs to have mono-channel. If the audio file has multi-channel, the sound will not be positioned in a 3D space. Multi-channel audio (a.k.a. stereo) is already designed to have illusion of directionality and audible perspective. Most sound effect should be monophonic.

Instance Method Summary collapse

Constructor Details

#Seal::Buffer.new(filename[, format]) ⇒ Object

Initializes a new buffer and loads it with audio from filename. format specifies the format of the audio file; automatic recognition of the audio format will be attempted if format is not specified. See Seal::Format for possible values. Sets all the attributes appropriately.

There is a limit on the number of allocated buffers. This method raises an error if it is exceeding the limit.



379
380
381
382
383
384
385
386
387
388
389
390
# File 'src/rubyext.c', line 379

static
VALUE
init_buf(int argc, VALUE* argv, VALUE rbuf)
{
    seal_buf_t* buf;

    buf = DATA_PTR(rbuf);
    check_seal_err(seal_init_buf(buf));
    input_audio(argc, argv, buf, seal_load2buf);

    return rbuf;
}

Instance Method Details

#bit_depthFixnum

Gets the bit depth (bits per sample) of the audio contained in buffer.

Returns:

  • (Fixnum)


443
444
445
446
447
448
# File 'src/rubyext.c', line 443

static
VALUE
get_buf_bps(VALUE rbuf)
{
    return get_obj_int(rbuf, seal_get_buf_bps);
}

#channel_countFixnum

Gets the number of channels of the audio contained in buffer.

Returns:

  • (Fixnum)


456
457
458
459
460
461
# File 'src/rubyext.c', line 456

static
VALUE
get_buf_nchannels(VALUE rbuf)
{
    return get_obj_int(rbuf, seal_get_buf_nchannels);
}

#frequencyFixnum

Gets the frequency (sample rate) of the audio contained in buffer.

Returns:

  • (Fixnum)


430
431
432
433
434
435
# File 'src/rubyext.c', line 430

static
VALUE
get_buf_freq(VALUE rbuf)
{
    return get_obj_int(rbuf, seal_get_buf_freq);
}

#load(filename[, format]) ⇒ Object

Loads audio from filename to buffer which must not be currently used by any source. Sets all the attributes appropriately. format specifies the format of the audio file; automatic recognition of the audio format will be attempted if format is not specified. See Seal::Format for possible values.Sets all the attributes appropriately.



402
403
404
405
406
407
408
409
# File 'src/rubyext.c', line 402

static
VALUE
load_buf(int argc, VALUE* argv, VALUE rbuf)
{
    input_audio(argc, argv, DATA_PTR(rbuf), seal_load2buf);

    return rbuf;
}

#sizeFixnum

Gets the size, in bytes, of buffer.

Returns:

  • (Fixnum)


417
418
419
420
421
422
# File 'src/rubyext.c', line 417

static
VALUE
get_buf_size(VALUE rbuf)
{
    return get_obj_int(rbuf, seal_get_buf_size);
}