Possible Bug: Sonic Pi Must be Rebooted Upon Second "Run" of This Code

I’ve run into a bug, or perhaps I’m coding something in a way the program can’t handle.

When I open up Sonic Pi and run the following code it works fine:

# INITIALIZE MASTER VALUES
use_bpm 90

# LOAD IN SAMPLE LIBRARIES
mgsMenu = "/Users/sheamkennedy/Desktop/Sonic Pi Files/SPi - Samples/MGS 1/Menu/" #[0-87]

riserAmp           = 0


# AUTOMATION
line_Riser1 = (line 1, 0, inclusive: true, steps: 128)

# AMP MOD
live_loop :ampMod do
  riserAmp = 0
  sleep 8
  riserAmp = 1
  sleep 8
  riserAmp = 0
  sleep 16
end

# TICKER
live_loop :ticker do
  puts tick
  time_warp 16 do
    sample mgsMenu, 7, amp: riserAmp, attack: line_Riser1.tick, beat_stretch: (ring 0.2, 0.5).look if (spread 16, 16).look
  end
  sleep 0.125
end

Upon stopping and pressing run again nothing happens. The program does not appear to be running, nothing happens in the cue window. If I use “reboot” in the form of code nothing happens. If I close Sonic Pi and reopen the code can execute once more (but again, not a second time…)

No errors are displayed either.

Hi there,

sorry that you’re having issues. I hope we can get things fixed up for you as soon as possible.

Unfortunately I was unable to reproduce the bug as you describe it on your machine. From the looks of your file path, you’re using a Mac which I am too.

My initial thinking is that there’s perhaps not an error with the code, but with the sample your’e trying to play. Could you make the sample that you’re triggering available to download so I can test that too?

Also, if you just run:

mgs_menu = "/Users/sheamkennedy/Desktop/Sonic Pi Files/SPi - Samples/MGS 1/Menu/" #[0-87]
sample mgs_menu, 7, amp: 1, attack: 1, beat_stretch: 0.2

Does that also break things?

If I just run this:

mgs_menu = "/Users/sheamkennedy/Desktop/Sonic Pi Files/SPi - Samples/MGS 1/Menu/" #[0-87]
sample mgs_menu, 7, amp: 1, attack: 1, beat_stretch: 0.2

There seems to be no issue. I can run it again and again without having to exit Sonic Pi.

Here’s the sound sample being used:
https://drive.google.com/open?id=1YHMCXLHWQR_iGL9TRf38CJ1vo9gmO7sN

Thanks for this - I’ll look into it.

Meanwhile, would it be possible to try and reduce your example to the shortest bit of code that breaks things?

Also, could you try commenting out the call to sample to see if that inhibits it from breaking?

Actually yeah I was just doing that and I think I’m getting to the root of things:

I found it seems to fail as soon as I use “time_warp”, when I comment it out the code functions perfectly (but with no time delay)…

This code works:

# INITIALIZE MASTER VALUES
use_bpm 90

# LOAD IN SAMPLE LIBRARIES
mgsMenu = "/Users/sheamkennedy/Desktop/Sonic Pi Files/SPi - Samples/MGS 1/Menu/" #[0-87]

# TICKER
live_loop :ticker do
  puts tick

    sample mgsMenu, 7, amp: 1, attack: 1, beat_stretch: 0.2

  
  sleep 0.125
end

This code doesn’t work:

# INITIALIZE MASTER VALUES
use_bpm 90

# LOAD IN SAMPLE LIBRARIES
mgsMenu = "/Users/sheamkennedy/Desktop/Sonic Pi Files/SPi - Samples/MGS 1/Menu/" #[0-87]

# TICKER
live_loop :ticker do
  puts tick
  time_warp 16 do
    sample mgsMenu, 7, amp: 1, attack: 1, beat_stretch: 0.2
  end
  
  sleep 0.125
end

Could it be that I’m trying to use a value that’s too big to be handled? If so what’s the maximum time_warp?

And if I comment out the call to sample it works (No sound plays obviously but I can see that the log keeps running and I can stop and start again without issues). That code looks like this:

# INITIALIZE MASTER VALUES
use_bpm 90

# LOAD IN SAMPLE LIBRARIES
mgsMenu = "/Users/sheamkennedy/Desktop/Sonic Pi Files/SPi - Samples/MGS 1/Menu/" #[0-87]

# TICKER
live_loop :ticker do
  puts tick
  time_warp 16 do
    
  end
  
  sleep 0.125
end