Buffer

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph cluster_builtins { graph [label=builtins]; node [color=1]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_supriya.realtime" { graph [label="supriya.realtime"]; node [color=2]; "supriya.realtime.Buffer.Buffer" [URL="../api/supriya/realtime/Buffer.html#supriya.realtime.Buffer.Buffer", color=black, fontcolor=white, label=Buffer, target=_top]; "supriya.realtime.ServerObjectProxy.ServerObjectProxy" [URL="../api/supriya/realtime/ServerObjectProxy.html#supriya.realtime.ServerObjectProxy.ServerObjectProxy", label="Server\nObject\nProxy", shape=oval, style=bold, target=_top]; "supriya.realtime.ServerObjectProxy.ServerObjectProxy" -> "supriya.realtime.Buffer.Buffer"; } subgraph "cluster_supriya.system" { graph [label="supriya.system"]; node [color=3]; "supriya.system.SupriyaObject.SupriyaObject" [URL="../api/supriya/realtime/../system/SupriyaObject.html#supriya.system.SupriyaObject.SupriyaObject", label="Supriya\nObject", target=_top]; } "builtins.object" -> "supriya.system.SupriyaObject.SupriyaObject"; "supriya.system.SupriyaObject.SupriyaObject" -> "supriya.realtime.ServerObjectProxy.ServerObjectProxy"; }

class supriya.realtime.Buffer.Buffer(buffer_group_or_index=None)[source]

A buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_
<- Buffer: ???>
>>> buffer_ = buffer_.allocate(frame_count=8192)
>>> server.sync()
<Server: udp://127.0.0.1:57751, 8i8o>
>>> buffer_
<+ Buffer: 0>
>>> buffer_ = buffer_.free()
>>> buffer_
<- Buffer: ???>

Attributes Summary

__float__ Gets float representation of buffer.
__int__ Gets integer representation of buffer.
__repr__ Gets interpreter representation of buffer.
allocate Allocates buffer on server.
allocate_from_file Allocates buffer on server with contents read from file_path.
buffer_group Gets buffer group.
buffer_id Gets buffer id.
channel_count Gets channel count.
close Closes buffer, if it was open during a read or write process by the DiskIn or DiskOut UGens.
copy_from Copies data from another buffer into this buffer.
copy_to Copies data in this buffer into another buffer.
duration_in_seconds Gets duration in seconds.
fill Fills contiguous blocks of samples with values.
fill_via_chebyshev Fills buffer with Chebyshev polynomial.
fill_via_sine_1 Fills buffer with sum of sinusoids via /b_gen sine1.
fill_via_sine_2 Fills buffer with sum of sinusoids via /b_gen sine2.
fill_via_sine_3 Fills buffer with sum of sinusoids via /b_gen sine3.
frame_count Gets frame count.
free Frees buffer.
get Gets sample values at indices.
get_contiguous Gets contiguous sample values.
get_frame Gets frames at frame_ids.
is_allocated Is true if buffer is allocated.
normalize
play
query Queries buffer.
read Reads contents of file_path into buffer.
sample_count Gets sample count.
sample_rate Gets sample-rate.
server Gets associated server.
set Sets samples.
set_contiguous Sets contiguous blocks of samples.
write Writes buffer to disk.
zero Zero all samples in buffer.

Special methods

__float__()[source]

Gets float representation of buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(frame_count=8)
>>> buffer_two = supriya.realtime.Buffer().allocate(frame_count=8)
>>> buffer_one
<+ Buffer: 0>
>>> float(buffer_one)
0.0
>>> buffer_two
<+ Buffer: 1>
>>> float(buffer_two)
1.0
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_three = supriya.realtime.Buffer()
>>> float(buffer_three)
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns float.

__int__()[source]

Gets integer representation of buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(frame_count=8)
>>> buffer_two = supriya.realtime.Buffer().allocate(frame_count=8)
>>> buffer_one
<+ Buffer: 0>
>>> int(buffer_one)
0
>>> buffer_two
<+ Buffer: 1>
>>> int(buffer_two)
1
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_three = supriya.realtime.Buffer()
>>> int(buffer_three)
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns integer.

__repr__()[source]

Gets interpreter representation of buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> repr(buffer_)
'<- Buffer: ???>'
>>> buffer_ = buffer_.allocate(frame_count=8)
>>> repr(buffer_)
'<+ Buffer: 0>'
>>> buffer_ = buffer_.free()
>>> repr(buffer_)
'<- Buffer: ???>'

Returns string.


Methods

allocate(channel_count=1, frame_count=1, server=None, sync=True)[source]

Allocates buffer on server.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate()
>>> buffer_one.query()
BufferInfoResponse(
    items=(
        Item(buffer_id=0, frame_count=1, channel_count=1, sample_rate=44100.0),
        ),
    )
>>> buffer_two = supriya.realtime.Buffer().allocate(
...     frame_count=16,
...     )
>>> buffer_two.query()
BufferInfoResponse(
    items=(
        Item(buffer_id=1, frame_count=16, channel_count=1, sample_rate=44100.0),
        ),
    )
>>> buffer_three = supriya.realtime.Buffer().allocate(
...     channel_count=2,
...     frame_count=32,
...     )
>>> buffer_three.query()
BufferInfoResponse(
    items=(
        Item(buffer_id=2, frame_count=32, channel_count=2, sample_rate=44100.0),
        ),
    )
>>> buffer_three.allocate()
Traceback (most recent call last):
...
supriya.exceptions.BufferAlreadyAllocated
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_three = buffer_three.free()

Returns buffer.

allocate_from_file(file_path, channel_indices=None, callback=None, frame_count=None, server=None, starting_frame=None, sync=True)[source]

Allocates buffer on server with contents read from file_path.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate_from_file(
...     supriya.system.Assets['audio/pulse_44100sr_16bit_octo.wav'],
...     )
>>> buffer_one.query()
BufferInfoResponse(
    items=(
        Item(buffer_id=0, frame_count=8, channel_count=8, sample_rate=44100.0),
        ),
    )
>>> buffer_two = supriya.realtime.Buffer().allocate_from_file(
...     supriya.system.Assets['audio/pulse_44100sr_16bit_octo.wav'],
...     channel_indices=(3, 4),
...     frame_count=4,
...     starting_frame=1,
...     sync=True,
...     )
>>> buffer_two.query()
BufferInfoResponse(
    items=(
        Item(buffer_id=1, frame_count=4, channel_count=2, sample_rate=44100.0),
        ),
    )
>>> for frame_id in range(buffer_two.frame_count):
...     buffer_two.get_frame(frame_id).as_dict()
...
OrderedDict([(0, (0.0, 0.0))])
OrderedDict([(2, (0.0, 0.0))])
OrderedDict([(4, (0.999969482421875, 0.0))])
OrderedDict([(6, (0.0, 0.999969482421875))])
>>> buffer_two.allocate()
Traceback (most recent call last):
...
supriya.exceptions.BufferAlreadyAllocated
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()

Returns buffer.

close(sync=True)[source]

Closes buffer, if it was open during a read or write process by the DiskIn or DiskOut UGens.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     channel_count=8,
...     frame_count=8,
...     )
>>> buffer_.read(
...     supriya.system.Assets['audio/pulse_44100sr_16bit_octo.wav'],
...     leave_open=True,
...     )
>>> buffer_.close()
>>> buffer_ = buffer_.free()
>>> buffer_.close()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

