Yet Another Synthesizer Engine
 
Loading...
Searching...
No Matches
yase::Sequencer Class Reference

#include <sequencer.hh>

+ Inheritance diagram for yase::Sequencer:
+ Collaboration diagram for yase::Sequencer:

Detailed Description

A general purpose sequencers.

Sequences can be built in two ways.

  1. You can insert MIDI events or rests using to build up an arbitrary sequence.
  2. You can allocate a sequence of a given size, and set events for each step. A sequencer requires a Clock input.
Parameters
[input]clock Should be wired to the "signal" output of a Clock object.
[input]duration The fraction of the clock period between 0 and 1 to hold a note down before releasing it.

Public Member Functions

void init ()
 
void update ()
 
void keydown (const Event &e)
 
void keyup (const Event &e)
 
void insert_rest ()
 Insert a rest onto the end of the sequence.
 
void reset ()
 Reset the sequence counter to the beginning of the sequence.
 
void record ()
 Put the sequencer into record mode so it will respond to calls to keydown()
 
void stop ()
 Stop the sequencer playing.
 
void play ()
 
void clear ()
 Clear the sequence, erasing all events.
 
void allocate (int n)
 
void set (int index, int note)
 
bool is_rest (int index)
 
void rest (int index)
 
void decrease_duration (double amount)
 
void increase_duration (double amount)
 
bool is_playing ()
 Returns true if the sequencer is playing (because of a previous call to play())
 
- Public Member Functions inherited from yase::Module
virtual void init ()=0
 
virtual void update ()=0
 
int add_input (string name)
 
int add_output (string name)
 
int get_input_index (string name) const
 
string get_input_name (int index) const
 
string get_output_name (int index) const
 
int get_output_index (string name) const
 
void set_input (string name, double value)
 
void set_input (int index, double value)
 
double get_input (int index) const
 
double get_input (string name) const
 
double get_output (string name) const
 
double get_output (int index) const
 
void set_output (int index, double value)
 
void copy_inputs (const Module &source)
 
void copy_outputs (Module &destination) const
 
void configure (std::vector< std::tuple< string, double > > assignments)
 
int num_inputs () const
 
int num_outputs () const
 
void emit (Event e)
 
void set_ts (double s)
 
double get_ts ()
 

Member Function Documentation

◆ allocate()

void yase::Sequencer::allocate ( int  n)

Allocate a sequence of n steps, and initialize all of them to be rests.

Parameters
nThe length of the sequence

◆ decrease_duration()

void yase::Sequencer::decrease_duration ( double  amount)

Increase the duration, as a fraction of the period, of time between a MIDI_KEYDOWN and a MIDI_KEYUP event. Does bounds checking. Note that the default duration is 0.5.

Parameters
amountThe amount.

◆ increase_duration()

void yase::Sequencer::increase_duration ( double  amount)

Decrease the duration, as a fraction of the period, of time between a MIDI_KEYDOWN and a MIDI_KEYUP event. Does bounds checking. Note that the default duration is 0.5.

Parameters
amountThe amount.

◆ init()

void yase::Sequencer::init ( )
virtual

This method should be overridden by derived classes. It will usually be called once, after all modules and connections objects have been added to a synthesizer, but before the synthesizer starts running.

Implements yase::Module.

◆ is_rest()

bool yase::Sequencer::is_rest ( int  index)

Return true of the sequence at the given index is a rest

Parameters
indexThe given index

◆ keydown()

void yase::Sequencer::keydown ( const Event e)

Respond to a keydown Event by adding the event to the end of a sequence. Requires the sequencer to be in "recordning" mode via a previous call to the Sequencer method record()

Parameters
eA MIDI_KEYDOWN Event, perhaps emitted by a Midi module and routed by a Container listen handler

◆ keyup()

void yase::Sequencer::keyup ( const Event e)

Not used

Parameters
eThe keyup event

◆ play()

void yase::Sequencer::play ( )

Play the sequencer. It will emit MIDI events that look just like MIDI events coming from a Midi device. So if you, for example, have a midi keyboard set up with Container listen() handlers, it will also "see" the sequencer events. Note that normally a sequencer needs to be added to a Container to work.

◆ rest()

void yase::Sequencer::rest ( int  index)

Set the sequence at the given index to a rest

Parameters
indexThe given index

◆ set()

void yase::Sequencer::set ( int  index,
int  note 
)

Set the a sequence event at the given index to play the given note

Parameters
indexThe index of the event
noteThe MIDI id ot eh note to play

◆ update()

void yase::Sequencer::update ( )
virtual

This method should be overridden by derived classes. It will be called repeatedly by a synthesizer at a frequency determined by SAMPLE_RATE.

Implements yase::Module.


The documentation for this class was generated from the following files: