--- title: First Notes layout: ../../layouts/MainLayout.astro --- import { MiniRepl } from '@src/docs/MiniRepl'; import { midi2note } from '@strudel/core'; import Box from '@components/Box.astro'; import QA from '@components/QA'; # First Notes Let's look at how we can play notes ## numbers and notes **play notes with numbers** [midi2note(i + 36), i + 36]), )} /> Try out different numbers! Try decimal numbers, like 55.5 **play notes with letters** [n, n.split('')[0]]))} /> Try out different letters (a - g). Can you find melodies that are actual words? Hint: ☕ 😉 ⚪ **add flats or sharps to play the black keys** [n, n.split('').slice(0, 2).join('')]), )} /> [n, n.split('').slice(0, 2).join('')]), )} /> **play notes with letters in different octaves** [midi2note(i + 36), midi2note(i + 36)]), )} /> Try out different octaves (1-8) If you are not comfortable with the note letter system, it should be easier to use numbers instead. Most of the examples below will use numbers for that reason. We will also look at ways to make it easier to play the right notes later. ## changing the sound Just like with unpitched sounds, we can change the sound of our notes with `sound`: {/* c2 g2, e3 b3 d4 e4 */} Try out different sounds: - gm_electric_guitar_muted - gm_acoustic_bass - gm_voice_oohs - gm_blown_bottle - sawtooth - square - triangle - how about bd, sd or hh? - remove `.sound('...')` completely **switch between sounds** **stack multiple sounds** The `note` and `sound` patterns are combined! We will see more ways to combine patterns later.. ## Longer Sequences **Divide sequences with `/` to slow them down** {/* [c2 bb1 f2 eb2] */} The `/4` plays the sequence in brackets over 4 cycles (=4s). So each of the 4 notes is 1s long. Try adding more notes inside the brackets and notice how it gets faster. Because it is so common to just play one thing per cycle, you can.. **Play one per cycle with \< \>** ").sound("gm_acoustic_bass")`} punchcard /> Try adding more notes inside the brackets and notice how it does **not** get faster. **Play one sequence per cycle** {/* <[c2 c3]*4 [bb1 bb2]*4 [f2 f3]*4 [eb2 eb3]*4>/2 */} /2") .sound("gm_acoustic_bass")`} punchcard /> **Alternate between multiple things** ") .sound("gm_xylophone")`} punchcard /> This is also useful for unpitched sounds: , [~ hh]*2") .bank("RolandTR909")`} punchcard /> ## Scales Finding the right notes can be difficult.. Scales are here to help: ") .scale("C:minor").sound("piano")`} punchcard /> Try out different numbers. Any number should sound good! Try out different scales: - C:major - A2:minor - D:dorian - G:mixolydian - A2:minor:pentatonic - F:major:pentatonic **automate scales** Just like anything, we can automate the scale with a pattern: , 2 4 <[6,8] [7,9]>") .scale("/4") .sound("piano")`} punchcard /> If you have no idea what these scale mean, don't worry. These are just labels for different sets of notes that go well together. Take your time and you'll find scales you like! ## Repeat & Elongate **Elongate with @** Not using `@` is like using `@1`. In the above example, c is 3 units long and eb is 1 unit long. Try changing that number! **Elongate within sub-sequences** *2") .scale("/4") .sound("gm_acoustic_bass")`} punchcard /> This groove is called a `shuffle`. Each beat has two notes, where the first is twice as long as the second. This is also sometimes called triplet swing. You'll often find it in blues and jazz. **Replicate** ]").sound("piano")`} punchcard /> Try switching between `!`, `*` and `@` What's the difference? ## Recap Let's recap what we've learned in this chapter: | Concept | Syntax | Example | | --------- | ------ | -------------------------------------------------------- | | Slow down | \/ | | | Alternate | \<\> | ")`} /> | | Elongate | @ | | | Replicate | ! | | New functions: | Name | Description | Example | | ----- | ----------------------------------- | --------------------------------------------------------------------------------- | | note | set pitch as number or letter | | | scale | interpret `n` as scale degree | | | stack | play patterns in parallel (read on) | | ## Examples **Classy Bassline** /2") .sound("gm_synth_bass_1") .lpf(800) // <-- we'll learn about this soon`} /> **Classy Melody** *2\`).scale("C4:minor") .sound("gm_synth_strings_1")`} /> **Classy Drums** , [~ hh]*2") .bank("RolandTR909")`} /> **If there just was a way to play all the above at the same time.......** It's called `stack` 😙 /2") .sound("gm_synth_bass_1").lpf(800), n(\`< [~ 0] 2 [0 2] [~ 2] [~ 0] 1 [0 1] [~ 1] [~ 0] 3 [0 3] [~ 3] [~ 0] 2 [0 2] [~ 2] >*2\`).scale("C4:minor") .sound("gm_synth_strings_1"), sound("bd*2, ~ , [~ hh]*2") .bank("RolandTR909") )`} /> This is starting to sound like actual music! We have sounds, we have notes, now the last piece of the puzzle is missing: [effects](/workshop/first-effects)