copy_from(frame_count=None, source_buffer_id=None, source_starting_frame=None, target_starting_frame=None, sync=True)[source]

Copies data from another buffer into this buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(frame_count=4)
>>> buffer_two = supriya.realtime.Buffer().allocate(frame_count=4)
>>> buffer_one.fill([(0, 4, 0.5)])
>>> buffer_two.copy_from(
...     frame_count=2,
...     source_buffer_id=buffer_one,
...     target_starting_frame=1,
...     )
>>> buffer_two.get_contiguous([(0, 4)]).as_dict()
OrderedDict([(0, (0.0, 0.5, 0.5, 0.0))])
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_one.copy_from(source_buffer_id=666)
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

copy_to(frame_count=None, source_starting_frame=None, target_buffer_id=None, target_starting_frame=None, sync=True)[source]

Copies data in this buffer into another buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(frame_count=4)
>>> buffer_two = supriya.realtime.Buffer().allocate(frame_count=4)
>>> buffer_one.fill([(0, 4, 0.5)])
>>> buffer_one.copy_to(target_buffer_id=buffer_two)
>>> buffer_two.get_contiguous([(0, 4)]).as_dict()
OrderedDict([(0, (0.5, 0.5, 0.5, 0.5))])
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_one.copy_to(target_buffer_id=666)
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

