OpenShot Audio Library | OpenShotAudio: juce::MultiTimer Class Reference

OpenShot Audio Library | OpenShotAudio 1.0.0

Loading...
Searching...
No Matches
juce::MultiTimer Class Referenceabstract

`#include <juce_MultiTimer.h>`

## Public Member Functions
virtual | ~MultiTimer ()
virtual void | timerCallback (int timerID)=0
void | startTimer (int timerID, int intervalInMilliseconds) noexcept
void | stopTimer (int timerID) noexcept
bool | isTimerRunning (int timerID) const noexcept
int | getTimerInterval (int timerID) const noexcept

## Protected Member Functions
| MultiTimer () noexcept
| MultiTimer (const MultiTimer &) noexcept

## Detailed Description

A type of timer class that can run multiple timers with different frequencies, all of which share a single callback.

This class is very similar to the Timer class, but allows you run multiple separate timers, where each one has a unique ID number. The methods in this class are exactly equivalent to those in Timer, but with the addition of this ID number.

To use it, you need to create a subclass of MultiTimer, implementing the timerCallback() method. Then you can start timers with startTimer(), and each time the callback is triggered, it passes in the ID of the timer that caused it.

See also
  Timer

Definition at line 45 of file juce_MultiTimer.h.

## Constructor & Destructor Documentation

## ◆ MultiTimer() [1/2]

juce::MultiTimer::MultiTimer | ( |  | ) |
| protectednoexcept

Creates a MultiTimer.

When created, no timers are running, so use startTimer() to start things off.

Definition at line 45 of file juce_MultiTimer.cpp.

Referenced by MultiTimer(), and timerCallback().

## ◆ MultiTimer() [2/2]

juce::MultiTimer::MultiTimer | ( | const MultiTimer & |  | ) |
| protectednoexcept

Creates a copy of another timer.

Note that this timer will not contain any running timers, even if the one you're copying from was running.

Definition at line 46 of file juce_MultiTimer.cpp.

## ◆ ~MultiTimer()

juce::MultiTimer::~MultiTimer | ( |  | ) |
| virtual

Destructor.

Definition at line 48 of file juce_MultiTimer.cpp.

## Member Function Documentation

## ◆ getTimerInterval()

int juce::MultiTimer::getTimerInterval | ( | int | timerID | ) | const
| noexcept

Returns the interval for a specified timer ID.

Returns
  the timer's interval in milliseconds if it's running, or 0 if no timer was running for the ID number specified.

Definition at line 98 of file juce_MultiTimer.cpp.

Referenced by timerCallback().

## ◆ isTimerRunning()

bool juce::MultiTimer::isTimerRunning | ( | int | timerID | ) | const
| noexcept

Checks whether a timer has been started for a specified ID.

Returns
  true if a timer with the given ID is running.

Definition at line 88 of file juce_MultiTimer.cpp.

Referenced by timerCallback().

## ◆ startTimer()

void juce::MultiTimer::startTimer | ( | int | timerID,
|  | int | intervalInMilliseconds )
| noexcept

Starts a timer and sets the length of interval required.

If the timer is already started, this will reset it, so the time between calling this method and the next timer callback will not be less than the interval length passed in.

Parameters

  timerID | a unique Id number that identifies the timer to start. This is the id that will be passed back to the timerCallback() method when this timer is triggered
  intervalInMilliseconds | the interval to use (any values less than 1 will be rounded up to 1)

Definition at line 68 of file juce_MultiTimer.cpp.

Referenced by timerCallback().

## ◆ stopTimer()

void juce::MultiTimer::stopTimer | ( | int | timerID | ) |
| noexcept

Stops a timer.

If a timer has been started with the given ID number, it will be cancelled. No more callbacks will be made for the specified timer after this method returns.

If this is called from a different thread, any callbacks that may be currently executing may be allowed to finish before the method returns.

Definition at line 80 of file juce_MultiTimer.cpp.

Referenced by timerCallback().

## ◆ timerCallback()

virtual void juce::MultiTimer::timerCallback | ( | int | timerID | ) |
| pure virtual

The user-defined callback routine that actually gets called by each of the timers that are running.

It's perfectly ok to call startTimer() or stopTimer() from within this callback to change the subsequent intervals.

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

- juce_MultiTimer.h
- juce_MultiTimer.cpp