Sound

BEEP [SoundEffectNumber[,[Pitch][,[Volume][,[Panpot]]]]]

Play simple warning and sound effects

Arguments

SoundEffectNumber

Sound type

Sound Effect Number Description
0 to 156 Preset Sounds
224 to 255 User Waveforms
256 to 383 BGM Sound Source

・0, if not specified.

Pitch

Pitch value: -32768 to 32767 (semitones by 100)

・0, if not specified.

Volume

Playback volume: 0 to 127

・64 is the default.

Panpot

Panpot: 0 (left) to 64 (center) to 127 (right)

・64 is the default.

Example

BEEP 3

BEEP([SoundEffectNumber[,[Pitch][,[Volume][,[Panpot]]]]])

Play simple warning and sound effects

Arguments

SoundEffectNumber

Sound type

Sound Effect Number Description
0 to 156 Preset Sounds
224 to 255 User Waveforms
256 to 383 BGM Sound Source

・0, if not specified.

Pitch

Pitch value: -32768 to 32767 (semitones by 100)

・0, if not specified.

Volume

Playback volume: 0 to 127

・64 is the default.

Panpot

Panpot: 0 (left) to 64 (center) to 127 (right)

・64 is the default.

Return Value

Handle

Handle to operate stop/volume/pitch/panpot after pronunciation: 0 to 15

Example

H=BEEP(152)

BEEPPAN Handle,Panpot

Change the sound effect panpot

Arguments

Handle

Handle obtained by executing the BEEP command

Panpot

Value of panpot to change: 0 (left) to 64 (center) to 127 (right)

Example

H=BEEP(152)
WAIT 60
BEEPPAN H,0

BEEPPIT Handle,Pitch

Change the pitch of sound effects

Arguments

Handle

Handle obtained by executing the BEEP command

Pitch

Value of pitch to change: -32768 to 32767

・Semitones by 100.

Example

H=BEEP(152)
WAIT 60
BEEPPIT H,1200

BEEPSTOP [Handle[,FadeTime]]

Stop sound effects

Arguments

Handle

Handle obtained by executing the BEEP command

・If not specified, all sound effects are stopped.

FadeTime

Specify in seconds

・Real can be specified.
・Stop immediately with 0.
・0, if not specified.

Example

BEEPSTOP

H=BEEP(152)
WAIT 60
BEEPSTOP H

BEEPVOL Handle,Volume

Change sound effect volume

Arguments

Handle

Handle obtained by executing the BEEP command

Volume

Volume value to change: 0 to 127

Example

H=BEEP(152)
WAIT 60
BEEPVOL H,16

BGMCLEAR [UserDefinedMusicNumber]

Delete user-defined music

Argument

UserDefinedMusicNumber

Music number: 128 to 255

・If not specified, all definitions are deleted.

Example

BGMCLEAR

BGMCONT [TrackNumber[,FadeTime]]

Resume music playback when paused

・Use BGMPAUSE to pause.

Arguments

TrackNumber

Track number to play: 0 to 15

・If not specified, all tracks are restarted.

FadeTime

Specify in seconds

・Real can be specified.
・Restart immediately with 0.
・0, if not specified.

Example

BGMCONT

BGMPITCH [TrackNumber,]Pitch

Change the reference pitch of the music being played

Arguments

TrackNumber

Target track number: 0 to 15

・If not specified, all tracks are the default.

Pitch

Changing pitch value: -32768 to 32767

・Semitones by 100

Example

BGMPITCH 0,100

BGMPLAY [TrackNumber,]MusicNumber[,Volume][,FadeTime]

Start playing the specified music

Arguments

TrackNumber

Track number to play: 0 to 15

・0, if not specified.

MusicNumber

・Preset sound source (0 to 73)
・User-defined (128 to 255)

Volume

・Playback volume: 0 to 127

FadeTime

・Fade-in time: 0 to 32767 seconds

Example

BGMPLAY 128

BGMPLAY MMLString

Start playing the specified MML data

・Playback by MML is performed on track 0.
・User-defined music number 255 is rewritten as an MML music.

Argument

MMLString

Command string

Example

BGMPLAY "T120O4L4CC8D8EE8F8GA8G8E2" 

BGMPAUSE [TrackNumber[,FadeTime]]

Pause music playback

・Use BGMCONT to resume.

Arguments

TrackNumber

Track number to play: 0 to 15

・If not specified, all tracks are stopped.

FadeTime