fill(index_count_value_triples=None)[source]

Fills contiguous blocks of samples with values.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     server=server,
...     sync=True,
...     )
>>> buffer_.fill([(0, 2, 0.5), (3, 3, 1.)])
>>> buffer_.get_contiguous([(0, 8)]).as_dict()
OrderedDict([(0, (0.5, 0.5, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0))])
>>> buffer_ = buffer_.free()
>>> buffer_.fill()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_chebyshev(amplitudes, as_wavetable=True, should_normalize=True, should_clear_first=True, sync=True)[source]

Fills buffer with Chebyshev polynomial.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     server=server,
...     )
>>> buffer_.fill_via_chebyshev(
...     amplitudes=(1, 0.5, 0.25),
...     as_wavetable=False,
...     )
>>> for x in buffer_.get_contiguous([(0, 8)]).as_dict()[0]:
...     x
...
-0.2133333384990692
-0.03999999910593033
4.7369516864363795e-17
-0.013333333656191826
0.0
0.12000000476837158
0.4266666769981384
1.0
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_chebyshev(amplitudes=(1, 0.5, 0.25))
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_sine_1(amplitudes=None, as_wavetable=True, should_clear_first=True, should_normalize=True, sync=True)[source]

Fills buffer with sum of sinusoids via /b_gen sine1.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     server=server,
...     )
>>> buffer_.fill_via_sine_1(
...     amplitudes=(1, 1, 1),
...     as_wavetable=False,
...     )
>>> for x in buffer_.get_contiguous([(0, 8)]).as_dict()[0]:
...     x
...
0.0
1.0
0.0
0.17157284915447235
1.014530602374735e-16
-0.17157284915447235
0.0
-1.0
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_sine_1(amplitudes=(1, 1, 1))
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_sine_2(amplitudes, frequencies, as_wavetable=True, should_clear_first=True, should_normalize=True, sync=True)[source]

Fills buffer with sum of sinusoids via /b_gen sine2.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     server=server,
...     )
>>> buffer_.fill_via_sine_2(
...     amplitudes=(1, 0.5, 0.25),
...     as_wavetable=False,
...     frequencies=(1, 2, 4),
...     )
>>> for x in buffer_.get_contiguous([(0, 8)]).as_dict()[0]:
...     x
...
0.0
0.46657732129096985
0.8170253038406372
0.9893794655799866
1.0
0.9250487685203552
0.8511532545089722
0.8245751261711121
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_sine_2(
...     amplitudes=(1, 0.5, 0.25),
...     frequencies=(1, 2, 4),
...     )
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_sine_3(amplitudes, frequencies, phases, as_wavetable=True, should_clear_first=True, should_normalize=True, sync=True)[source]

