synthclone  0.3.0
synthclone::Sampler Class Referenceabstract

Component capable of capturing and playing back audio. More...

#include <synthclone/sampler.h>

Inheritance diagram for synthclone::Sampler:
Collaboration diagram for synthclone::Sampler:

Signals

void jobAborted ()
 Emitted when a job has been aborted. More...
 
void jobCompleted ()
 Emitted when a job finishes. More...
 
void jobError (const QString &message)
 Emitted when a job cannot be completed due to an error. More...
 
- Signals inherited from synthclone::Component
void nameChanged (const QString &name)
 Emitted when the Component name is changed. More...
 
void progressChanged (float progress)
 Emitted by the Component to indicate progress in whatever operation the Component is performing. More...
 
void statusChanged (const QString &status)
 Emitted when the Component object's status changes. More...
 

Public Member Functions

virtual void abortJob ()=0
 Aborts the current job. More...
 
virtual void startJob (const SamplerJob &job, SampleStream &stream)=0
 Starts a new job. More...
 
- Public Member Functions inherited from synthclone::Component
QString getName () const
 Gets the Component name. More...
 

Protected Member Functions

 Sampler (const QString &name, QObject *parent=0)
 Constructs a new Sampler. More...
 
virtual ~Sampler ()
 
- Protected Member Functions inherited from synthclone::Component
 Component (const QString &name, QObject *parent=0)
 Constructs a new Component object. More...
 
virtual ~Component ()
 Destroys a Component object. More...
 

Additional Inherited Members

- Public Slots inherited from synthclone::Component
void setName (const QString &name)
 Sets the name of this Component. More...
 

Detailed Description

Component capable of capturing and playing back audio.

Constructor & Destructor Documentation

◆ Sampler()

synthclone::Sampler::Sampler ( const QString &  name,
QObject *  parent = 0 
)
explicitprotected

Constructs a new Sampler.

This constructor cannot be called directly; instead, subclasses should call this constructor in their constructors.

Parameters
nameThe initial name for the sampler.
parentThe parent object of the sampler.

◆ ~Sampler()

virtual synthclone::Sampler::~Sampler ( )
protectedvirtual

Member Function Documentation

◆ abortJob()

virtual void synthclone::Sampler::abortJob ( )
pure virtual

Aborts the current job.

It's possible for this method to be called before the session reflects that the current job is done, but after the Sampler has finished the current job. In that case, this method should do nothing.

See also
startJob()

◆ jobAborted

void synthclone::Sampler::jobAborted ( )
signal

Emitted when a job has been aborted.

◆ jobCompleted

void synthclone::Sampler::jobCompleted ( )
signal

Emitted when a job finishes.

◆ jobError

void synthclone::Sampler::jobError ( const QString &  message)
signal

Emitted when a job cannot be completed due to an error.

Parameters
messageThe error message.

◆ startJob()

virtual void synthclone::Sampler::startJob ( const SamplerJob job,
SampleStream stream 
)
pure virtual

Starts a new job.

Jobs should be run asynchronously, and should be able to be aborted within a reasonable time interval. How the job is handled depends on the job type.

If the job's type is:

... then:

  1. Play the given audio.
  2. Use the progressChanged() and statusChanged() signals to indicate progress.
  3. When playing is complete, emit a jobCompleted() signal.

If an error occurs during the playing process:

  1. Stop playing the sample.
  2. Emit a jobError() signal.

If abort() is called during the playing process:

  1. Stop playing the sample.
  2. Emit a jobAborted() signal.

If the job's type is:

... then:

  1. Send a MIDI control message on the given MIDI channel for each control item that's set to a specific value.
  2. Send a MIDI note on message on the given MIDI channel for the given note and velocity values.
  3. If the channel pressure value is set, send a MIDI channel pressure message on the given MIDI channel with the given channel pressure value.
  4. If the aftertouch value is set, send a MIDI aftertouch message on the given MIDI channel with the given aftertouch value.
  5. If there is any known latency for the MIDI port and/or audio ports, then wait that time before sampling. Note that any time spent sending the MIDI aftertouch and/or control pressure messages should be subtracted from the wait time.
  6. Retrieve data until Zone::getSampleTime() has passed. Use the progressChanged() and statusChanged() signals to indicate progress.
  7. After sampling is complete, send a MIDI note off event on the given MIDI channel.
  8. Wait the amount of time specified by Zone::getReleaseTime(). Use the progressChanged() and statusChanged() signals to indicate progress.
  9. Send an all sound off event on the given channel.
  10. Send a reset all controllers event on the given channel.
  11. Make sure that all of the audio data has been written to the given stream. Whether or not this is done asynchronously or after all data is retrieved is up to the sampler implementation.
  12. When sampling is complete, emit the jobCompleted() signal.

If an error occurs during the sampling process:

  1. If MIDI messages have been sent, execute steps 7-10 above (if possible).
  2. Emit a jobError() signal.

If abort() is called during this operation:

  1. If MIDI messages have been sent, execute steps 7-10 above (if possible).
  2. Emit a jobAborted() signal.
Parameters
jobThe job to be run.
streamA stream object. If the job type is: ... then the object will be a SampleInputStream. If the job type is: ... then the object will be a SampleOutputStream. Use qobject_cast to cast the object to the appropriate type.

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