Making Music With Code TI-Nspire Student

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Making Music with Code TI-INNOVATOR™ STEM PROJECT

TI-NSPIRE™ CX STUDENT ACTIVITY

Making Music with Code

You will write a TI-BASIC program on your calculator to


create sounds using the built-in speaker on the TI-
Innovator Hub. You will also experiment with changing
the length of time in which each sound plays. Once you
have some experience, you will write a program to play
a song.

Your Challenge: TrebleMaterials:


Activity clef scale with notes from C4 to G5 First notes of “Twinkle, Twinkle, Little Star”

Find the sheet music for a simple song and write a • TI Nspire CX family calculator
• TI-Innovator Hub
program to play the song on the TI-Innovator Hub.
• Unit-to-unit cable

88 Key Piano Keyboard with Frequencies

Frequencies (in Hertz...Hz) are listed below the white keys and above the black keys. For example, A0 is equal to 27.5 Hz while A4 is equal to 440 Hz.
Notes start from A0 and go to C8 from left to right. Notice that as you move from left to right, each frequency for a note (B for example) roughly
doubles. B0 is 30.50 Hz while B1 is 61.74 Hz and B2 is 123.74 Hz and so on.

©2018 Texas Instruments Incorporated 1 education.ti.com


Making Music with Code TI-INNOVATOR™ STEM PROJECT
TI-NSPIRE™ CX STUDENT ACTIVITY

Music Concepts Explanation


Musical Scale Music is arranged with symbols on a “scale”. We use a scale since the notes are divided by “octaves”. An
octave represents eight steps between the equivalent note that is at either double or half the frequency.
For example, A4 is 440 hertz (Hz), while A5 is 880 Hz (twice the value of A4), while A3 is 220 Hz (half of A4).

Beats per minute/Tempo Have you ever noticed how some songs are slow while others are fast? Every song has its own “tempo” or
speed. The speed is determined by the number of “beats per minute”. A slow song may have 50 beats per
minute while a faster song may have 100 beats per minute.

Quarter, half, and whole notes • Notes can be shorter or longer depending on the song. One way for a musician to write a song with
notes of different durations is to use whole notes, half notes, quarter notes, eighth notes, and
sixteenth notes.
• One whole note equals four quarter notes or two half notes. One half note is equal to two quarter
notes and so on.
• For a song that has 4-4 measures, it means that each measure of the song has 4 beats. A whole note
would be equal to 4 beats (hence, one measure).
• How many half notes could fit into a 4-4 measure? If you said two, you are correct! Since each half
note is equal to two beats and there are four total beats per measure, two half notes are equal to
four beats.
So now you can see how a song with 100 beats per minute will have faster whole notes than a song with 50
beats per minute! Not all whole notes equal the same time duration!

Application of notes and beats per Twinkle, Twinkle, Little Star is a song that has multiple notes and uses 4-4 time. Try to code this song with
minute your calculator.

©2018 Texas Instruments Incorporated 2 education.ti.com


Making Music with Code TI-INNOVATOR™ STEM PROJECT
TI-NSPIRE™ CX STUDENT ACTIVITY

Projects Challenges
Challenge 1: Create a program called “c1”. Set the speaker on the Hub to play a tone of 440 Hz. Try several different tones. What is the lowest tone
you can hear? What is the highest tone that you can hear?

Challenge 2: Create a program called “c2”. Make a door bell using any key press on the calculator to ring the chime.

Challenge 3: Write a program called “c3” that plays the Major C scale from C4 to C5. Each note should be played for a variable length of time using
a variable named “duration”.

Challenge 4: Create a program called “c4”. Make a metronome that: plays 10 beats with a tone of middle C4 with a duration of a ¼ note at 100
Beats per minute. To do this you will need to determine the how long a quarter note is (in seconds) based on the information above. A rest of .1
seconds should be used between beats.
Try a double time tempo of 200 BPM.
Try using a 1/2 or whole note.

*Use the file “88 Piano Keys” utility found in 88 Piano Keys.tns file or create tables to convert notes to duration and frequency.

Challenge 5: Create a program called “c5”. Use the sheet music for Twinkle to play the first two bars of the song on your Hub.

*Use the file “88 Piano Keys” utility found in 88 Piano Keys.tns file or create tables to convert notes to duration and frequency.

Challenge 6: Create a program called “c6”. Use two lists with frequencies and durations and a loop to play the same Twinkle song.

Final Challenge: Find the sheet music for a simple song and play it on the Hub.

©2018 Texas Instruments Incorporated 3 education.ti.com


Making Music with Code TI-INNOVATOR™ STEM PROJECT
TI-NSPIRE™ CX STUDENT ACTIVITY

Example Programming Commands for the project


Example Code Behavior
Send “SET SOUND 440 TIME 4” Plays a 440 hertz tone on the speaker for 4 seconds
DispAt 3, “Note = 440 Hz” Displays the message “Note = 440 Hz” on calculator. A variable value may also be displayed with the text
message. For example DispAt 3,” Note =“,n will display the same output if the value of 440 is stored in the
variable named n.
For n,1,10 Runs For loop 10 times, starting at 1 and ending at 10. Executes the statement in the block each time, displays
DispAt 3,n the value for the counter variable, n, on row 3.
EndFor
n:=440 When eval is used within a Hub command, the variable value is inserted into the Hub command. In the example,
Send “SET SOUND eval(n)” the value for variable n is 440. The next command then is sent as Send “SET SOUND 440” and a tone is played on
the Hub.
Wait 2 Causes program execution to halt and wait for two seconds.
©D5 The © symbol is used as a “comment”. A comment is meant to leave notes within the program for easier
navigation later or to let the user know what the following line of code is used for. Anytime there is a © in a
program, that line of information is NOT part of the program. It is ignored by the system and is only there for
reference. © is found on the 1:Actions Program Menu.
Calculator Notes:
• On the Home screen press 4:Current to return to your document file.
• On the Home screen Press 1:New to create a new document file.
• You create and edit programs in a Program Editor app. You run programs from within a Calculator app.
• Use the [menu] key to see the options for your current app.
• ctrl-b is the shortcut from the Check Syntax and Store menu to store changes to your program.
• ctrl-r is the shortcut from the Check Syntax and Store menu to store changes to your program and paste the name to a Calculator app
• Press [enter] to run a program named on a Calculator app entry line.
• The Calculator app “remembers” the last command entered. Press Enter after a program has run to run the program again.
• Find your program names in a Calculator app by pressing the [var] (variables) key.
• Move from page to page by using ctrl-left arrow and ctrl-right arrow or by using the touchpad pointer to click on the desired page tab.
• ctrl-doc (+page) will add a blank page to your document.
• ctrl-z will undo your last action.
• To stop (“break”) a program press and hold the ON key until you receive a dialogue box.
• ctrl-s is the shortcut for saving your entire document file. Do this periodically to save your work.
©2018 Texas Instruments Incorporated 4 education.ti.com

You might also like