Fills buffer with sum of sinusoids via /b_gen sine3.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     server=server,
...     )
>>> buffer_.fill_via_sine_3(
...     amplitudes=(1, 0.5, 0.25),
...     as_wavetable=False,
...     frequencies=(1, 2, 3),
...     phases=(0, 0.5, 0),
...     )
>>> for x in buffer_.get_contiguous([(0, 8)]).as_dict()[0]:
...     x
...
0.21980325877666473
0.6533028483390808
0.9323374032974243
1.0
0.8886302709579468
0.6973193287849426
0.5352014899253845
0.46329957246780396
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_sine_3(
...     amplitudes=(1, 0.5, 0.25),
...     frequencies=(1, 2, 3),
...     phases=(0, 0.5, 0),
...     )
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

free() → supriya.realtime.Buffer.Buffer[source]

Frees buffer.

get(indices=None)[source]

Gets sample values at indices.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=4,
...     server=server,
...     sync=True,
...     )
>>> response = buffer_.get(indices=(1, 2))
>>> response.as_dict()
OrderedDict([(1, 0.0), (2, 0.0)])
>>> buffer_ = buffer_.free()
>>> buffer_.get()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns buffer-set response.

get_contiguous(index_count_pairs=None)[source]

Gets contiguous sample values.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=4,
...     server=server,
...     sync=True,
...     )
>>> response = buffer_.get_contiguous(
...     index_count_pairs=((0, 2), (1, 3))
...     )
>>> response.as_dict()
OrderedDict([(0, (0.0, 0.0)), (1, (0.0, 0.0, 0.0))])
>>> buffer_ = buffer_.free()
>>> buffer_.get_contiguous()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns buffer-set-contiguous response.

get_frame(frame_ids=None, completion_callback=None)[source]

Gets frames at frame_ids.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate_from_file(
...     supriya.system.Assets['audio/pulse_44100sr_16bit_octo.wav'],
...     )
>>> for frame_id in range(buffer_.frame_count):
...     buffer_.get_frame(frame_id).as_dict()
...
OrderedDict([(0, (0.999969482421875, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))])
OrderedDict([(8, (0.0, 0.999969482421875, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))])
OrderedDict([(16, (0.0, 0.0, 0.999969482421875, 0.0, 0.0, 0.0, 0.0, 0.0))])
OrderedDict([(24, (0.0, 0.0, 0.0, 0.999969482421875, 0.0, 0.0, 0.0, 0.0))])
OrderedDict([(32, (0.0, 0.0, 0.0, 0.0, 0.999969482421875, 0.0, 0.0, 0.0))])
OrderedDict([(40, (0.0, 0.0, 0.0, 0.0, 0.0, 0.999969482421875, 0.0, 0.0))])
OrderedDict([(48, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.999969482421875, 0.0))])
OrderedDict([(56, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.999969482421875))])
>>> buffer_ = buffer_.free()
>>> buffer_.get_frame()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns buffer-set-contiguous response.

normalize(as_wavetable=None, new_maximum=1.0, sync=False)[source]
play(add_action=None, bus=0, level=1, loop=False, rate=1, target_node=None)[source]
query()[source]

Queries buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     channel_count=2,
...     frame_count=16,
...     )
>>> buffer_.query()
BufferInfoResponse(
    items=(
        Item(buffer_id=0, frame_count=16, channel_count=2, sample_rate=44100.0),
        ),
    )
>>> buffer_ = buffer_.free()
>>> buffer_.query()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns buffer-info response.

read(file_path, channel_indices=None, callback=None, frame_count=None, leave_open=None, starting_frame_in_buffer=None, starting_frame_in_file=None, sync=True)[source]