Specify in seconds

・Real can be specified.
・Immediate stop with 0.
・0, if not specified.

Example

BGMPAUSE

BGMSET UserDefinedMusicNumber,MMLString

Define user-defined music

・The defined music can be played on BGMPLAY.

Arguments

UserDefinedMusicNumber

User-defined music number: 128 to 255

MMLString

Command string

Example

BGMSET 128,"CDEFG" 

BGMSETD UserDefinedMusicNumber,@LabelString

Predefine user-defined music

・The defined music can be played on BGMPLAY.
・Register MML internally using DATA command (DATA "CDEFGAB").
・Define a numerical value of 0 at the end of DATA.

Arguments

UserDefinedMusicNumber

User-defined music number: 128 to 255

@LabelString

Label or label string with MML string registered in DATA

Example

BGMSETD 128,"@MMLTOP" 

BGMSTOP [TrackNumber[,FadeTime]]

Stop playing music

Arguments

TrackNumber

Target track number: 0 to 15

・If not specified, all tracks are stopped.

FadeTime

Specify in seconds

・Real can be specified.
・Immediate stop with 0.
・0, if not specified.

Example

BGMSTOP

BGMVAR TrackNumber,VariableNumber,Value
BGMVAR TrackNumber,VariableNumber OUT Variable

Set and get BGM track variable values

Arguments

TrackNumber

Track number: 0 to 15

VariableNumber

Variable number to set/get value: 0 to 7

Return Value

The acquired variable value

Example

BGMVAR 0,1,2
V=BGMVAR(0,1)

BGMVOL [TrackNumber,]Volume

Set the volume of the specified track

Arguments

TrackNumber

Track number to play: 0 to 15

・0, if not specified.

Volume

Volume to set: 0 to 127

Example

BGMVOL 0,64

BGMWET [TrackNumber,]Wet

Set the effector level for the specified track

・Volume changes when effector is off. Use with the effector turned on.

Arguments

TrackNumber

Track number to set: 0 to 15

・0, if not specified.

Wet

Effector level to be set: 0 (dry) to 127 (wet)

Example

BGMWET 0,64

EFCEN State
EFCEN OUT Variable

Set/get effector status

Argument

State

0 #EFCOFF OFF
1 #EFCON ON

Return Value

0: OFF
1: ON

Example

EFCEN 0
S=EFCEN()

EFCSET PresetNumber

Set effectors (preset designation)

Argument

PresetNumber

0 #EFCOFF OFF
1 #EFCBATH Bath
2 #EFCCAVE Cave
3 #EFCSPACE Space

Example

EFCSET #EFCSPACE

EFCSET ReflectionSoundMode,ReflectionSoundVolume,ReflectionSoundTime,EchoMode,EchoVolume,EchoTime,HighSoundAttenuationRate,EchoTone,InputVolume

Set effectors (detailed settings)

Arguments

ReflectionSoundMode

0 #EFCREFSROOM Small Room
1 #EFCREFLROOM Large Room
2 #EFCREFHALL Hall
3 #EFCREFCAVE Cave
4 #EFCREFNONE No Reflections

ReflectionSoundVolume

Reflected sound volume: 0.0 to 1.0

ReflectionSoundTime

Time for reflected sound to decay: 0 to 300 (milliseconds)

EchoMode

0 #EFCREVROOM Room
1 #EFCREVHALL Hall
2 #EFCREVMETAL Metallic Corridor
3 #EFCREVCAVE Cave
4 #EFCREVREV Reverb

EchoVolume

Reverberation volume: 0.0-1.0

EchoTime

Reverberation decay time: 100-20000 (milliseconds)

HighSoundAttenuationRate

Decay rate of reverberant treble: 0.1 to 1.0 (the lower the value, the faster the treble is attenuated)

EchoTone

Reverberant tone parameters: 0.0 to 1.0

InputVolume

Effector input volume: 0.0 to 1.0

Example

EFCSET #EFCREFSROOM,1,100,#EFCREVROOM,1,20000,1,0.01,0.5

EFCWET BEEPWet,BGMWet,TALKWet,PCMWet

Set effector wetness

・Volume changes when effector is off. Use with the effector turned on.

Arguments

BEEPWet

Effect on BEEP: 0 (dry) to 127 (wet)

BGMWet

Effect on BGMPLAY: 0 (dry) to 127 (wet)

TALKWet

Effect on TALK: 0 (dry) to 127 (wet)

