Function index

Every name of synths.js and synths, by area, one line each: the JavaScript spelling, then the Python one. The link under each heading goes to the page that explains it, with programs to run.

In a pictures.js scene these are ready, with nothing to import. A Pyctures scene starts with from synths import *. Either spelling works in both languages.

Game sounds

Explained in Game sounds.

JavaScriptPythonWhat it does
playSound(name, volume, { pitch, pan, length })play_sound(name, volume, pitch=, pan=, length=)Plays a ready-made game sound: "coin", "jump", "laser" …
soundNames()sound_names()The list of game sounds

Notes and tunes

Explained in Notes, chords and tunes.

JavaScriptPythonWhat it does
playNote(note, length, volume)play_note(note, length, volume)Plays a note, a list of notes or a chord by name, now. Half a second unless you say
playNotes(notes, step, { repeat, volume, hold })play_notes(notes, step, repeat=, volume=, hold=)Plays a tune written as text or as a list. Gives back the tune, which has stop()
note(note, length)note(note, length)The next note of a tune written a line at a time: it begins where the last one ended
chord(name, length)chord(name, length)The next thing in the line is a chord
rest(length)rest(length)A silence in the line
loopNotes(() => { … })with loop_notes():A section of lines that goes round until its stop(). A number first is how many times
startLines()start_lines()Begins every line again from now
noteNumber(note)note_number(note)A note as a number: "A4" is 69, and 60 is middle C
setTempo(beatsAMinute)set_tempo(beats_a_minute)Sets the tempo. Beat 0 is the moment you call it
beats(n)beats(n)How many seconds n beats last
beat()beat()Which beat it is now, with its fraction
soundTime()sound_time()The sound clock, in seconds

Synths

Explained in Synths and their settings.

JavaScriptPythonWhat it does
makeSynth(name, { settings })make_synth(name, settings=)Makes a synth: a ready-made one by name, a changed one, or one from settings alone
synthNames()synth_names()The list of ready-made synths
settingNames()setting_names()The list of every setting
mainSynth()main_synth()The synth that playNote and note play
soundOutput()sound_output()All the sound together, for a scope or a meter

What a synth has. lead is one you made.

JavaScriptPythonWhat it does
lead.play(note, length, volume)lead.play(note, length, volume)A note, a chord, or the synth's own note
lead.start(note)lead.start(note)A note that stays. It has stop(), slideTo(note, seconds) (slide_to), vibrato(), pitch, volume and pan
lead.play(note, length, { glide, bend, slide, vibrato })lead.play(note, length, glide=, bend=, slide=, vibrato=)A note whose pitch moves: a slide in, a scoop, a fall, a vibrato. In play, start and playNote, not in a tune from playNotes
lead.noteOn(note, velocity, { at }), lead.noteOff(note, { at })lead.note_on(note, velocity, at=), lead.note_off(note, at=)A key down and up, now or at an exact time on the sound clock
lead.tranceGate = "x.x.xx.x", lead.setTranceGate(pattern, { rate, depth, smooth, swing, stereo, sends })lead.trance_gate = "x.x.xx.x", lead.set_trance_gate(pattern, rate=, …)A trance gate: the sound chopped in a pattern of steps, in time. tranceGateStep() is the step sounding
lead.arpPattern = "trance"lead.arp_pattern = "trance"A pattern of its own for every arpeggio of the synth. arpStep() is the step sounding
lead.stop()lead.stop()Lets go of every note, or of the one named
lead.playNotes(notes, step)lead.play_notes(notes, step)A tune on this synth
lead.note(…), lead.chord(…), lead.rest(…)the sameThis synth's own line
lead.startLine()lead.start_line()Begins this synth's line again from now
lead.arp(chord, length, { step, octaves, gate, pattern })lead.arp(chord, length, step=, octaves=, gate=, pattern=)A chord as an arpeggio: fast, or with step each note struck in time with the tempo
lead.startArp(chord, { step, pattern })lead.start_arp(chord, step=, pattern=)An arpeggio that stays. It has change(chord) and stop(), and its gate, octaves, swing, accent, pattern, order, step and speed change as it plays
lead.cutoff = 800lead.cutoff = 800Any setting, as a property
lead.set({ … }, { glide })lead.set(…, glide=)Changes several settings, or slides there
lead.get(name), lead.describe(name)the sameA setting by name, and its range, unit and kind
lead.macro = [ … ]lead.macro = [ … ]A step macro
lead.samples(), lead.level(), lead.notes()the sameWhat it is doing now: its wave, how loud, the notes sounding. A frame late in Python
lead.sample = loadSample(file)lead.sample = load_sample(file)A recording for its wave
lead.voice = "robot"lead.voice = "robot"A voice changer on everything it plays
lead.record(seconds)lead.record(seconds)Records this synth alone
lead.playFromMidi(), lead.learn(setting), lead.mapMidi(number, setting), lead.sendToMidi()lead.play_from_midi(), lead.learn(setting), lead.map_midi(number, setting), lead.send_to_midi()MIDI: a keyboard plays it, a knob turns a setting, what it plays is sent out
lead.remove()lead.remove()Finished with it

