|
| | ~AudioEngine () |
| | Destructor of the AudioEngine. More...
|
| |
| void | lock (const char *file, unsigned int line, const char *function) |
| | Mutex locking of the AudioEngine. More...
|
| |
| bool | try_lock (const char *file, unsigned int line, const char *function) |
| | Mutex locking of the AudioEngine. More...
|
| |
| bool | try_lock_for (std::chrono::microseconds duration, const char *file, unsigned int line, const char *function) |
| | Mutex locking of the AudioEngine. More...
|
| |
| void | unlock () |
| | Mutex unlocking of the AudioEngine. More...
|
| |
| void | assertLocked () |
| | Assert that the calling thread is the current holder of the AudioEngine lock. More...
|
| |
| Sampler * | get_sampler () |
| |
| Synth * | get_synth () |
| |
| float | getElapsedTime () const |
| |
| void | calculateElapsedTime (unsigned sampleRate, unsigned long nFrame, int nResolution) |
| | Calculates the elapsed time for an arbitrary position. More...
|
| |
| void | updateElapsedTime (unsigned bufferSize, unsigned sampleRate) |
| | Increments m_fElapsedTime at the end of a process cycle. More...
|
| |
| void | locate (unsigned long nFrame) |
| | Relocate using the audio driver and update the m_fElapsedTime. More...
|
| |
| | ~Object () |
| | destructor More...
|
| |
| | Object (const Object &obj) |
| | copy constructor More...
|
| |
| | Object (const char *class_name) |
| | constructor More...
|
| |
| const char * | class_name () const |
| | return the class name More...
|
| |
| virtual QString | toQString (const QString &sPrefix, bool bShort=true) const |
| | Formatted string version for debugging purposes. More...
|
| |
| void | Print (bool bShort=true) const |
| | Prints content of toQString() via DEBUGLOG. More...
|
| |
Audio Engine main class (Singleton).
It serves as a container for the Sampler and Synth stored in the __sampler and __synth member objects and provides a mutex __engine_mutex enabling the user to synchronize the access of the Song object and the AudioEngine itself. lock() and try_lock() can be called by a thread to lock the engine and unlock() to make it accessible for other threads once again.
| void calculateElapsedTime |
( |
unsigned |
sampleRate, |
|
|
unsigned long |
nFrame, |
|
|
int |
nResolution |
|
) |
| |
Calculates the elapsed time for an arbitrary position.
After locating the transport position to nFrame the function calculates the amount of time required to reach the position during playback. If the Timeline is activated, it will take all markers and the resulting tempo changes into account.
Right now the tempo in the region before the first marker is undefined. In order to make reproducible estimates of the elapsed time, this function assume it to have the same BPM as the first marker.
- Parameters
-
| sampleRate | Temporal resolution used by the sound card in frames per second. |
| nFrame | Next transport position in frames. |
| nResolution | Resolution of the Song (number of ticks per quarter). |
| void lock |
( |
const char * |
file, |
|
|
unsigned int |
line, |
|
|
const char * |
function |
|
) |
| |
Mutex locking of the AudioEngine.
Lock the AudioEngine for exclusive access by this thread.
The documentation below may serve as a guide for future implementations. At the moment the logging of the locking is not supported yet and the arguments will be just stored in the __locker variable, which itself won't be ever used.
Easy usage: Use the RIGHT_HERE macro like this...
#define RIGHT_HERE
Macro intended to be used for the logging of the locking of the H2Core::AudioEngine.
Definition: AudioEngine.h:46
static AudioEngine * get_instance()
Definition: AudioEngine.h:77
void lock(const char *file, unsigned int line, const char *function)
Mutex locking of the AudioEngine.
Definition: AudioEngine.cpp:98
More complex usage: The parameters file and function need to be pointers to null-terminated strings that are persistent for the entire session. This does not include the return value of std::string::c_str(), or QString::toLocal8Bit().data().
Tracing the locks: Enable the Logger::AELockTracing logging level. When you do, there will be a performance penalty because the strings will be converted to a QString. At the moment, you'll have to do that with your debugger.
Notes: The order of the parameters match GCC's implementation of the assert() macros.
- Parameters
-
| file | File the locking occurs in. |
| line | Line of the file the locking occurs in. |
| function | Function the locking occurs in. |
Time in seconds since the beginning of the Song.
In Hydrogen the current transport position is not measured in time but in past ticks. Whenever transport is passing a BPM marker on the Timeline, the tick size and effectively also time will be rescaled. To nevertheless show the correct time elapsed since the beginning of the Song, this variable will be used.
At the end of each transport cycle updateElapsedTime() will be used to increment it (its smallest resolution is thus controlled by the buffer size). If, instead, a relocation was triggered by the user or an external transport control (e.g. JACK server), calculateElapsedTime() will be used to determine the time anew.
If loop transport is enabled #Song::__is_loop_enabled, the elapsed time will increase constantly. However, if relocation did happen, only the time relative to the beginning of the Song will be calculated irrespective of the number of loops played so far.
Retrieved using getElapsedTime().