PCMWet

Effect on PCMSTREAM: 0 (dry) to 127 (wet)

Example

EFCWET 64,64,64,64
EFCWET 0,0,127,0

PCMCONT

Resume PCM playback

Example

PCMCONT

PCMPOS PlaybackPosition

Set the PCM playback position

・Set which array index will be used for the next time PCM data is sent at regular intervals.

Argument

PlaybackPosition

The index of the array specified by PCMSTREAM

Example

PCMPOS 1024

PCMPOS OUT Variable

Get PCM playback position

-Returns the array index from which the next transmission of PCM data, which is performed at regular intervals, will be performed.

Return value

The index of the array specified by PCMSTREAM

Example

PCMPOS OUT P

PCMSTOP

Stop PCM playback

Example

PCMSTOP

PCMSTREAM PCMDataArray[,SamplingFrequency]

Start PCM playback

Arguments

PCMDataArray

An array containing PCM data. The 1D array is reproduced as monaural and the 2D array is reproduced as stereo sound.
Arrays are treated as ring buffers and can be rewritten while playing.

SamplingFrequency

Sampling frequency (Hz) of data to be reproduced: 1 to 192000

・The default is 48000.

Example

DIM PCMDATA[2,48000]
PCMSTREAM PCMDATA,48000

PCMSTREAM PCMDataArrayL,PCMDataArrayR[,SamplingFrequency]

Start PCM playback

Argument

PCMDataArrayL

An array containing PCM data on the left side of stereo audio.
Arrays are treated as ring buffers and can be rewritten while playing.

PCMDataArrayR

An array containing PCM data on the right side of stereo audio.
Arrays are treated as ring buffers and can be rewritten while playing.

SamplingFrequency

Sampling frequency (Hz) of data to be reproduced: 1 to 192000

・The default is 48000.

Example

DIM PCML[48000],PCMR[48000]
PCMSTREAM PCML,PCMR,48000

PCMVOL Channel,Volume[,NumberOfSamples]

Set the PCM volume

Arguments

Channel

Specify the channel to set the volume

0 #PVLEFT Left
1 #PVRIGHT Right

Volume

Volume to set: -32767 to 32767 (Specifying a negative value reverses the phase.)

NumberOfSamples

Number of output samples until the set volume is reached

・0, if not specified.

Example

PCMVOL 0,0,48000

PCMVOL [Channel,]Volume

Set the PCM volume

Arguments

Channel

Specify the channel to set the volume

0 #PVLEFT Left
1 #PVRIGHT Right

・If not specified, it's both.

Volume

Volume to set: -32767 to 32767 (Specifying a negative value reverses the phase.)

Example

PCMVOL 16384

PCMVOL OUT LeftVolume[,RightVolume]

Get PCM volume

Return Value

LeftVolume

Current left channel or monaural volume: -32767 to 32767

Right volume

Current right channel volume: -32767 to 32767

Example

PCMVOL OUT L,R

RECCHK OUT State

Get recording status by RECSTART

Return Value

Recording complete/stop=0, Recording = 1

Example

RECSTART 10
WHILE RECCHK():WEND

RECDATA SamplePosition OUT Left,Right

Extract sample values recorded with RECSTART

Argument

SamplePosition

0 to RECLEN()-1

Return Value

Left

Left channel sample value

Right

Right channel sample value

Example

RECSTART 10
WHILE RECCHK():WEND
FOR I=0 TO RECLEN()-1
  RECDATA I OUT L,R
NEXT

RECLEN()

Returns the number of buffer samples allocated by RECSTART

Return Value

Buffer sample count

Example

RECSTART 10
? RECLEN() '480000

RECPOS()

Returns the current sample position recorded with RECSTART

Return Value

Sample position

Example

RECSTART 10
WHILE RECCHK()
 ? RECPOS
WEND

RECSAVE Array[,SampleNumber][,SamplePosition]

Extract sample values recorded with RECSTART into an array

Arguments

Array

Specify a 1D array or a 2D array. The number of elements is adjusted automatically.

For a 1D array, the average value of the left and right samples. In the case of a 2D array, [0, x] is the left channel and [1, x] is the right channel sample value.

SampleNumber

Number of samples to be taken

・If not specified, it's the same value as RECPOS().

SamplePosition

Top position to take out sample

・0, if not specified.

Example