Reads contents of file_path into buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     channel_count=2,
...     frame_count=8,
...     )
>>> for frame_id in range(buffer_.frame_count):
...     buffer_.get_frame(frame_id).as_dict()
...
OrderedDict([(0, (0.0, 0.0))])
OrderedDict([(2, (0.0, 0.0))])
OrderedDict([(4, (0.0, 0.0))])
OrderedDict([(6, (0.0, 0.0))])
OrderedDict([(8, (0.0, 0.0))])
OrderedDict([(10, (0.0, 0.0))])
OrderedDict([(12, (0.0, 0.0))])
OrderedDict([(14, (0.0, 0.0))])
>>> file_path = supriya.system.Assets['audio/pulse_44100sr_16bit_octo.wav']
>>> buffer_.read(file_path, channel_indices=(0, 1))
>>> for frame_id in range(buffer_.frame_count):
...     buffer_.get_frame(frame_id).as_dict()
...
OrderedDict([(0, (0.999969482421875, 0.0))])
OrderedDict([(2, (0.0, 0.999969482421875))])
OrderedDict([(4, (0.0, 0.0))])
OrderedDict([(6, (0.0, 0.0))])
OrderedDict([(8, (0.0, 0.0))])
OrderedDict([(10, (0.0, 0.0))])
OrderedDict([(12, (0.0, 0.0))])
OrderedDict([(14, (0.0, 0.0))])
>>> buffer_ = buffer_.free()
>>> buffer_.read(file_path)
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

set(index_value_pairs=None, sync=False)[source]

Sets samples.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     )
>>> buffer_.set([
...     (0, 0.25),
...     (1, 0.5),
...     (4, 0.75),
...     (5, 1.0),
...     ])
>>> buffer_.get_contiguous([(0, 8)]).as_dict()[0]
(0.25, 0.5, 0.0, 0.0, 0.75, 1.0, 0.0, 0.0)
>>> buffer_ = buffer_.free()
>>> buffer_.set()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

set_contiguous(index_values_pairs=None, sync=False)[source]

Sets contiguous blocks of samples.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     )
>>> buffer_.set_contiguous([
...     (1, [1, 2, 3]),
...     (4, [-3, 2, -1]),
...     ])
>>> buffer_.get_contiguous([(0, 8)]).as_dict()[0]
(0.0, 1.0, 2.0, 3.0, -3.0, 2.0, -1.0, 0.0)
>>> buffer_ = buffer_.free()
>>> buffer_.set_contiguous()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

write(file_path, callback=None, frame_count=None, header_format='aiff', leave_open=False, sample_format='int24', starting_frame=None, sync=True)[source]

