Controlling Audio library with Accelerometer.

Status
Not open for further replies.

Waterme11on

Active member
Hey there,

Just wondering if anyone could help me out with controlling parameters in the audio library with the motion sensors on the prop shield.
For example i'd like to open and close a filter depending on the force applied to any accelerometer axis, or change the pitch of a waveform with the overall orientation.

I have all the hardware setup and working (prop shield & teensy with a speaker) but I just need help with the coding.
I watched the audio shield workshop tutorial and It doesn't really cover adding custom controls as the buttons and knobs are already set up.

I imagine I could take the orientation code from the NXPMotionsense and fuse it with code from the audio design tool?
I'm a pretty big noob to coding unfortunately so I have no idea how I would do that.
Cheers.
 
This one is a tricky problem because it's really hard to visulise what paramater change will do and what size the steps should be, should it be 1, 0.0001, some sort of curve?

What you are going to be doing is redefining inputs to say things like
setHighpass(0, ReadFromAccelXAxis, 0.5);

Suggestion is to break it into chunks:
Getting a sound you like
Controlling that sound by pots, buttons and serial commands
Parsing your IMU data to get from rotation and motion into 'shake' or 'isUpsideDown' - can be handy to make a unit with a display for this sort of thing so you can move untethered and read what numbers given motions get.
Mapping outputs from your parseing code (say in degrees of angle) into values in your audio generator (say oscillator frequency). You must ensure that you don't get signal levels even slightly over one (produces static due math overflows), or feed an impossible number to the audio functions (negative frequency)

Lot of fairly complex steps, and a lot of art. Being reasonably good at math helps when you need to map between linear, sine and exponential curves. This is why I'm not aware of any 'example' that is just pick up and play since things tend to be very basic 'test if z axis is positive or negative' or very complex projects with lots of 'magic it just works' numbers in.

If you haven't played with sound generation much suggest a PC based package may be good to get a handle an what does what in the world of sound, and how to make controls with useful number ranges. I've used supercollider, and it worked but suspect there are better tools around.
 
Last edited:
Status
Not open for further replies.
Back
Top