Where to get global tempo

3 views
Skip to first unread message

Gerald Mwangi

unread,
Apr 27, 2011, 7:58:35 AM4/27/11
to Composite-dev
Hi guys,
Can someone tell me how inside Tritium I have access to the global tempo (say from the Sampler class). I'm on to building a model for a loopengine, with a timestretching component at the core. Right now I'm prototyping an interface for the timestretching component:
A class masking

Thinking about how the Loopengine should be, I think it should share some base class with the class Sampler which contains the means to handle instruments (creating, deleting, get per instrument outs). The only method that differs in both classes is process(), that is the way that short samples and long loops are played.
Cheers,
Gerald

Gabriel M. Beddingfield

unread,
Apr 27, 2011, 8:31:51 AM4/27/11
to compos...@googlegroups.com

Hi Gerald,

On Wednesday, April 27, 2011 06:58:35 am Gerald Mwangi
wrote:


> Hi guys,
> Can someone tell me how inside Tritium I have access to
> the global tempo (say from the Sampler class). I'm on to

We call it the 'Transport', and you access it by calling
Engine::get_transport().

The Transport object (src/Tritium/Tritium/Transport.hpp)
controls the state of the Transport (start, stop, etc.)

You access the current state/position by using
Transport::get_position(). It returns a TransportPosition
struct that is very much like JACK's jack_position_t.

> Thinking about how the Loopengine should be, I think it
> should share some base class with the class Sampler
> which contains the means to handle instruments
> (creating, deleting, get per instrument outs). The only
> method that differs in both classes is process(), that
> is the way that short samples and long loops are played.

That sounds allright... and the Sampler class is in need of
some refactoring, anyway (i.e. the other e-mail that I
sent).

I suggest either setting up an interface (pure virtual
class) that they share and/or a private implementation
class[1] with the shared code.

-gabriel

[1] I.e. everything in src/Tritium/src and not
src/Tritium/Tritium (the public headers)

Gabriel Beddingfield

unread,
Apr 27, 2011, 9:25:32 AM4/27/11
to compos...@googlegroups.com
On Wed, Apr 27, 2011 at 7:31 AM, Gabriel M. Beddingfield
<gabr...@gmail.com> wrote:
> You access the current state/position by using
> Transport::get_position().  It returns a TransportPosition
> struct that is very much like JACK's jack_position_t.

Also, the current TransportPosition is typically passed to each
sub-engine in their process() parameters. E.g. Sampler::Process()
looks like this:

void Sampler::process(
SeqScriptConstIterator beg,
SeqScriptConstIterator end,
const TransportPosition& pos,
uint32_t nFrames
);

Note also that the iterator (beg, end) is the event queue (sequence),
and the events are sorted chronologically (i.e. by frame).

-gabriel

Gerald Mwangi

unread,
Apr 27, 2011, 9:55:12 AM4/27/11
to compos...@googlegroups.com
Hi, is TransportPosition only meant for the current transport position?

Gabriel M. Beddingfield

unread,
Apr 27, 2011, 10:08:33 AM4/27/11
to compos...@googlegroups.com

On Wed, 27 Apr 2011, Gerald Mwangi wrote:

> Hi, is TransportPosition only meant for the current transport position?

Yes.

The intention is that all sound generators will be
sequenced. The master sequencer (or real-time user input)
will tell a sample to play at time X... or for a loop to
start at time Z and be synchronized according to
such-and-such scheme (e.g. resample, time-stretch, or loop
unsynchronized).

With this scheme, all the sound generators really need to
know is the current position for the current process()
cycle... and the frame number when specific events should
happen.

-gabriel

Reply all
Reply to author
Forward
0 new messages