Objects used to play back ezScore score data.
Class used for playing back ezScore objects. Users should set an ezScore object to be played, as well as ezInstrument objects specifying sound synthesis for each part. See https://chuck.stanford.edu/smuck/doc/walkthru.html for more information.
ezScorePlayer()
Default constructor, creates an empty ezScorePlayer.
ezScorePlayer(ezScore s)
Create an ezScorePlayer from an ezScore object.
void bpm(float value)
Set the tempo for the ezScorePlayer in BPM (beats per minute). Can be changed dynamically during playback.
float bpm()
Get the tempo for the ezScorePlayer in BPM (beats per minute). Can be changed dynamically during playback.
int isPlaying()
Get the current playback state for the ezScorePlayer. If true, the player is currently playing.
void logPlayback(int value)
Toggle on/off logging of playback events. If true, current note events are logged to the console as they are played.
void loop(int loop)
Set the loop mode. If true, the player will loop back to the start of the score when it reaches the end.
int loop()
Get the loop mode. If true, the player will loop back to the start of the score when it reaches the end.
void pause()
Pause playback of the score.
void play()
Start playback of the score.
dur playhead()
Get the current playhead position for the ezScorePlayer. This represents the current position in the score in ms.
void pos(dur timePosition)
Set the playhead position by absolute time in ms.
void pos(float beatPosition)
Set the playhead position by beat position.
void preview()
Preview the score by playing back using default instruments. Can be used to quickly preview the score without having to set instruments for each part.
void rate(float value)
Set the playback rate for the ezScorePlayer. Defalut value of 1.0. Used to speed up or slow down playback. Negative values play the score in reverse.
float rate()
Get the playback rate for the ezScorePlayer. Defalut value of 1.0. Used to speed up or slow down playback. Negative values play the score in reverse.
void setEnd(float beat)
Set the end position of the score in beats. If the end position is set to -1, the end position will automatically be set to the score's end position.
void setInstrument(int partIndex, ezInstrument instrument)
Set the ezInstrument object to be used for a given part.
void setInstrument(ezInstrument[] insts)
Set the ezInstrument objects to be used for all parts. The array must be the same size as the number of parts in the score.
void setScore(ezScore s)
Set the ezScore object to be played back. If the player is currently playing, it will be stopped first.
void stop()
Stop playback of the score.
void tick(dur value)
Set the tick duration for the ezScorePlayer. This represents the update rate of the player's internal clock.
dur tick()
Get the tick update rate for the ezScorePlayer. This represents the update rate of the player's internal clock.
ezInstrument[] instruments
The ezInstrument objects to be used in playback. Need to set manually for each part.
ezPart[] parts
The ezPart objects in the score. Set automatically when a score is set for the player.
Gain previewGain
Gain object to control volume of the playback in preview mode.
ezScore score
The ezScore object to be played back.
[ top ]
Base class for user-defined instruments to be used for playback in ezScorePlayer. Users should extend this base class to create their own instruments. Users define the behavior of their instrument by overriding the noteOn and noteOff functions.
ezInstrument()
Default constructor for ezInstrument.
void noteOff(ezNote note, int voice)
This function defines behavior that will be executed when a note is released by the ezScorePlayer. This could include calling .keyOff(), etc. or referencing variables of the ezNote. The base class function is empty, and should be overridden by the user.
void noteOn(ezNote note, int voice)
This function defines behavior that will be executed when a note is played by the ezScorePlayer. Typically, this would include setting frequency, gain, calling .keyOn(), etc. by referencing variables of the ezNote. The base class function is empty, and should be overridden by the user.
void setVoices(int n_voices)
Set the number of voices for the instrument if using user-defined signal chain. This tells the ezScorePlayer how many voices to allocate for the instrument. E.g. if you set up 5 SinOscs, you should call setVoices(5) inside your class definition. See ezDefaultInst.ck for an example.
[ top ]
Default ezInstrument that uses a simple signal chain of sine oscillators and envelopes. Used as the instrument for ezScorePlayer's .preview() function. Handles up to 10 simultaneous voices for a given part. Signal chain is: SinOsc[10] => ADSR[10] => Gain => NRev => dac.
ezDefaultInst()
Default constructor for ezDefaultInst.
void noteOff(ezNote note, int voice)
This noteOff() function calls .keyOff() on the envelope. The variable 'voice' determines which oscillator/envelope to use and is passed in by the ezScorePlayer.
void noteOn(ezNote note, int voice)
This noteOn() function uses note.pitch() to set the frequency of the oscillator and note.velocity() to set the gain. It also calls .keyOn() on the envelope. The variable 'voice' determines which oscillator/envelope to use and is passed in by the ezScorePlayer.
Gain bus
Post-envelope bus for gain control of all voices. Gain set to .1 by default.
ADSR[] envs
Array of ADSR amplitude envelopes. Envelopes are set to attack = 4ms, decay = 7000ms, sustain = 0.0, release = 200ms by default.
TriOsc[] oscs
Array of triangle oscillators.
[ top ]
EzInstrument that uses the MidiOut class to send ezNote data as MIDI messages.
ezMidiInst()
Default constructor. Opens MIDI device 0 and sets channel to 0.
ezMidiInst(int device)
Constructor that opens a given MIDI device.
void channel(int channel)
Set the MIDI channel to use.
int channel()
Get the MIDI channel currently in use.
void device(int device)
Set the MIDI device to use.
int device()
Get the MIDI device currently in use.
void flushMIDI()
Flush the MIDI device by sending a noteOn and noteOff message for each MIDI channel and note.
void logOutput(int log)
Set whether to log outgoing note data to the console.
void noteOff(ezNote note, int voice)
This noteOff() function sends a MIDI noteOff message carrying pitch data from incoming ezNotes. Note that here, 'voice' is passed by ezScorePlayer, but is not necessary for this kind of instrument.
void noteOn(ezNote note, int voice)
This noteOn() function sends a MIDI noteOn message carrying pitch and velocity data from incoming ezNotes. Velocity values are scaled from 0.0-1.0 to 0-127. Note that here, 'voice' is passed by ezScorePlayer, but is not necessary for this kind of instrument.
int _channel
No description available
int _device
No description available
int _logOutput
No description available
MidiOut mout
No description available
[ top ]
EzInstrument that uses the OscOut class to send ezNote data as OSC messages.
ezOscInst()
Default constructor. Opens an OSC connection to localhost on port 8888.
ezOscInst(string hostname, int port)
Constructor that opens an OSC connection to a given hostname and port.
void hostname(string hostname)
Set the hostname to use for outgoing OSC messages.
string hostname()
Get the hostname currently in use for outgoing OSC messages.
void logOutput(int log)
Set whether to log outgoing note data to the console.
void noteOff(ezNote note, int voice)
This noteOff() function sends an OSC message carrying pitch data from incoming ezNotes. This function uses the OSC start address '/smuck/noteOff' and adds the pitch data to the message as an 'int' value. Note that here, 'voice' is passed by ezScorePlayer, but is not necessary for this kind of instrument.
void noteOn(ezNote note, int voice)
This noteOn() function sends an OSC message carrying pitch and velocity data from incoming ezNotes. This function uses the OSC start address '/smuck/noteOn' and adds the pitch and velocity data to the message as 'int' values. Note that here, 'voice' is passed by ezScorePlayer, but is not necessary for this kind of instrument.
void port(int port)
Set the port to use for outgoing OSC messages.
int port()
Get the port currently in use for outgoing OSC messages.
string _hostname
No description available
int _logOutput
No description available
int _port
No description available
OscOut xmit
No description available
[ top ]
EzInstrument that sends note data to an external MIDI and/or OSC device. Meant for sending data to external devices/software.
ezExternalInst()
Default constructor for ezExternalInst.
void channel(int channel)
Set the MIDI channel to use.
int channel()
Get the MIDI channel currently in use.
void device(int device)
Set the MIDI device to use.
int device()
Get the MIDI device currently in use.
void flushMIDI()
Flush the MIDI device by sending a noteOn and noteOff message for each MIDI channel and note.
void hostname(string hostname)
Set the OSC hostname to use.
string hostname()
Get the OSC hostname currently in use.
void logOutput(int log)
Set whether to log outgoing note data to the console.
void noteOff(ezNote note, int voice)
Send a noteOff message via MIDI and/or OSC.
void noteOn(ezNote note, int voice)
Send a noteOn message via MIDI and/or OSC.
void port(int port)
Set the OSC port to use.
int port()
Get the OSC port currently in use.
void sendMIDI(int device)
Set the MIDI device to use and enable MIDI output.
void sendOSC(string hostname, int port)
Set the OSC hostname and port to use and enable OSC output.
void useMIDI(int toggle)
Set whether to send note data via MIDI.
void useOSC(int toggle)
Set whether to send note data via OSC.
[ top ]
EzInstrument that uses the FluidSynth chugin to play back ezScore data with FluidSynth SoundFont files. NOTE: using this instrument requires the FluidSynth chugin to be installed. It is not imported by default. If you have the FluidSynth chugin installed, you can import smuck/ezFluidInst.ck to use this class.
ezFluidInst()
Create a new ez-fluidsynth instrument; (hint: use .open() to load a SoundFont file; use .progChange() to set an instrument)
ezFluidInst(string filename)
Create a new ezFluidInst with a specific SoundFont file; program number will default to 0 (Grand Piano)
ezFluidInst(string filename, int instrument)
Create a new ezFluidInst with a specific SoundFont file and instrument program number.
string filename()
Get the SoundFont file currently in use.
void noteOff(ezNote note, int voice)
Send a noteOff message to the FluidSynth instrument.
void noteOn(ezNote note, int voice)
Send a noteOn message to the FluidSynth instrument.
void open(string filename)
Load a SoundFont file to use.
int progChange(int instrument)
Set the instrument program number to use.
int progChange()
Get the instrument program number currently in use.
[ top ]