Limited Number of Code Editor Lines?

Forgive a total newbie, but is there a limit to the number of lines of code you can write in the code editor? I am probably doing something wrong, writing out
Play
Sleep
Play
Sleep
etc for melody, plus I have several threads/loops for accompaniment and percussion.
I am up to 377 lines and can go no further, though I have more melody to add!

Hello @Songstress!
Correct, this situation is due to a limitation in the underlying technology that Sonic Pi uses to send data between the GUI and the server behind it.
There are a few ways to work around this - The following post may shed a little more light on it:

Feel free to comment or ask questions here or there if you’d like further clarification or assistance :slight_smile: :+1:

Take a look at the play_pattern_timed function, it lets you store an entire melody in just two arrays.

yep as @Davids-Music-Lab suggests, you probably need to use a function that you still don’t know.

So if you post your code, maybe we can help you to discover some ways to achieve your goal :slight_smile: and give you some tips !
Cheers

Thank you for your responses! If I can get a bit more help…

I am exploring play_pattern_timed, which may be the way to go. Now is there a way to specify expressions for indiviual notes in the list? Here’s a chunk:
use_synth :piano
play 61.9, amp: 0.75, attack: 0.01, attack_level: 0.5, sustain: 0.75, sustain_level: 0.75, decay: 0.5, decay_level: 0.5, slide: 0.5, slide_shape: 6
sleep 0.25
play 68.9, amp: 0.75, attack: 0.01, attack_level: 0.5, sustain: 0.75, sustain_level: 0.75, decay: 0.5, decay_level: 0.5, slide: 0.5, slide_shape: 6
sleep 0.25
play 68.9, amp: 1, attack: 0.01, attack_level: 0.75, sustain: 0.75, sustain_level: 0.75, decay: 0.5, decay_level: 0.5, slide: 0.5, slide_shape: 6
sleep 0.25
play 66.9, amp: 0.75, attack: 0.01, attack_level: 0.5, sustain: 0.75, sustain_level: 0.75, decay: 0.75, decay_level: 0.5, slide: 0.5, slide_shape: 6
sleep 1.25

Just four notes. First, second, and fourth have same expression, but I want the third to “hit” a little harder. How would indicate that in a list like:
play_pattern_timed [61.9, 68.9, 68.9, 66.9], [0.25, 0.25, 0.25, 1.25]
Thanks in advance!

I would do it with a live_loop:

use_synth_defaults attack: 0.01, sustain: 0.75
live_loop :melody do
  tick
  play (ring 61,68,68,66).look, sustain: (ring 0.25,0.25,0.25,0.25).look, amp: (ring 0.75,0.75,1,0.75)
  sleep (ring 0.25,0.25,0.25,1.25).look
end

Tick&look counts through the rings, so the first time the loop is executed, the first value is used, then the next value every time it loops.

Parameters that don’t change can be set using use_synth_defaults, all following play/synth commands use these parameters.

4 Likes

Using rings is working!!! Thank you so much!
I wanted to share what you helped me with:

It still needs A LOT of work and the melody isn’t finished, but I’m so excited now to keep working on it! :grin:

7 Likes

Sounds pretty good to me so far! Glad you found a working strategy. Would love to hear more as this progresses :slight_smile:

1 Like

great song! Love it!

1 Like

Thanks! Still working on it lol!

It’s done!

2 Likes