1. speaker[index] plays note [note] for[beat]beats

Speaker - 图1

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.
Speaker - 图2

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:
Speaker - 图3

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”.
Speaker - 图4


2. speaker [index] plays sound at frequency of [hz] for [time] secs

Speaker - 图5

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.
Speaker - 图6


3. speaker[index] plays sound at frequency of [hz]

Speaker - 图7

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.
Speaker - 图8


4. speaker[index] plays [string]

Speaker - 图9

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.
Speaker - 图10

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.
Speaker - 图11

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”.
Speaker - 图12


5. speaker [index] plays [string] until done

Speaker - 图13

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.
Speaker - 图14


6. speaker [index]stops sound

Speaker - 图15

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.
Speaker - 图16


7. speaker [index] increases volume by [volume] %

Speaker - 图17

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”.
Speaker - 图18


8. speaker [index] sets volume to [volume] %

Speaker - 图19

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”.
Speaker - 图20


9. speaker [index]’s volume(%)

Speaker - 图21

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.
Speaker - 图22

Example

When you press the button on Halocode, the LED ring shows the volume of the speaker.
Speaker - 图23


10. speaker [index] is playing song?

Speaker - 图24

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.
Speaker - 图25


11. emotional sound [emotion_sound]

Speaker - 图26

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:
Speaker - 图27

Example

When you press the button on Halocode, the speaker plays “hi”.
Speaker - 图28


12. electronic sound[electronic_sound]

Speaker - 图29

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:
Speaker - 图30

Example

When you press the button on Halocode, the speaker plays the electronic sound “start”.
Speaker - 图31


13. physical sound[physical_sound]

Speaker - 图32

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:
Speaker - 图33

Example

When you press the button on Halocode, the speaker plays the physical sound “shot-1”.
Speaker - 图34


14. number and letter sound [number_letter_sound]

Speaker - 图35

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:
Speaker - 图36

Example

When you press the button on Halocode, the speaker plays the letter “A”.
Speaker - 图37


15. english word[english_word]

Speaker - 图38

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:
Speaker - 图39

Example

When you press the button on Halocode, the speaker plays the English word “black”.
Speaker - 图40