Chip sounds and arpeggios

Explained in Chip sounds and arpeggios.

JavaScriptPythonWhat it does
playArp(chord, length, { speed, order })play_arp(chord, length, speed=, order=)A chord played one note at a time, very fast, on one voice. With step it is in time with the tempo
startArp(chord)start_arp(chord)One that stays until its stop(); change(chord) moves it to another chord

Samples

Explained in Samples.

JavaScriptPythonWhat it does
loadSample(file, { loop, note })load_sample(file, loop=, note=)A recorded sound from a file, as a synth
makeSynth({ sample: file, note })make_synth(sample=file, note=)A synth whose wave is a recording
loadSamples(files, { kit, crossfade, release })load_samples(files, kit=, crossfade=, release=)Several recordings as one instrument, each playing the keys near its note. piano.zones() reads them back
lead.samples = files, lead.setSamples(files, { … })lead.samples = files, lead.set_samples(files, …)The same on a synth you made

Your voice

Explained in Your voice. Not connected in Circuitry's own preview yet.

JavaScriptPythonWhat it does
useMicrophone()use_microphone()The microphone, as a synth whose sound comes in. Nothing is heard until its listen()
mic.voice = "robot"mic.voice = "robot"A voice: robot, chipmunk, monster, cave, telephone, alien, whisper, or "none"
mic.listen(), mic.mute()the sameHear yourself, and stop. Wear headphones
mic.pitch, mic.ring, mic.comb, mic.gain, mic.gatethe sameIts own settings, beside every setting a synth has
mic.state, mic.whenReady()mic.state, mic.on_ready(fn)"on", or why there is no microphone
voiceNames()voice_names()The list of voices
stopMicrophone()stop_microphone()Lets the microphone go

Recording

Explained in Recording.

JavaScriptPythonWhat it does
recordSound(seconds, { effects })record_sound(seconds, effects=)Records the microphone. Gives back the take at once: a sample, with done, seconds, onDone(fn) (on_done) and soundLike(mic) (sound_like)
startRecording({ max })start_recording(max=)Records until stopRecording(), or for 30 seconds
stopRecording()stop_recording()Ends the recording that is being made
recordOutput(seconds)record_output(seconds)Records everything the program plays, in stereo
saveSound(take, name)save_sound(take, name)Saves a recording or a sample as a WAV file

Songs

Explained in Songs.

JavaScriptPythonWhat it does
playSong(file, { repeat, volume, raw, patches })play_song(file, repeat=, volume=, raw=, patches=)Plays a .mod, an .xm or a song of synths' own. Gives back the song: pause(), resume(), seek(part, row), volume, stop()
song.mute(channel), song.unmute(), song.solo(channel)the sameSilences a channel, brings them back, hears one alone. Channels count from 0
song.loopPattern()song.loop_pattern()Stays on the pattern that is playing; false carries on
song.positionsong.positionWhere the song is: its state, pattern, row and tempo
song.channel(n).level()the sameOne channel's level, and its samples() and notes()
song.channel(n).volume, .pan, .reverb, .echothe sameThe mix: a channel's fader, its place from left to right, and how much of it goes to the reverb and the echo
song.loop(from, to)song.loop(from, to)A part of the song goes round; null (None) runs on
song.replace(edited)song.replace(edited)An edited song in the place of the one playing
stopSong()stop_song()Stops the song that is playing