RECSTART 5
BGMPLAY 3
WHILE RECCHK():WEND
BGMSTOP
DIM BUF[2,1]
RECSAVE BUF
WAIT 60
PCMSTREAM BUF,48000
INPUT A$

RECSTART Time

Record sound played on BEEP/BGMPLAY/TALK

・Record at the sampling frequency 48KHz for the time given by the argument.
・Recording stops after the specified time.
・Use RECSTOP to stop during recording.

Argument

Time

Number of seconds to record: 0.1 to 60

Example

RECSTART 5
BGMPLAY 3
WHILE RECCHK():WEND
BGMSTOP
DIM BUF[2,1]
RECSAVE BUF
WAIT 60
PCMSTREAM BUF,48000
INPUT A$

RECSTART

Record sound played on BEEP/BGMPLAY/TALK

・Record at sampling frequency of 48KHz (no time limit).
・The buffer is prepared for 5 seconds.
・Use RECSTOP to stop recording.

Example

LENGTH=48000/3
DIM BUF[2,LENGTH]
PCMSTREAM BUF,48000
PCMVOL 0,16384
PCMVOL 1,16384
RECSTART
BGMPLAY 1
PPOS=0
WPOS=0
LOOP
 NPOS=RECPOS()
 IF PPOS!=NPOS THEN
  FOR I=PPOS to NPOS-1
   RECDATA I OUT L,R
   BUF[0,WPOS]=L
   BUF[1,WPOS]=R
   WPOS=(WPOS+1) mod LENGTH
  NEXT
  PPOS=NPOS
 ENDIF
ENDLOOP

RECSTOP

Stop recording with RECSTART

Example

RECSTART 10
WAIT 60*5
RECSTOP

SNDMSBAL Balance[,FadeTime]

Set the volume balance of the main/sub interpreter

・It can only be set within subprograms.

Arguments

Balance

Balance to be set: 0 (sub side only) to 64 (main/sub equal) to 127 (main side only)

FadeTime

Time to reach the set balance: 0 to 32767 (seconds)

Example

SNDMSBAL 0,3.5

SNDMSBAL OUT Balance

Obtaine the volume balance of the main/sub interpreter

Return Value

Current balance

Example

SNDMSBAL OUT B

SNDMVOL Volume[,FadeTime]

Set the overall sound volume

・Settings from subprograms are ignored.

Arguments

Volume

Volume to be set: 0 to 127

FadeTime

Time to reach the set volume: 0 to 32767 (seconds)

Example

SNDMVOL 0,1.5

SNDMVOL OUT Volume

Get the volume of the entire sound

Return Value

