[LAD] how to store deferred events in a real time audio app?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-audio-dev@...>
Date: Tuesday, December 20, 2011 - 1:10 am

--20cf305640cf296c9104b47bba06
Content-Type: text/plain; charset=ISO-8859-1

Hi, I'm sure others have tackled this and have some wisdom to share. My
project is principally a monosynth step sequencer. This is nice an simple
to do in real time because resolution is very limited and there can be only
one note per track. So step sequenced note data is stored in simple
multi-dimensional arrays, making reading and writing very easy, and
messaging simple between audio and gui threads.

However, I would like to add the ability for the user to send a message and
have it get executed later, where later gets figured out by the engine ( ie
on the top of the next 8 bar phrase ). To do this, I need some way of
storing deferred events and having the engine check on each step whether
there were any deferred events stored for 'now'. I can think of a few ways
to do this, and all of them raise red flags for a real time thread.

- I could use a hash table, hashed by time, with a linked list of all the
events for that time. The engine looks up the current time and gets all the
events. I don't know much about hashing so I'd prob just use Boost, is that
a bad idea?

- I could make a linked list of all deferred events and iterate through
them checking if time is now. There wouldn't be any hashing, but maybe this
list would be really big.

Anyone have any suggestions for how to safely do the above or some better
alternative?

thanks!
iain

--20cf305640cf296c9104b47bba06
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi, I'm sure others have tackled this and have some wisdom to shar=
e. My project is principally a monosynth step sequencer. This is nice an si=
mple to do in real time because resolution is very limited and there can be=
only one note per track. So step sequenced note data is stored in simple m=
ulti-dimensional arrays, making reading and writing very easy, and messagin=
g simple between audio and gui threads.
However, I would like to add the ability for the user t=
o send a message and have it get executed later, where later gets figured o=
ut by the engine ( ie on the top of the next 8 bar phrase ). To do this, I =
need some way of storing deferred events and having the engine check on eac=
h step whether there were any deferred events stored for 'now'. I c=
an think of a few ways to do this, and all of them raise red flags for a re=
al time thread.
- I could use a hash table, hashed by time, with =
a linked list of all the events for that time. The engine looks up the curr=
ent time and gets all the events. I don't know much about hashing so I&=
#39;d prob just use Boost, is that a bad idea?
- I could make a linked list of all deferred events and=
iterate through them checking if time is now. There wouldn't be any ha=
shing, but maybe this list would be really big.=A0
Anyone have any suggestions for how to safely do the above or some better a=
lternative?thanks!iain

--20cf305640cf296c9104b47bba06--

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAD] how to store deferred events in a real time audio app?, Iain Duncan, (Tue Dec 20, 1:10 am)