Writing audio to disk #456
-
I'm trying to save the audio from the playback of a sequenced track. I'm keeping everything in groups to make sure the order of execution is correct:
This is what I see when dumping the tree immediately after triggering sample playback:
I have the This is what the
When I start playing back a sequenced track, I'm calling this method:
The _create_buffer method:
When playback stops, I'm calling this method:
However, I'm not getting any audio recorded. I'm stumped. All the buses look correct to me, as does the order of groups. Any suggestions? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 9 replies
-
Ingredients generally look good. Might need to put the buffer freeing into the completion of closing the buffer. |
Beta Was this translation helpful? Give feedback.
-
👏
…On Fri, Feb 28, 2025, 7:19 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
#457 <#457>
—
Reply to this email directly, view it on GitHub
<#456 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNEUE2NHK4XUSKC5WLJT2SCSB5AVCNFSM6AAAAABYCGBOJGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMZVGQ4TSMY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
@dayunbao Just released the fix on PyPI: https://pypi.org/project/supriya/25.2b2/ |
Beta Was this translation helpful? Give feedback.
-
I'll try to start with those in the future.
…On Fri, Feb 28, 2025, 8:13 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
You're welcome. And thanks again for the MRE. I can move very fast when I
have good examples to work against.
—
Reply to this email directly, view it on GitHub
<#456 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNEQKEDEDLPSRKNRRCQ32SCYNZAVCNFSM6AAAAABYCGBOJGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMZVGU3TAOA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
-
Seems that I've found another issue. When I create the buffer, the value for
When
|
Beta Was this translation helpful? Give feedback.
-
Ah, yup. That was the problem. Thanks so much!
Good advice. I'll start doing that from now on.
…On Sat, Mar 1, 2025, 4:52 PM Joséphine Wolf Oberholtzer < ***@***.***> wrote:
Make sure you pass frame_count=0 in recording_buffer.write(...).
Otherwise it defaults to frame_count=-1 which will write all of the
(zeroed) samples in the buffer to disk before it gets to writing what your
synths have written into it.
It can be really helpful to validate what commands your system is sending
by wrapping blocks of code in with server.osc_protocol.capture() as
transcript: and then dumping out what OSC commands you actually sent, and
compare them against what's in the official Server Command Reference
<https://doc.sccode.org/Reference/Server-Command-Reference.html>.
def main() -> None:
server = Server().boot()
server.add_synthdefs(audio_to_disk, saw)
server.sync()
file_path = create_buffer_file_path()
with server.osc_protocol.capture() as transcript:
recording_buffer = create_buffer(server=server)
start_writing_buffer(
recording_buffer=recording_buffer, file_path=file_path, server=server
)
audio_to_disk_synth = start_writing_audio_to_disk(
server=server, recording_buffer=recording_buffer
)
saw_synth = start_playing_synth(server=server)
time.sleep(5)
audio_to_disk_synth.free()
saw_synth.set(gate=0)
saw_synth.free()
recording_buffer.close(on_completion=lambda _: recording_buffer.free())
server.sync()
for x in transcript.filtered(sent=True, received=False, status=False):
print(repr(x))
sys.exit(0)
Before I explicitly added the frame_count=0 I saw:
➜ python discussion456.py
OscMessage('/b_alloc', 0, 65536, 2)
OscMessage('/sync', 2)
OscMessage('/b_write', 0, '/Users/josephine/Source/github.com/supriya-project/supriya/recordings/recording.wav', 'wav', 'int24', -1, 0, 1)
OscMessage('/s_new', 'audio_to_disk', 1000, 1, 1)
OscMessage('/s_new', 'saw', 1001, 0, 1)
OscMessage('/n_free', 1000)
OscMessage('/n_set', 1001, 'gate', 0.0)
OscMessage('/n_set', 1001, 'gate', 0.0)
OscMessage('/b_close', 0, OscMessage('/b_free', 0))
OscMessage('/sync', 3)
And after I added that keyword argument I got:
➜ python discussion456.py
OscMessage('/b_alloc', 0, 65536, 2)
OscMessage('/sync', 2)
OscMessage('/b_write', 0, '/Users/josephine/Source/github.com/supriya-project/supriya/recordings/recording.wav', 'wav', 'int24', 0, 0, 1)
OscMessage('/s_new', 'audio_to_disk', 1000, 1, 1)
OscMessage('/s_new', 'saw', 1001, 0, 1)
OscMessage('/n_free', 1000)
OscMessage('/n_set', 1001, 'gate', 0.0)
OscMessage('/n_set', 1001, 'gate', 0.0)
OscMessage('/b_close', 0, OscMessage('/b_free', 0))
OscMessage('/sync', 3)
Note the /b_write commands last few arguments go from -1, 0, 1 to 0, 0, 1.
We want that -1 which represents "number of frames to write" to be 0
instead so we don't write out the full empty buffer before continuing to
write the rest of the incoming audio. I'd link the SCR section, but they
don't have anchors on the page so just search for /b_write there.
—
Reply to this email directly, view it on GitHub
<#456 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACVNNEQ7L7DJFV3PE7C5AW32SHJVBAVCNFSM6AAAAABYCGBOJGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEMZWGA4TSNA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
Beta Was this translation helpful? Give feedback.
Make sure you pass
frame_count=0
inrecording_buffer.write(...)
. Otherwise it defaults toframe_count=-1
which will write all of the (zeroed) samples in the buffer to disk before it gets to writing what your synths have written into it.It can be really helpful to validate what commands your system is sending by wrapping blocks of code in
with server.osc_protocol.capture() as transcript:
and then dumping out what OSC commands you actually sent, and compare them against what's in the official Server Command Reference.