-
-
Notifications
You must be signed in to change notification settings - Fork 927
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
Thread sync/drift #2
Comments
Hi there, I haven't added any thread synchronisation to Sonic Pi. This is going to be a feature for a future version :-) |
Closed
Closed
hzulla
added a commit
to hzulla/sonic-pi
that referenced
this issue
May 2, 2016
samaaron
added a commit
that referenced
this issue
May 12, 2016
Moving towards weblate #2: Activate translation sync of Qt GUI through weblate
hzulla
added a commit
to hzulla/sonic-pi
that referenced
this issue
May 19, 2016
hzulla
added a commit
to hzulla/sonic-pi
that referenced
this issue
May 20, 2016
Closed
Closed
lostapathy
added a commit
to lostapathy/sonic-pi
that referenced
this issue
Nov 28, 2017
# This is the 1st commit message: remove USE_RVM All builds had USE_RVM set, so removing conditional that didn't use it as well as the env variable itself. # This is the commit message sonic-pi-net#2: Update to latest ruby versions Updating to latest ruby versions and simplifying travis syntax
Closed
This was referenced Sep 11, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, been doing some work with CA, I noticed that if I start 3 threads running at default BPM, after a few bars they get a bit out of sync. I wasn't sure whether you had built in thread synchronisation into your core code, or whether it was up to the user to do their own sync between threads. Either are ok of course, but I wasn't sure if you were expecting users to realise that they need thread synchronisation and then read about how to do it as part of the learning experience, or whether you had provision for it to happen automatically in your code so readers could just code multiple tracks out of the box.
Code below as an example, excuse my crap ruby code I'm not really a ruby programmer: I have a separate thread showing the bar and beat number so I can keep track of everything on the screen, the thread that starts playing after 3 bars on my Raspberry Pi is already out of sync. If I remove this bar counting, it does still get out of sync eventually so I think even if there was a startup latency in the threads, there still appears to be some drift over time.
C=60
D=62
E=64
F=65
G=67
A=69
B=71
octave=12
major = [0,2,4,5,7,9,11,12]
pentatonic = [1,3,6,8,10]
d=1.0
bar=0
beat=0
in_thread do
loop do
sleep d
beat=(beat+1)%4
if beat==0
bar = bar + 1
print "**** "
print bar
print "\n"
end
end
end
by the time this thread reaches it's target bar
time has drifted enough to be noticeable
in_thread do
note=C+12
loop do
if bar>3
play note
end
sleep d/2
end
end
in_thread do
with_synth "beep"
note=C
loop do
play note+pentatonic[rand(5)]
sleep d/2
end
end
in_thread do
note=C-octave*2
with_synth "beep"
loop do
play note
sleep d
play note
sleep d
play note
sleep d/2
play note
sleep d/2
play note
sleep d
end
end
in_thread do
with_synth "saw_beep"
loop do
note = C+pentatonic[rand(5)]
play note-(octave)
sleep d
end
end
The text was updated successfully, but these errors were encountered: