Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlling screen op in Sonic Pi #3

Open
rbnpi opened this issue Feb 9, 2015 · 8 comments
Open

Controlling screen op in Sonic Pi #3

rbnpi opened this issue Feb 9, 2015 · 8 comments

Comments

@rbnpi
Copy link
Contributor

rbnpi commented Feb 9, 2015

I'm not sure that the cli takes account of the settings for Print output and check synth args. These can both seriously inhibit SP performance (on a model B B+) . Would be good if there were an option to switch them off. Not so much of a problem on a Pi 2 :-)

@Widdershin
Copy link
Owner

sonic-pi-cli just passes on the commands to Sonic Pi, which acts as a server.

If the options aren't being respected, I would suspect this is a bug with Sonic Pi. I'm unsure as to what the "Print output" and "Check synth args" flags actually do. Perhaps @samaaron could shed some light on this?

@rbnpi
Copy link
Contributor Author

rbnpi commented Feb 10, 2015

I looked at this again on my iMac this morning. There IS a differnce between running the file from within Sonic Pi and via the cli. On teh pref interface you can switch off pritned output. When you run via cli it still produces some. Try it with the file below. Run on iMac with print output on and off and see the difference. Then (with print output switched off on Sonic Pi) try running it with
cat (filename) | sonic_pi
you should see the difference

#The Earl of Essex Galiard John Dowland transcribed for Sonic Pi 2 by Robin Newman July 2014

s = 1.0 / 26 #s is speed multiplier 1.0 / 8 makes crotchet 1s or 60 crotchets/minute the default bpm
#note use of 1.0 to make the variable floating point and not integer
dsq = 1 * s #demi-semi-quaver
sq = 2 * s #semi-quaver
sqd = 3 * s #semi-quaver dotted
q = 4 * s #quaver
qd = 6 * s #quaver dotted
qdd = 7 * s #quaver double dotted
c = 8 * s #crotchet
cd = 12 * s #crotchet dotted
cdd = 14 * s #crotchet double dotted
m = 16 * s #minim
md = 24 * s #minim dotted
mdd = 28 * s #minim double dotted
b = 32 * s #breve
bd = 48 * s #breve dotted

use_synth :tri

define :tune do|pitch,duration,shift=0,amp= 0.3|
pitch.zip(duration).each do |p,d|
if p == :r
sleep d
else
with_transpose shift_12 do
play p,sustain: 0.9_d,release: 0.1*d,attack: 0,amp: amp
sleep d
end
end

end
end

n1 = [:g4,:a4,:bb4,:g4,:g5,:f5,:eb5,:d5,:d5,:c5,:bb4,:a4,:f5,:d5,:eb5,:c5,:d5,:c5,:bb4,:a4,:bb4,:c5,:bb4,:a4,:g4,:a4,:g4]
d1 = [cd,q,c,c,m,md,c,m,m,m,m,m_3,m,c,m,c,md,c,c,q,q,c,c,c,c,m,m_3]
#use_bpm 180
n2 = [:g4,:g4,:a4,:bb4,:c5,:d5,:c5,:bb4,:bb4,:a4,:g4,:fs4,:a4,:bb4,:c5,:a4,:bb4,:a4,:g4,:g4,:fs4,:e4,:fs4,:g4]
d2 = [m,cd,q,c,c,md,c,m,m,m,m,m_3,m,c,m,c,md,c,m,md,q,q,m,m_3]
n3 = [:d5,:g5,:d5,:c5,:bb4,:f5,:f5,:f5,:d5,:d5,:d5,:d5,:g5,:f5,:f5,:d5,:eb5,:r,:d5,:d5,:c5,:b4,:a4,:b4]
d3 = [m,m,md,c,m,m,md,c,m,m_3,m,c,m,c,m,m,b,m,m,c,c,c,c,m]
n4 = [:bb4,:a4,:g4,:d5,:e5,:f5,:bb4,:bb4,:c5,:a4,:bb4,:g4,:a4,:a4,:g4,:g4,:a4,:f4,:f4,:g4,:g4,:d5,:d4,:d4]
d4 = [md,c,m,cd,q,m,md,c,c,c,c,c,m_3,m,c,m,c,md,c,m,m,m,m,m_3]
n5 = [:g3,:g3,:a3,:bb3,:bb2,:f3,:g3,:d3,:d3,:g3,:c3,:f3,:bb2,:eb3,:c3,:d3,:g2]
d5 = [m,md,c,m_3,m,m,m,m_3,m,c,m,c,b,m,m,b,m_3]

define :sec1 do |m|
v1 = m_0.8
v2 = m_0.8
v3 = m*0.8
v4 = m
v5 = m
in_thread do
tune(n1,d1,0,v1)
end
in_thread do
tune(n2,d2,0,v2)
end
in_thread do
tune(n3,d3,-1,v3)
end
in_thread do
tune(n4,d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read do
tune(nc2,dc2,0,v2)
end
in_thread do
tune(nc3,dc3,-1,v3)
end
in_thread do
tune(nc4,dc4,-1,v4)
end
tune(nc5,dc5,0,v5)
end

2.times do
sec1(0.4)
sec1(0.2)
sec2(0.4)
sec2(0.2)
sec3(0.3)
sec3(0.5)
end

@samaaron
Copy link

Hi there, @rbnpi is absolutely right - there is a difference between Sonic Pi's behaviour and sonic-pi-cli. Sonic Pi sneakily inserts lines at the top of the code to modify behaviour based on the user's preferences. The important thing to realise is that everything is driven by code - even the preferences!

You can see this happening here:
https://github.com/samaaron/sonic-pi/blob/master/app/gui/qt/mainwindow.cpp#L692

The magic #__nosave__.* comments ensure that these lines aren't saved or printed so the user never sees them.

@rbnpi
Copy link
Contributor Author

rbnpi commented Feb 10, 2015

Ah! So basically its down to the user with sonic_pi to explicitly put in a use_debug false command in the file being sent to sonic_pi cli. That way the printed output is clobbered.

@samaaron
Copy link

Yep, or @Widdershin could teach sonic-pi-cli to accept an optional hash with these prefs which would then turn into similar magic comments to be prepended to the script before sending to Sonic Pi.

@Widdershin Widdershin self-assigned this Feb 10, 2015
@Widdershin
Copy link
Owner

I will definitely support this with some flags.

@samaaron
Copy link

:-)

@Widdershin
Copy link
Owner

I never got around to this but if someone wants to pick this up I'll happily review and merge the pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants