Grand Piano for Sonic Pi: improved performance

If you have looked at my articles on adding a sample based Grand Piano voice to Sonic Pi, then adding the following three lines to the programs immediately after the sam array is defined will improve performance. The lines use a loop to preload all the samples before the pieces start to play, and so they become immediately available when required to play a note.

sam.each do |s|
load_sample s[1]

basically the loop iterates around the entries in the sam array, and takes the SECOND entry (offset 1) which is the name of the sample and uses the load_sample command to preload it into memory.

You can add this to all the programs in the article.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s