Current volume (changes within the specified time if it's fading)

Example

V=SNDMVOL()

SNDSTOP

Stop all sounds

Example

'BGM/BEEP/TALK
SNDSTOP

TALK String

Start speech synthesis according to the given string

Argument

Hiragana / Katakana / Punctuation marks or phoneme strings starting with $

  a b d e f g h i j k m n o p q(n) r s t u w y z
  by ch cl(hopping sound) dy gy hy ky my ny py sh ts
  #(0.1 second no sound)

In addition to the above, control strings starting with < and ending with >

<SValue> Speed: 0 (Fast) to 1024 (Slow) Standard: 128
<PValue> Pitch: 0 (High) to 1024 (Low) Standard: 128
<VValue> Volume: 0 (Little) to 128 (Loud) Standard: 128

Example

TALK "<S128>Konnichiwa. Watashiha, PetitCom4 desu." 
TALK "$<S128>koqnichiwa######watashiwa##puchikoqfoodesu" 

TALKSTOP

Stop speech synthesis

Example

TALKSTOP

WAVSET InstrumentNumber,Attack,Decay,Sustain,Release,DefinitionString[,ReferencePitch]

Set the instrument sound waveform

Arguments

InstrumentNumber

Instrument number for setting the waveform: 224 to 255

Attack

Time to increase the volume to maximum: 0 to 127 (faster as the value increases)

Decay

Time until the volume decreases from the maximum value to become constant: 0 to 127 (faster as the value increases)

Sustain

Volume when extending the sound: 0 to 127 (louder as the value increases)

Release

Time until volume decreases to 0: 0 to 127 (faster as the value increases)
・When the release is set to 0, the playback sound cannot be stopped with BGMSTOP, but it can be forcibly stopped with the SNDSTOP command.

DefinitionString

"00" to "FF" are continuously described as one sample of 8 bits (128 is subtracted and treated as a value of -128 to 127)

Specify with 16, 32, 64, 128, 256 and 512 samples

ReferencePitch

Specify the note number of the pitch of the defined waveform.

・The default is 69 ("O4A": A of octave 4).

Example

WAVSET 224,127,0,0,127,"FF00"*8,69
BGMPLAY "@224O4A1" 

WAVSETA InstrumentNumber,Attack,Decay,Sustain,Release,Array[,ReferencePitch][,WaveStart][,WaveEnd]

Set the instrument sound waveform

・Version 3 compatibility mode
・Depending on sample length and reference pitch, correct pitch may not be produced.

Arguments

InstrumentNumber

Instrument number for setting the waveform: 224 to 255

Attack

Time to increase the volume to maximum: 0 to 127 (faster as the value increases)

Decay

Time until the volume decreases from the maximum value and becomes constant: 0 to 127 (faster as the value increases)

Sustain

Volume when extending the sound: 0 to 127 (louder as the value increases)

Release

Time until volume decreases to 0: 0 to 127 (faster as the value increases)
・When the release is set to 0, the playback sound cannot be stopped with BGMSTOP, but it can be forcibly stopped with the SNDSTOP command.

Array

A 1D array containing waveforms
・One element is treated as one sample of 8 bits. (128 is subtracted and treated as a value of -128 to 127)

ReferencePitch

Specify the note number of the pitch of the defined waveform.

・The default is 69 ("O4A": A of octave 4).

WaveformStart

Specify the index of the top position of the waveform.

・0, if not specified.

WaveformEnd

Specify the index of the end position of the waveform.

・If not specified, it'll be the end of the array.

Example

DIM W[2048]
WAVSETA 224,127,0,0,127,W,69,0,2047
BGMPLAY "@224O4A1" 

WAVSETA InstrumentNumber,Attack,Decay,Sustain,Release,Array,ReferencePitch,LoopStart,LoopEnd,SampleFrequency[,Offset][,BEEPLoopFlag]

Set the instrument sound waveform

・Accommodates waveforms as long as the sound memory capacity allows (at a sample frequency of 48000Hz for about 80 seconds)
・Loop setting and sample frequency can be specified.
・Depending on the sample length, reference pitch, and sample frequency, the correct pitch may not be produced.

Arguments

InstrumentNumber

Instrument number for setting the waveform: 224 to 255

Attack

Time to increase the volume to maximum: 0 to 127 (faster as the value increases)

Decay

Time until the volume decreases from the maximum value and becomes constant: 0 to 127 (faster as the value increases)

Sustain

Volume when extending the sound: 0 to 127 (louder as the value increases)

Release

Time until volume decreases to 0: 0 to 127 (faster as the value increases)
・When the release is set to 0, the playback sound cannot be stopped with BGMSTOP, but it can be forcibly stopped with the SNDSTOP command.

Array

A 1D array containing waveforms
・One element is treated as one signed 16-bit sample.

ReferencePitch

The note number of the pitch of the defined waveform

・The default is 69 ("O4A": A of octave 4).

LoopStart

The index of the top position of the loop of the waveform (with offset)

・0, if not specifiied.

LoopEnd

The index of the loop end position of the waveform (with offset)

・If not specified, it'll be the end of the array.

SampleFrequency

Waveform sample frequency (in Hz): 1 to 96000

・The default is 28160.

Offset

The index of the reference start position of the array

・0, if not specified.

BEEPLoopFlag

Specify whether to loop when playing waveform in BEEP

・0, if not specified (does not loop).

Example

DIM W[2048]
WAVSETA 224,127,0,0,127,W,69,1024,2047,44100,0,#false
BGMPLAY "@224O4A1" 

BGMCHK [TrackNumber] OUT Variable

Return the music playback status of the specified track

Argument

TrackNumber

Number of the track whose playback status is to be acquired: 0 to 15

・0, if not specified.

Return Value

0: Not Playing
1: Playing

Example

R=BGMCHK(1)
PRINT R

CHKMML MMLString OUT Variable

Return whether the contents of the MML string can be correctly interpreted as MML

Argument

MMLString

Command string

Return Value

-1: Normal
0: Error (string position that caused an interpretation error)

Example

R=CHKMML("T120O4L4CC8D8EE8F8GA8G8E2")
PRINT R

TALKCHK OUT Variable

Check the speech synthesis status

Return Value

FALSE=Stopped, TRUE=Playing

Example

RET=TALKCHK()