- 1. speaker[index] plays note [note] for[beat]beats
- 2. speaker [index] plays sound at frequency of [hz] for [time] secs
- 3. speaker[index] plays sound at frequency of [hz]
- 4. speaker[index] plays [string]
- 5. speaker [index] plays [string] until done
- 6. speaker [index]stops sound
- 7. speaker [index] increases volume by [volume] %
- 8. speaker [index] sets volume to [volume] %
- 9. speaker [index]’s volume(%)
- 10. speaker [index] is playing song?
- 11. emotional sound [emotion_sound]
- 12. electronic sound[electronic_sound]
- 13. physical sound[physical_sound]
- 14. number and letter sound [number_letter_sound]
- 15. english word[english_word]
1. speaker[index] plays note [note] for[beat]beats
Makes the specified speaker play the specified note for the specified number of beats
How to use
The number of speaker in the block indicates the place of a speaker among the ones connected to Halocode. As shown in the following figure, the number 1 indicates the first speaker connected to Halocode, 2 indicates the second one, and so on.
Note description
Determined by frequency, notes can represent the pitch and duration of a sound in musical notation. The character in a note name is called letter name, and the number on the right indicates an octave.
Mapping between letter names and solfeges:
Beat description
A beat refers to the total length of a note in each measure in a musical notation. Common beats include 1/4, 2/4, 3/4, 4/4, 3/8, 6/8, 7/8, 9/8, 12/8. The length of each measure is fixed.
Example
When you press the button on Halocode, the speaker plays music “Twinkle Twinkle Little Star”.
2. speaker [index] plays sound at frequency of [hz] for [time] secs
Makes the specified speaker play at the specified frequency for a specified time
How to use
The vibrational frequency of the sound determines the pitch, which is measured in hertz (Hz).
The sound of some cars:
Fire engine: Gradually from low frequency (650-750 Hz) to high frequency (1450-1550 Hz) at an interval of 1.5 seconds. Then drop back from the high frequency to the low frequency, each interval of 3 seconds.
Police cars: Gradually from low frequency (650-750 Hz) to high frequency (1450-1550 Hz) at an interval of 0.23 seconds. Then drop back from the high frequency to the low frequency, each interval of 0.1 seconds.
Ambulance: Gradually from low frequency (650-750 Hz) to high frequency (9000-10000 Hz) at intervals of 0.4 seconds. Then drop back from the high frequency to the low frequency, each interval of 0.6 seconds. Alternate between high and low frequencies.
Example
When you press the button on Halocode, the speaker plays the sound of an ambulance.
3. speaker[index] plays sound at frequency of [hz]
Makes the specified speaker play sound at the specified frequency
Example
When you press the button on Halocode, the speaker play sound at frequency of 700.
4. speaker[index] plays [string]
Makes the specified speaker play a default or custom audio file
How to use
Play a custom audio file
Before playing a custom audio file, follow the steps below to store the audio file to the speaker:
1. Connect the speaker to your computer
Connect the speaker to your computer with the Micro USB cable. After the connection is successful, the disk of speaker will be displayed in your computer. Open the disk to check the files in the speaker.
2. Store the audio file to the speaker
Drag the audio file you want to play to the speaker’s disk.
Note: The audio file may can’t be stored if the size is larger than speaker. It’s recommended to compress the audio file and try again.
3. Modify the audio file name (important)
Due to the hardware limitations, the speaker can only find and play the audio file by searching the first four characters of the audio file name (which can only be composed of English letters, numbers, or punctuation). So in order to play the audio successfully, you need to modify the audio file name to the required format (four characters composed of English letters, numbers, or punctuation).
Here are some examples that can help you understand how to modify the audio file name. The left side is the original name, and the right is the file name that is available after modification.
- Yesterday once more.mp3 —————————> ysom.mp3
- One of us.mp3 ————-> oous.mp3
- happy birthday.mp3 —————> M001.mp3
After you finish the modification, enter the audio name in the block to play the audio file.
Play a default audio file
The speaker contains rich of default audio files, put the sound block into the speaker () plays () block to play the audio file.
How to restore the default audio files?
A wrong operation may damage the default audio files of speaker, and the default sound can not be played properly. To restore the default files, visit the following link to download the default audio files:
Download the preset audio files
Example
When you press the button on Halocode, the speaker plays the audio file named “ysom”.
5. speaker [index] plays [string] until done
Makes the specified speaker play a default or custom audio file until it ends. Then run the following script
Example
When you press the button on Halocode, the speaker starts playing the audio file named “M001”, and then the LED animation “rainbow” will be played after the audio is played.
6. speaker [index]stops sound
Makes the specified speaker stop sound
Example
When Halocode starts up, the speaker plays the audio file “M001”. If you press the button, the speaker will stop playing the sound.
7. speaker [index] increases volume by [volume] %
Increases the volume of the specified speaker by the specified percentage, a negative number indicates decreasing
How to use
Available value range: –100 to +100
Note: The volume can’t be changed when the speaker plays a sound at a specified frequency.
How to use
When you press the button on Halocode, the volume of the speaker is increased by 20%, and then the speaker plays the emotional sound ‘hello”.
8. speaker [index] sets volume to [volume] %
Sets the volume of the specified speaker to the specified percentage(0–100)
Example
When you press the button on Halocode, the volume of the speaker is set to 50%, and then the speaker plays the electronic sound “start”.
9. speaker [index]’s volume(%)
Reports the volume of the specified speaker
How to use
It is a reporter type block. Select the checkbox next to the block to display the current volume on the stage.
Example
When you press the button on Halocode, the LED ring shows the volume of the speaker.
10. speaker [index] is playing song?
Detects if the speaker is playing a song
Example
When you press the button on Halocode, if the speaker is playing a song, all the LEDs will light up green.
11. emotional sound [emotion_sound]
Default emotional sound
How to use
Put the emotional sound block to speaker () plays () block to play the sound and create more fun projects.
Choose a sound from the drop-down menu:
Example
When you press the button on Halocode, the speaker plays “hi”.
12. electronic sound[electronic_sound]
Default electronic sound
How to use
Put the electronic sound block to speaker () plays () block to play the sound and create more fun projects.
Choose a sound from the drop-down menu:
Example
When you press the button on Halocode, the speaker plays the electronic sound “start”.
13. physical sound[physical_sound]
Default physical sound
How to use
Put the physical sound block to speaker () plays () block to play the sound and create more fun projects.
Choose a sound from the drop-down menu:
Example
When you press the button on Halocode, the speaker plays the physical sound “shot-1”.
14. number and letter sound [number_letter_sound]
Default number and letter sound
How to use
Put the number and letter sound block to speaker () plays () block to play the sound and create more fun projects.
Choose a sound from the drop-down menu:
Example
When you press the button on Halocode, the speaker plays the letter “A”.
15. english word[english_word]
Default English word sound
How to use
Put the english word block to speaker () plays () block to play the sound and create more fun projects.
Choose a sound from the drop-down menu:
Example
When you press the button on Halocode, the speaker plays the English word “black”.