Writes buffer to disk.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate_from_file(
...     supriya.system.Assets['audio/pulse_44100sr_16bit_octo.wav'],
...     channel_indices=(0,),
...     )
>>> buffer_one.get_contiguous([(0, 8)]).as_dict()[0]
(0.999969482421875, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
>>> import os
>>> file_path = os.path.expanduser('~')
>>> file_path = os.path.join(file_path, 'temp.wav')
>>> if os.path.exists(file_path):
...     os.remove(file_path)
>>> buffer_one.write(
...     file_path,
...     header_format='wav',
...     )
>>> buffer_two = supriya.realtime.Buffer().allocate_from_file(file_path)
>>> buffer_two.get_contiguous([(0, 8)]).as_dict()[0]
(0.999969482421875, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
>>> os.remove(file_path)
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_one.write(file_path=file_path)
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.

zero(callback=None, sync=True)[source]

Zero all samples in buffer.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     sync=True,
...     )
>>> buffer_.set_contiguous(
...     index_values_pairs=[(0, (1, 2, 3, 4, 5, 6, 7, 8))],
...     sync=True,
...     )
>>> buffer_.get_contiguous([(0, 8)]).as_dict()
OrderedDict([(0, (1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0))])
>>> buffer_.zero()
>>> buffer_.get_contiguous([(0, 8)]).as_dict()
OrderedDict([(0, (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0))])
>>> buffer_ = buffer_.free()
>>> buffer_.zero()
Traceback (most recent call last):
...
supriya.exceptions.BufferNotAllocated

Returns none.


Read-only properties

buffer_group

Gets buffer group.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(frame_count=8)
>>> buffer_one.buffer_group is None
True
>>> buffer_group = supriya.realtime.BufferGroup(buffer_count=1)
>>> buffer_group.allocate(frame_count=8)
<+ BufferGroup{1}: 1>
>>> buffer_two = buffer_group[0]
>>> buffer_two.buffer_group is buffer_group
True
>>> buffer_one = buffer_one.free()
>>> buffer_one.buffer_group is None
True
>>> buffer_group = buffer_group.free()
>>> buffer_two.buffer_group is buffer_group
True

Returns BufferGroup or none.

buffer_id

Gets buffer id.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer()
>>> buffer_one.buffer_id is None
True
>>> buffer_group = supriya.realtime.BufferGroup(buffer_count=4)
>>> for buffer_ in buffer_group:
...     print(buffer_.buffer_id)
...
None
None
None
None
>>> buffer_one = buffer_one.allocate(frame_count=8)
>>> buffer_one.buffer_id
0
>>> buffer_group.allocate(frame_count=8)
<+ BufferGroup{4}: 1>
>>> for buffer_ in  buffer_group:
...     buffer_.buffer_id
...
1
2
3
4
>>> buffer_one = buffer_one.free()
>>> buffer_one.buffer_id is None
True
>>> buffer_group = buffer_group.free()
>>> for buffer_ in buffer_group:
...     print(buffer_.buffer_id)
...
None
None
None
None

Returns integer or none.

channel_count

Gets channel count.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(
...     frame_count=8,
...     )
>>> buffer_two = supriya.realtime.Buffer().allocate(
...     channel_count=4,
...     frame_count=8,
...     )
>>> buffer_one.channel_count
1
>>> buffer_two.channel_count
4
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()

Returns integer.

duration_in_seconds

Gets duration in seconds.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_.duration_in_seconds
0.0
>>> buffer_ = buffer_.allocate(frame_count=44100)
>>> buffer_.duration_in_seconds
1.0
>>> buffer_ = buffer_.free()
>>> buffer_.duration_in_seconds
0.0

Returns float.

frame_count

Gets frame count.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_.frame_count
0
>>> buffer_ = buffer_.allocate(frame_count=512)
>>> buffer_.frame_count
512
>>> buffer_ = buffer_.free()
>>> buffer_.frame_count
0

Returns integer.

is_allocated

Is true if buffer is allocated. Otherwise false.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_.is_allocated
False
>>> buffer_ = buffer_.allocate(frame_count=8)
>>> buffer_.is_allocated
True
>>> buffer_ = buffer_.free()
>>> buffer_.is_allocated
False

Returns boolean

sample_count

Gets sample count.

>>> server = supriya.realtime.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(frame_count=16)
>>> buffer_two = supriya.realtime.Buffer().allocate(
...     channel_count=2,
...     frame_count=16,
...     )
>>> buffer_three = supriya.realtime.Buffer().allocate(
...     channel_count=8,
...     frame_count=16,
...     )
>>> buffer_one.sample_count
16
>>> buffer_two.sample_count
32
>>> buffer_three.sample_count
128
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_three = buffer_three.free()
>>> buffer_one.sample_count
0
>>> buffer_two.sample_count
0
>>> buffer_three.sample_count
0

Returns integer.

sample_rate

Gets sample-rate.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_.sample_rate
0
>>> buffer_ = buffer_.allocate(frame_count=8)
>>> buffer_.sample_rate
44100.0
>>> buffer_ = buffer_.free()
>>> buffer_.sample_rate
0

Returns float.

server

Gets associated server.

>>> server = supriya.realtime.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_.server is None
True
>>> buffer_ = buffer_.allocate(frame_count=8)
>>> buffer_.server is server
True
>>> buffer_ = buffer_.free()
>>> buffer_.server is None
True

Returns server or none.