MIDI

Explained in MIDI keyboards and knobs. Not connected in Circuitry's own preview yet.

JavaScriptPythonWhat it does
onMidiNote(fn)on_midi_note(fn)Calls fn(note, velocity, channel) for each key. In a scene, a function of your own with this name is called
onMidiNoteOff(fn)on_midi_note_off(fn)Calls fn(note, channel) when a key comes up
onMidiControl(fn)on_midi_control(fn)Calls fn(number, value, channel) when a knob, a slider or a pedal moves
onMidi(fn)on_midi(fn)Calls fn(message) with everything that arrives
onMidiDevices(fn)on_midi_devices(fn)Calls fn(devices) when the devices are known, and when one comes or goes
midiDevices()midi_devices()inputs, outputs and available, now
useMidiInput(name)use_midi_input(name)Listens to that device alone
useMidiOutput(name)use_midi_output(name)Sends to that device
midiInput(), lead.midiInput()midi_input(), lead.midi_input()What the program, or one synth, listens to, as something a control is tied to: its "device" and "channel"
midiOutput(), lead.midiOutput()midi_output(), lead.midi_output()The same for what is sent
sendMidiNote(note, velocity, { length, channel })send_midi_note(note, velocity, length=, channel=)Sends a note, a chord or a list of notes
sendMidiNoteOff(note)send_midi_note_off(note)Lets go of a note that was sent to be held
sendMidiControl(number, value)send_midi_control(number, value)Turns a knob on the other device: value is 0 to 1
sendMidiBend(amount)send_midi_bend(amount)The pitch wheel, -1 to 1
sendMidiProgram(number)send_midi_program(number)Chooses a sound on the other device
sendMidiClock()send_midi_clock()Sends the beat, in time with setTempo; false stops it
sendMidi(bytes)send_midi(bytes)Any message, as its bytes
receiveMidi(message)receive_midi(message)Hands the program a message as a keyboard would, for trying a scene with none
stopMidi()stop_midi()Stops everything MIDI is doing

Effects and volume

Explained in Effects and Volume, mute and stop.

JavaScriptPythonWhat it does
setEffects({ echoTime, echoLevel, reverbType, reverbSize, reverbLevel, … })set_effects(echo_time=, echo_level=, reverb_type=, reverb_size=, reverb_level=, …)Shapes the echo, the reverb (and which kind it is) and the chorus that all synths share
setVolume(volume)set_volume(volume)How loud everything is. 1 is normal
muteSound()mute_sound()Silence
unmuteSound()unmute_sound()Brings the sound back
stopSound()stop_sound()Stops everything that is sounding or waiting to sound
soundButton(corner)sound_button(corner)A speaker on the scene that switches its sound off and on. The M key does the same
askAboutSound(title)ask_about_sound(title)For a demo: a card that asks "Play with sound" or "Play without sound" before anything is heard
soundIsOn()sound_is_on()Whether the scene's sound is switched on
setSoundBuffer("large")set_sound_buffer("large")How much sound is made at a time, for a page that clicks: "small", "medium", "large", "auto" or a number of frames
soundBuffer()sound_buffer()What it is now: frames, delay, thread, underruns and setting

When a sound starts

Everything that makes a sound takes one of these. Explained in When things start.

JavaScriptPythonWhen
{ after: 0.5 }after=0.5That long from now: seconds, or a note length by name
{ at: soundTime() + 2 }at=sound_time() + 2At a time on the sound clock
{ beat: 8 }beat=8On that beat

The names in the other library only

  • chordNotes("Cm7") (chord_notes) gives a chord's notes as numbers. It is in synths.js when imported on a page of your own, and in synths; a pictures.js scene is not given it.
  • renderSound, createPlayer and createSound are for a page or an app of your own: see Outside Circuitry.
  • await packSong(bytes) turns a song file of any kind into the engine's small packed form, which playSong plays. It is in synths.js when imported on a page of your own, for an editor that keeps a song after importing it.