buffers

class Buffer(buffer_group_or_index=None)

Bases: supriya.realtime.bases.ServerObject

A buffer.

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

Gets float representation of buffer.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_two = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_one
<+ Buffer: 0, 1ch, 8>
>>> float(buffer_one)
0.0
>>> buffer_two
<+ Buffer: 1, 1ch, 8>
>>> 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 115, in __float__
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns float.

__int__()

Gets integer representation of buffer.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_two = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_one
<+ Buffer: 0, 1ch, 8>
>>> int(buffer_one)
0
>>> buffer_two
<+ Buffer: 1, 1ch, 8>
>>> 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 164, in __int__
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns integer.

__plot__()
__render__(**kwargs) supriya.io.PlayMemo
allocate(server, channel_count=1, frame_count=1, *, sync=True)

Allocates buffer on server.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server)
>>> 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(
...     server,
...     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(
...     server,
...     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(server)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 344, in allocate
    raise supriya.exceptions.BufferAlreadyAllocated
supriya.exceptions.BufferAlreadyAllocated
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()
>>> buffer_three = buffer_three.free()

Returns buffer.

allocate_from_file(server, file_path: os.PathLike, *, channel_indices=None, callback=None, frame_count=None, starting_frame=None, sync=True)

Allocates buffer on server with contents read from file_path.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate_from_file(
...     server,
...     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(
...     server,
...     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_frames(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(server)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 344, in allocate
    raise supriya.exceptions.BufferAlreadyAllocated
supriya.exceptions.BufferAlreadyAllocated
>>> buffer_one = buffer_one.free()
>>> buffer_two = buffer_two.free()

Returns buffer.

property buffer_group

Gets buffer group.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_one.buffer_group is None
True
>>> buffer_group = supriya.realtime.BufferGroup(buffer_count=1)
>>> buffer_group.allocate(server, 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.

property buffer_id

Gets buffer id.

>>> server = supriya.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(server, frame_count=8)
>>> buffer_one.buffer_id
0
>>> buffer_group.allocate(server, 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.

property channel_count

Gets channel count.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_two = supriya.realtime.Buffer().allocate(
...     server, 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.

close(*, sync=True)

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

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     server, 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 479, in close
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

copy(target_buffer_id, *, frame_count=None, source_starting_frame=None, target_starting_frame=None, sync=True)

Copies data in this buffer into another buffer.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server, frame_count=4)
>>> buffer_two = supriya.realtime.Buffer().allocate(server, frame_count=4)
>>> buffer_one.fill((0, 4, 0.5))
>>> buffer_one.copy(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(target_buffer_id=666)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 522, in copy
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

property duration_in_seconds

Gets duration in seconds.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer()
>>> buffer_.duration_in_seconds
0.0
>>> buffer_ = buffer_.allocate(server, frame_count=44100)
>>> buffer_.duration_in_seconds == buffer_.frame_count / buffer_.sample_rate
True
>>> buffer_ = buffer_.free()
>>> buffer_.duration_in_seconds
0.0

Returns float.

fill(*index_count_value_triples, sync=True)

Fills contiguous blocks of samples with values.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     server,
...     frame_count=8,
...     sync=True,
... )
>>> buffer_.fill((0, 2, 0.5), (3, 3, 1.0))
>>> 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 564, in fill
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_chebyshev(amplitudes, *, as_wavetable=False, should_normalize=True, should_clear_first=True, sync=True)

Fills buffer with Chebyshev polynomial.

>>> server = supriya.Server().boot()
>>> buffer_ = server.add_buffer(1, 512)
>>> buffer_.fill_via_chebyshev(
...     [1, 0.5, 0.25],
...     as_wavetable=False,
... )
>>> supriya.plot(buffer_)  
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_chebyshev([1, 0.5, 0.25])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 625, in fill_via_chebyshev
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_sine_1(amplitudes, *, as_wavetable=False, should_clear_first=True, should_normalize=True, sync=True)

Fills buffer with sum of sinusoids via /b_gen sine1.

>>> server = supriya.Server().boot()
>>> buffer_ = server.add_buffer(1, 512)
>>> buffer_.fill_via_sine_1(
...     [1, 1, 1],
...     as_wavetable=False,
... )
>>> supriya.plot(buffer_)  
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_sine_1([1, 1, 1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 673, in fill_via_sine_1
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_sine_2(amplitudes, frequencies, *, as_wavetable=False, should_clear_first=True, should_normalize=True, sync=True)

Fills buffer with sum of sinusoids via /b_gen sine2.

>>> server = supriya.Server().boot()
>>> buffer_ = server.add_buffer(1, 512)
>>> buffer_.fill_via_sine_2(
...     frequencies=[1, 2, 4],
...     amplitudes=[1, 0.5, 0.25],
...     as_wavetable=False,
... )
>>> supriya.plot(buffer_)  
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_sine_2(
...     frequencies=[1, 2, 4],
...     amplitudes=[1, 0.5, 0.25],
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 726, in fill_via_sine_2
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

fill_via_sine_3(amplitudes, frequencies, phases, *, as_wavetable=False, should_clear_first=True, should_normalize=True, sync=True)

Fills buffer with sum of sinusoids via /b_gen sine3.

>>> server = supriya.Server().boot()
>>> buffer_ = server.add_buffer(1, 512)
>>> buffer_.fill_via_sine_3(
...     frequencies=[1, 2, 3],
...     amplitudes=[1, 0.5, 0.25],
...     phases=[0, 0.5, 0],
...     as_wavetable=False,
... )
>>> supriya.plot(buffer_)  
>>> buffer_ = buffer_.free()
>>> buffer_.fill_via_sine_3(
...     frequencies=[1, 2, 3],
...     amplitudes=[1, 0.5, 0.25],
...     phases=[0, 0.5, 0],
... )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 783, in fill_via_sine_3
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

property frame_count

Gets frame count.

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

Returns integer.

free() supriya.realtime.buffers.Buffer

Frees buffer.

get(*indices)

Gets sample values at indices.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     server,
...     frame_count=4,
...     sync=True,
... )
>>> response = buffer_.get(1, 2)
>>> response.as_dict()
OrderedDict([(1, 0.0), (2, 0.0)])
>>> buffer_ = buffer_.free()
>>> buffer_.get()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 827, in get
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns buffer-set response.

get_contiguous(*index_count_pairs)

Gets contiguous sample values.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     server,
...     frame_count=4,
...     sync=True,
... )
>>> response = buffer_.get_contiguous((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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 866, in get_contiguous
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns buffer-set-contiguous response.

get_frames(*frame_ids, completion_callback=None)

Gets frames at frame_ids.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate_from_file(
...     server,
...     supriya.system.Assets["audio/pulse_44100sr_16bit_octo.wav"],
... )
>>> for frame_id in range(buffer_.frame_count):
...     buffer_.get_frames(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_frames()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 912, in get_frames
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns buffer-set-contiguous response.

property is_allocated

Is true if buffer is allocated. Otherwise false.

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

Returns boolean

normalize(*, as_wavetable=None, new_maximum=1.0, sync=True)
query()

Queries buffer.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     server, 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 961, in query
    raise supriya.exceptions.BufferNotAllocated
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)

Reads contents of file_path into buffer.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(
...     server, channel_count=2, frame_count=8
... )
>>> for frame_id in range(buffer_.frame_count):
...     buffer_.get_frames(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_frames(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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 1035, in read
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

property sample_count

Gets sample count.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate(server, frame_count=16)
>>> buffer_two = supriya.realtime.Buffer().allocate(
...     server,
...     channel_count=2,
...     frame_count=16,
... )
>>> buffer_three = supriya.realtime.Buffer().allocate(
...     server,
...     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.

property sample_rate

Gets sample-rate.

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

Returns float.

property server

Gets associated server.

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

Returns server or none.

set(*index_value_pairs, sync=False)

Sets samples.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(server, 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 1091, in set
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

set_contiguous(*index_values_pairs, sync=False)

Sets contiguous blocks of samples.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(server, 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 1128, in set_contiguous
    raise supriya.exceptions.BufferNotAllocated
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)

Writes buffer to disk.

>>> server = supriya.Server().boot()
>>> buffer_one = supriya.realtime.Buffer().allocate_from_file(
...     server,
...     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(server, 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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 1199, in write
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

zero(*, callback=None, sync=True)

Zero all samples in buffer.

>>> server = supriya.Server().boot()
>>> buffer_ = supriya.realtime.Buffer().allocate(server, frame_count=8)
>>> buffer_.set_contiguous(
...     (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):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/josiah-wolf-oberholtzer/supriya/supriya/realtime/buffers.py", line 1258, in zero
    raise supriya.exceptions.BufferNotAllocated
supriya.exceptions.BufferNotAllocated

Returns none.

class BufferGroup(buffer_count=1)

Bases: supriya.realtime.bases.ServerObject

A buffer group.

>>> server = supriya.Server().boot()
>>> buffer_group = supriya.realtime.BufferGroup(buffer_count=4)
>>> buffer_group
<- BufferGroup{4}: ???>
>>> buffer_group.allocate(
...     server,
...     frame_count=8192,
...     sync=True,
... )
<+ BufferGroup{4}: 0>
>>> buffer_group.free()
<- BufferGroup{4}: ???>
__contains__(item)
__float__()
__getitem__(index)

Gets buffer at index.

Returns buffer.

__int__()
__iter__()
__len__()

Gets length of buffer group.

Returns integer.

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

Allocates buffer group.

Returns buffer group.

property buffer_id

Gets initial buffer id.

Returns integer or none.

property buffers

Gets associated buffers.

Returns tuple or buffers.

free() supriya.realtime.buffers.BufferGroup

Frees all buffers in buffer group.

static from_file_paths(server, file_paths, sync=True)

Create a buffer group from file_paths.

>>> file_paths = supriya.Assets["audio/*mono_1s*"]
>>> len(file_paths)
4
>>> server = supriya.Server().boot()
>>> buffer_group = supriya.realtime.BufferGroup.from_file_paths(server, file_paths)
>>> for buffer_ in buffer_group:
...     buffer_
... 
<+ Buffer: 0, 1ch, 44100>
<+ Buffer: 1, 1ch, 44100>
<+ Buffer: 2, 1ch, 44100>
<+ Buffer: 3, 1ch, 44100>

Returns buffer group.

index(item)
property is_allocated

Is true when buffer group is allocated. Otherwise false.

Returns boolean.

zero()

Analogous to SuperCollider’s Buffer.zero.

class BufferProxy(buffer_id=None, channel_count=0, frame_count=0, sample_rate=0, server=None)

Bases: supriya.system.SupriyaValueObject

A buffer proxy.

Acts as a singleton reference to a buffer on the server, tracking the state of a single buffer id and responding to /b_info messages. Multiple Buffer instances reference a single BufferProxy.

BufferProxy instances are created internally by the server, and should be treated as an implementation detail.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy
BufferProxy(
    buffer_id=0,
    channel_count=2,
    frame_count=441,
    sample_rate=44100,
    server=<Server: offline>,
)
__float__()

Gets float representation of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> float(buffer_proxy)
0.0

Returns float.

__int__()

Gets integer representation of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> int(buffer_proxy)
0

Returns integer.

property buffer_id

Gets buffer id of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.buffer_id
0

Returns integer.

property channel_count

Gets channel count of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.channel_count
2

Returns integer.

property duration_in_seconds

Gets duration in seconds of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.duration_in_seconds
0.01

Returns float.

property frame_count

Gets frame count of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.frame_count
441

Returns integer.

property sample_count

Gets sample count of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.sample_count
882

Returns integer.

property sample_rate

Gets sample-rate of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.sample_rate
44100

Returns integer.

property server

Gets server of buffer proxy.

>>> server = supriya.Server()
>>> buffer_proxy = supriya.realtime.BufferProxy(
...     buffer_id=0,
...     server=server,
...     channel_count=2,
...     frame_count=441,
...     sample_rate=44100,
... )
>>> buffer_proxy.server
<Server: offline>

Returns server.