User Tools

Site Tools


weblogo:commands:music

Multimedia Commands

Multimedia commands.

MIDI.RECORD

Records and saves music commands that PLAY plays.

Syntax

MIDI.RECORD TRUE
MIDI.RECORD filename

Description

MIDI.RECORD TRUE starts the recording of music commands in MIDI format. All PLAY commands with a list as input are recorded without actually being played. End the recording by entering MIDI.RECORD with a file name. Logo ends the recording and saves all recorded music to the MIDI file.

Note that Logo only records music commands, not sound or music files.

MIDI.RECORD TRUE
PLAY [8G. 16E C E G C5]
MIDI.RECORD "SONG

PLAY

Plays sound files or notes.

Syntax

PLAY filenameOrList
(PLAY filenameOrList TRUE)
(PLAY filenameOrList loop wait)
(PLAY)

Description

PLAY causes the given sound file to be played. If the filename does not have any extension, Logo assumes the extension “MP3”. Logo plays this file in the background, returning immediately. If the optional second input to PLAY is TRUE, Logo plays the file repeatedly. Stop playing a sound file by using (PLAY) with no inputs.

If the third input to PLAY is TRUE, PLAY waits for the song to finish before continuing.

Logo offers a variety of sounds in its ~HOME folder. Use the following command to list available sounds:

(DIR "~HOME/SOUNDS)

As a convenience, Logo looks into that directory if the input does not contain a path name, and the file cannot be found at the current directory (see also CURDIR).

If the input is a list, Logo treats the list as a list of music commands. Logo has its own tiny music language, enabling you to create music. Please refer to the manual chapter Making Music for a detailed explanation and tutorial. When Logo plays a list of music commands, it waits for the music to finish by default unless you set the thirds input to PLAY to FALSE.

Logo offers several different synthesizers to play music with. The global variable :MIDI.OUTPUTS contains a list of MIDI synthesizers. and you select the synthesizer by changing the value of the global variable :MIDI.OUTPUT.

You cannot play sounds or music on some mobile devices. These devices place restrictions on sounds and videos to prevent websites from using too much data by downloading huge media files.

Example

; plays "Aha" repeatedly
(PLAY "AHHA TRUE)
; Stops the play
(PLAY)
; Plays a short melody
PLAY [8G. 16E C E G C5]

PLAY.NOTES

Plays simple songs on a robot's speaker.

Syntax

PLAY.NOTES notes

Description

PLAY.NOTES lets you play simple songs on a robot's internal speaker. The input is a list of notes. A note is of the C, D, E, F, G, A, B. The duration of the note is in front of the letter, which can be one of 1, 2, 4, 8, 16, or 32 (which is a full, a half, a quarter note etc; if none is given, Logo assumes quarter notes). Optionally, the number of the octave is right behind the note.

Use the letter P for a pause instead of a note.

Use “On”, where “n” is a nubmer between 0 and 6, to preset the octave.

Use the letter T to set the tempo in quarter notes per minute. The default is “T120”, which is 120 quarter notes per minute.

InO-Bot has 1 1/2 octaves built in. Possible octaves are O4 and O5. Other robots may choose to ignore this command.

Example

; Play two eigth notes of C in two octaves
PLAY.NOTES [8C 8C5]
; Play a nice song
play.notes [t200 c d e c c d e c e f 2g e f 2g 8g 8a 8g 8f e c 8g 8a 8g 8f e c c g 2c c g 2c]

PLAY.SOUND

Play a predefined sound on a robot's speaker.

Syntax

PLAY.SOUND number

Description

PLAY.SOUND plays a predefined sound on a robot's speaker. Its input is a number between 1 and the number of sounds that the robot can play. Please note that if you play multiple sounds, you need to add a short delay with the [**WAIT*]] command. If you don't, each sound save for the last one will only be very short. If the robot does not have any built-in sound, the command is ignored.

InO-Bot has 43 built-in sounds.

Example

PLAY.SOUND 1

SAY

Makes Logo speak its input.

Syntax

SAY wordorlist

Description

SAY passes its input (a word or a list) to the computer's speech synthesizer, if there is any installed. This causes Logo to speak its input. On computers without a speech synthesizer, SAY does nothing.

Some robots or other devices may also implement the SAY command. If you TELL such a device, that device will talk instead of the computer.

Often, computers offer more than one voice. Use the Tools/Select Voice command or the SELECT.VOICE command to select a different voice. It can be a lot of fun to select a, say, Italian voice and have it speak English with an Italian accent!

The Chrome browser comes with several built-in voices, including Russian, Chinese and other voices. You might want to run Logo in the Chrome browser for a great selection of voices.

The Root robot can also talk. If you use the SAY command to have it talk, it talks robot gibberish.

SAY "HELLO
SAY [GOOD MORNING]

SELECT.VOICE

Opens a dialog where you can select a voice for the SAY command.

Syntax

SELECT.VOICE

Description

SELECT.VOICE opens a dialog where you can select a different voice for the SAY command. If your computer does not support speech synthesis, SELECT.VOICE does nothing.

It can be a lot of fun to select a, say, Italian voice and have it speak English with an Italian accent!

SELECT.VOICE
weblogo/commands/music.txt · Last modified: 2018/11/15 08:20 by michael