# Unit Plan for Teachers - Generative Music in Sonic Pi

**URL:** https://in-thread.sonic-pi.net/t/unit-plan-for-teachers-generative-music-in-sonic-pi/6452
**Category:** Educators
**Created:** [January 30, 2022, 2:28am UTC](https://in-thread.sonic-pi.net/t/unit-plan-for-teachers-generative-music-in-sonic-pi/6452 "2022-01-30T02:28:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mrbombmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/mrbombmusic/32/2282_2.png) [@mrbombmusic](https://in-thread.sonic-pi.net/u/mrbombmusic)
#### Post date: [January 30, 2022, 2:28am UTC](https://in-thread.sonic-pi.net/t/unit-plan-for-teachers-generative-music-in-sonic-pi/6452/1 "2022-01-30T02:28:41Z")

</div>

I am currently taking graduate school classes to get a second teaching certification in Computer Science (my primary certification is in music). As the final project for my Curriculum Development course, I had to develop a unit plan for a subject of my choosing. Naturally, I wanted to do something with Sonic Pi, so I decided to do a unit on creating generative music. It is meant to be a later unit in a class for beginners to coding.

The unit is posted on [github](https://github.com/hunter-teacher-cert/currdev_unit_plan-sonic-pi-gen-music). It includes detailed lesson plans with code examples, assignment sheets, lesson slides etc. I figured I’d share it here for others to take a look at. The lessons and documents are uploaded as pdfs but [this link](https://drive.google.com/drive/folders/1HU5Xx_uDxKJbD2fBs8F1xsHi-sL_Sqee?usp=sharing) is to a Google Drive folder where each part is in its own Google Doc.

Here are the topics covered:

1. Using Randon Events to Write a Song

- Defining Indeterminate/Aleotoric
- Create piece using dice rolls and coin flips
- Recreating Dice Roll and Coin Flip piece in Sonic Pi

1. True random vs Pseudo random

- Using rrand\_i to choose random integer from a range of numbers
- Establish why same number is always chosen
- Use\_random\_seed
- Discuss concept of pseudo random
- Time.now.to\_i

1. Manipulating data structures

- Identify ways to manipulate a sequence of numbers
- Introduce methods for manipulating data structures
- Provide randomized input to methods

1. Looping through data structures of different lengths

- Identify issues with basic looping structures
- Finding length of data structures = .length

1. Single Line Conditional Statements

- Single Line if statements
- Storing randomized output in variables
- Dice Roll simulation
- Out of Class Assignment Roll Out

1. Nested Conditionals

- Intro to Nested Conditionals
- Probability
- one\_in() function

1. Random Durations

- Note Duration
- Sample Rate

8-11. Final Project - Generative Music

- Defining Generative Music
- Assignment Roll Out
- In Class Work Time
- Gallery Walk

---

<div class="post-metadata">

### Author: ![ethancrawford](https://avatars.discourse-cdn.com/v4/letter/e/a88e4f/32.png) [@ethancrawford](https://in-thread.sonic-pi.net/u/ethancrawford)
#### Post date: [February 9, 2022, 3:40am UTC](https://in-thread.sonic-pi.net/t/unit-plan-for-teachers-generative-music-in-sonic-pi/6452/2 "2022-02-09T03:40:57Z")

</div>

@mrbombmusic - just had a closer look at the repository - It may or may not be too late notice now to be useful, but I saw that in this file:

> <https://github.com/hunter-teacher-cert/currdev_unit_plan-sonic-pi-gen-music/blob/5cd9decf32578e8cc0af154feaa54944c0693e17/resources/04%20-%20Different%20Length%20Data%20Structures%20Peardeck%20Slides.pdf>

You use code similar to the following:

```ruby
seq = (ring, ...)

```

To me, it seems like the comma after `ring` is unnecessary. It works fine without one there 🙂 - up to you whether you feel it’s worth removing them though 👍

---

<div class="post-metadata">

### Author: ![mrbombmusic](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/mrbombmusic/32/2282_2.png) [@mrbombmusic](https://in-thread.sonic-pi.net/u/mrbombmusic)
#### Post date: [June 13, 2024, 12:57am UTC](https://in-thread.sonic-pi.net/t/unit-plan-for-teachers-generative-music-in-sonic-pi/6452/3 "2024-06-13T00:57:02Z")

</div>

Just realizing the github link to the unit plan is no longer working and the post is too old for me to edit so I’m just posting an updated link: [GitHub - mrbombmusic/currdev\_unit\_plan-sonic-pi-gen-music: currdev\_unit\_plan-sonic-pi-gen-music created by GitHub Classroom](https://github.com/mrbombmusic/currdev_unit_plan-sonic-pi-gen-music)

---

<div class="post-metadata">

### Author: ![HarryLeBlanc](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/harryleblanc/32/2813_2.png) [@HarryLeBlanc](https://in-thread.sonic-pi.net/u/HarryLeBlanc)
#### Post date: [June 13, 2024, 1:55am UTC](https://in-thread.sonic-pi.net/t/unit-plan-for-teachers-generative-music-in-sonic-pi/6452/4 "2024-06-13T01:55:27Z")

</div>

Under probability, you might want to include spread too. To choose 3 in ten, you can just say spread(3, 10).pick – well worth knowing, and pretty easy.  
Have fun!
