"silent Record mode" with sonic-pi (capture, don't play... yet) and soundcards (aggregate?)

Greetings groovy geeks and geniuses :slight_smile:

  1. I’ve been looking at sound_in and recording buffers, and wondered if it’s possible to record using sonicpi, but not hear the input whilst being recorded.

I tried reducing amp but that seems to reduce the recording amplitude also.
I’m thinking a workaround may be possible with specific outputs, to playback to a preview device like headphones, but currently trying with “single output” setup.

Is it possible, to record a one-shot with sound_in, and not have the recording be played until called (eg with sample buffer :buffername)?

  • I tried to add another output device, to test sound_out

Bluetooth speakers (44.1KHz) - default speakers are 48
image

image

I made a test loop, to see if anything pings anywhere

loop do #ping-tick soundcards
  with_fx :sound_out, output: [1,3,5].tick do
    play :c
    sleep 0.5
  end
end

is this “multisoundcard” out possible?
Or is this a job for ASIO?

curently output only comes to headphones only when set as default audio in windows, and restarting SP.

Appreciate any insights!
(Windows 11 Pro)

You could put a :level effect around the recorder and set its amp to 0

1 Like

It works!

:record :sound_in Wrapped up in a record method rec with defaults for duration and name of record_buffer

# Recording audio
define :rec do |dur = 4, buf = :rec_buf|
  with_fx :record, buffer: buf do
    synth :sound_in, sustain: dur
    sleep dur
  end
end

This method is called with record quiet mode recq
(cause I don’t how to curry or build the block and avoid repetition of code when putting things in things … yet)

define :recq do |dur = 4, buf = :rec_buf|
  with_fx :level, amp: 0 do
    rec dur, buf
  end
end

When it came to playback I had issues, which I haven’t solved yet. I’m trying to set the buffer length, like in the examples, but it’s not working, maybe due to the assignment operation (although primitive testing outside the method yielded the expected duration)

I get no sound on playback if I try and set the buffer length, perhaps due to my code, so as a workaround I added an explicit sustain to the sample, and the quiet-rec-loop-playback works as expected :+1:t2:


Here’s the code in entirety for copying critique, suggestions…
The duration issue mentioned occurs on Line#15 when trying to use buffer(name,duration) as per the examples

define :rec do |dur = 4, buf = :rec_buf|
  with_fx :record, buffer: buf do
    synth :sound_in, sustain: dur, amp: 1
    sleep dur
  end
end

define :recq do |dur = 4, buf = :rec_buf|
  with_fx :level, amp: 0 do
    rec dur, buf
  end
end

define :play_buffer do |buf = :rec_buf, dur = 4, repeat = 1|
  sam = buffer buf  #can't use buffer(buf,dur)
  repeat.times do
    sample sam, sustain: dur
    sleep dur
  end
end

recq 4, :my_buffer 

with_fx :reverb do  
  play_buffer :my_buffer, 4, 3 
end