play :c4
sleep 1
play :c4
sleep 1
play :g4
sleep 1
play :g4
sleep 1
play :a4
sleep 1
play :a4
sleep 1
play :g4
sleep 2
play :f4
sleep 1
play :f4
sleep 1
play :e4
sleep 1
play :e4
sleep 1
play :d4
sleep 1
play :d4
sleep 1
play :c4
sleep 2
play :g4
sleep 1
play :g4
sleep 1
play :f4
sleep 1
play :f4
sleep 1
play :e4
sleep 1
play :e4
sleep 1
play :d4
sleep 2
play :g4
sleep 1
play :g4
sleep 1
play :f4
sleep 1
play :f4
sleep 1
play :e4
sleep 1
play :e4
sleep 1
play :d4
sleep 2
play :c4
sleep 1
play :c4
sleep 1
play :g4
sleep 1
play :g4
sleep 1
play :a4
sleep 1
play :a4
sleep 1
play :g4
sleep 2
play :f4
sleep 1
play :f4
sleep 1
play :e4
sleep 1
play :e4
sleep 1
play :d4
sleep 1
play :d4
sleep 1
play :c4
sleep 2
cue :finish
osc_send “localhost”,4557, “/stop-recording”,“myGUID”
osc_send “localhost”,4557, “C:/Users/vinodv/Desktop/music/Keyboard/sonic/saved_songs/test.wav”
What could be the problem.
OS: Windows 10 Home 64 bit.
Portable version of Sonic Pi
Opened sonic pi as “Run as Administrator”
(Aside from that, just in case you’re not already aware, sending commands to the server directly through OSC is not officially supported.)
You may be basing your test on comments seen elsewhere in this forum? - there are several threads which talk about this - however, the internal design of Sonic Pi has changed since comments such as those seen in Recording Sonic Pi output into .wav files programatically - the most recent builds of Sonic Pi now dynamically determine the port at which the server receives commands.
It is possible, with a bit of work, to find out the port number that is being used. You can inspect the log file .sonic-pi\log\gui.log usually found starting in your home directory, and find a line that says:
Port entry server-listen-to-gui : XXXXX : XXXXX
where XXXXX is the port number that is used to send commands to the server.
(A reminder again that sending commands directly to the server like this is not officially supported, and it is highly likely that such a thing will change completely down the road). We do plan on eventually introducing a much easier way of doing things like this, when resources permit.
Should I change the string “myGUID” for recording.
the port no mentioned in gui.log was 51235. I changed to this port no.
Even then the recording is not happening.
Here are some bits I wrote to enable recording from software OSC commands in Sonic Pi.
I wpould reiterate Ethan’s comments that they use undocumented parts of Sonic Pi and are not guaranteed to work in future versions. Rely n them at your own risk.
Note the string “guid-rbn” can be any value you like, as long as you use the same value in all your OSC messages.
Once you know the current value of the port, you can use this manually for OSC calls from external devices or from a python script for example.
#This program lets you find the current server Listen port,
#where the Sonic Pi server listens to command from the GUI front end
#It also demonstrates how to setup a Stop All command
#and how to send code to run on Sonic Pi
#developed by Robin Newman, August 2019
#WARNING this uses undocumented features in Sonic Pi which MAY CHANGE
#and it is not guaranteed to work with future versions of Sonic Pi
define :pvalue do #get current listen port for Sonic Pi from log file
value= 4557 #pre new logfile format port was always 4557
File.open(ENV['HOME']+'/.sonic-pi/log/server-output.log','r') do |f1|
while l = f1.gets
if l.include?"Listen port:"
value = l.split(" ").last.to_i
break
end
end
f1.close
end
return value
end
puts "Server Listen port is: #{pvalue}"
set :pvalue,pvalue
#three functions with will start recording, stop recording and save recorded audio file
define :recordStart do #this command is equivalent to pushing the start recording button
use_real_time
pvalue=get(:pvalue)
osc_send "localhost",pvalue, "/start-recording","guid-rbn"
sleep 1# make sure recording running before creating any audio to save
puts "recording started"
end
define :recordStop do #this command stops a currently recording process
use_real_time
pvalue=get(:pvalue)
osc_send "localhost",pvalue, "/stop-recording","guid-rbn"
end
define :saveAudio do |file| #this command saves the recorded audio file
pvalue=get(:pvalue)
osc_send "localhost",pvalue, "/save-recording","guid-rbn",file
puts "recording stopped"
end
#combine stop and save functions
define :stopAndSaveRecording do |file|
recordStop
saveAudio(file)
puts "Recording saved to #{file}"
end
#test recording
recordStart
#play some audio
use_synth :tb303
24.times do
play scale(:c4,:minor_pentatonic,num_octaves: 2).choose,release: 0.2,cutoff: 70
sleep 0.2
end
sample :loop_amen
sleep sample_duration :loop_amen #wait till finished
#adjust path/name to suit your own location
stopAndSaveRecording("/Users/rbn/testfile.avi")