Choosing a Random Synth in Sonic Pi

Towards the end of our coding class at school today, one of the children asked me how they would choose a random synth in their code.  I couldn’t give them the answer off of the top of my head so I came home and have placed two different solutions below:

# Choosing a Random Synth in Sonic Pi

# Solution 1
10.times do
  use_synth [:beep, :blade, :cnoise, :dpulse].choose
  play :C3
  sleep 1
end

# Solution 2
10.times do
 use_synth choose([:beep, :blade, :cnoise, :dpulse])
 play :C3
 sleep 1
end

 

Check or change the Timezone in Debian

To see or change what timezone your Debian system is configured for:

dpkg-reconfigure tzdata

More detailed information is available in the Debian Wiki

More specifically, I used this in a setup of HypriotOS, a minimal Debian-based operating systems that is optimised to run Docker on ARM devices. In this instance it was an old Raspberry Pi Model B running NodeRed in a Docker Container.

I needed to get the time in the Docker Container to match the time on the host.  Achieved, as below, where /etc/localtime on the host is mapped to /etc/localtime in the container when it is created.

docker run --restart=always -p 1880:1880 -d --name nodered -v /etc/localtime:/etc/localtime:ro -v node_red_user_data:/data nodered/node-red-docker:0.17.4-rpi

I have used NodeRed to subscribe to messages from an MQTT service I have running that publishes various messages from various nodes around our house.  The NodeRed code listens for some of these messages and uses the AWS Polly Service to convert them to speech and read them out to us.

There’s a sample of the speech, below, as well as screen shots of the NodeRed flows.