Glitching sound samples with movement | Teensy 3.2 | NEED HELP <3

Status
Not open for further replies.
Hello everyone! :D

I am a multimedia artist, working on my MA thesis in new media art titled A New Natural World.
The plan is to make 7 granular synths or "sound sample glitching machines" controlled by angle sensors.

;) DESCRIPTION TIME: ;)

The installation will consist of 7 vials hanging on a thread from the ceiling, each loaded with one Teensy 3.2 with an SD card reader, one angle sensor, one RGB LED and covered with a lid turned into a speaker. Each Teensy is representing a cell sample - kept frozen in the vials by the preservation institutions - of one endangered animal species, of which the sound sample is continuosly playing through the speaker. The vials hanging on a thread metaphorize how close these animals are to extinction. Vial size = inner diameter 35,4mm, length 115mm.

Every spectator will be able to interact with these vials by bringing them closer to their ears to listen; only that as they do so, the sensor will trigger the granular synthesis and the sound samples will start to glitch, the LED turns red and blinks, signalizing the nearing end of species. As the spectator puts the vials back to the original spot, the vials in time regenerate, the LED turns back to green, and the sound samples start playing normal once again; the ecosystem is balanced for another day.

Underneath the hanging vials, there will be a pile of broken or molten ones alongside with random computer chips, as a reminder of many animal species that have already gone extinct since the start of the Anthropocene, and if we don't stop and learn how to coexist with the natural world, the remaining ones alive will die out too.

The questions are:

1.) Do I need to use audio shield for a desired effect or no? If yes, is there a solution how to make the sound sample freeze or glitch when the vial is moved without using the audio shield? I don't care if the sound isn't the best quality but i would like a real time feedback. Basically it is enough that the sample just gets crunched in some way.
2.) Would anyone have will and time to help me realize this in code? Thank you!

The installation will be exhibited at the Rewire festival organized by Noise Kitchen this september in Prague, Czech republic.
https://www.facebook.com/events/968493720595329/

SKETCH OF THE INSTALLATION

210720503_148324090614183_8004519710249099953_n.jpg

Regards,
Tim.
 
Depends.... :)

I'd suggest to use Teensy 4.1 instead. It as a inbuilt SD reader and "MQS" (Medium qualtiy sound) outputs. Also, any glitching is more easy because it has a) more cpu power and b) the sampling frequency can be changed easyly any time.
It's smaller than a 3.2 + audioshield, too.

Perhaps the inbuilt Flash is large enough to hold the sounds? That would be better than SD, exp when the vials get touched or handled roughly.
 
Hi Tim,
As Frank B already alluded to, your primary concern is that of storage space. To put some figures around this if you use uncompressed PCM (.wav digital sound files) then at 8bit resolution and running at 8Khz sampling frequency you will be able to store~ 30sec of sound data on a Teensy 3.2 (256K Flash). No doubt the cost of each board is a factor in your project. Although the 3.2 does not have the MQS module. It does have a 12bit DAC, which should be able to run at these rates.
Driving a loudspeaker is also a significant consideration. The DAC output on the Teensy 3.2 is only rated at 1mA and if you drive a loudspeaker rated at 16ohm, which would be typical for a tiny little speaker as you have drawn, this will overload the output of the DAC, and probably fry it. It would all depend on how long and how loud!

The advantage of the Audio shield is the headphone amplifier built into the codec on the shield, it is designed to drive such loads and has various protection mechanisms in place to avoid killing the device if you short out the outputs. When working with electronics you soon realise that if it can happen it probably will. "I was only screwing the lid on the vile and the Teensy blew up" You get the idea. I am not aware of the output characteristics of the MQS module in the Teensy 4.1, but often you find the the "MCU", although designed to interface with the outside world far more than a standard microprocessor, still have significant limitations and often need ancillary circuitry to support then (protect them).

What I can tell you is that with the application of some advanced scientific tools, (Knife), you could trim the edges off the Audio shield, leaving the same overall width profile as the Teensy module. This must be done with great care, to ensure that all the copper traces needed for functionality are intact. The edges of the board only contain the I/O and optional RAM, even the SD slot is contained within the inner profile. Using very short interconnect pins can bring down the overall thickness to just a few mm, maybe < 10mm if carefully soldered. Using the SD card on the Audio shield would solve any issues around sound file lengths and the codec would resolve the problem of driving the loudspeaker.

The Teensy 3.2, contains a touch sensor module (not sure about the 4.1). This might well offer you the solution to the 'handling' issue. It would need experimentation. Brief suggestion..... tin foil rings glued to the inside of the vile attached to the TS module, and you may have enough sensitivity to detect, through glass contact with fingers. I have never used this module, but once again getting this to work as a solution would save you any external ancillary sensing circuit. A rather fiddly solution, but hey your an artist.... you can work out it ;)

The LED is probably a no brainer, with a simple series resistor and a high efficiency LED you can get a lot of light output directly from a GPIO (General Purpose Input Output) pin on any Teensy module.

'Glitching' the sound, might be quite simple.. again experimentation needed, but as a simple suggestion modulating on/off the IRQ (Interrupt channel) of the Audio system on the Teensy will probably achieve what is required. It depends on what effect you are looking for. IRQ's are essential for the Audio system and on the Teensy they run in a hierarchical fashion. High priority IRQ getting serviced before any other code such as Touch Sensing. In this way the audio flows continuously without Interruption. However if you temporally disable these IRQs the data will freeze, re-enable and it starts flowing again. IN PRINCIPLE... again experimentation needed.

I hope this gives you a little better understanding of the issues you face, the reality of the electronics and the time involved I promise you budget some time estimate and then * 10.
SEPTEMBER !!!! Good luck! :confused:
 
SEPTEMBER !!!! Good luck!
It's not September, the exhibition starts on 2nd Sept so, essentially it's what is left of August.
Say 10 days. That gives you 3 days for slippage, assuming you work 7 days a week until it's done.
Given that you don't really know what you are doing I would suggest that it is not possible to complete in time.
At the moment you should be designing/writing software, designing/manufacturing/assembling electronics, designing/producing housing/supports then you can put it all together and test.
You think you can do all that in under two weeks?
 
I hope this gives you a little better understanding of the issues you face, the reality of the electronics and the time involved I promise you budget some time estimate and then * 10.
SEPTEMBER !!!! Good luck! :confused:

First of all thank you for a very detailed description of what I am dealing here with aidyw <3 .
I see it will not be an easy thing to do but I am pretty determined to make it work.
However, If it doesn't, then I would pre-glitch a sample and just make a fade between the two as they get moved which I think it will be way easier.

Now unfortunately I won't use the Teensy 4.1, as I already have all 7 of 3.2s, so I need to make it work with these boys.
I am also not the biggest fan of buying the audio shields and then cutting them down to fit, and the vials that I got are the widest I could find :(

This is the list of components that I have/ or have ordered, so let me know what I should change or be carefull of with them.

Speakers: 5W 8Ohm 53mm drivers, with max power supply 6.32V or
3W 8Ohm 40mm, max 4.90V or
1W 8Ohm 40mm with max power supply of 2.83V

Angle sensor

or, Analog Accelerometer

Micro SD reader




For power I would use a 9V 250mAh battery with a reduction circuit out of two resistors to get the 5V output, as I don't want to have cables outside the vials, and the 9V battery is the only battery I could find that fits inside the vial. Here is a photo for size comparison: the vial, angle sensor and accelerometer and LED.

236347219_1024250135045164_164944316223390445_n.jpg
 
You think you can do all that in under two weeks?

Mindset is the most important thing when it comes to projects with super close deadlines, so to answer your question: yes, I do think I can do all that in under two weeks.
I have amazing people that are helping me with circuitry and code, so I am not all alone in this. Moreover, there are some very nice and helpful people on this forum with valuable information.
 
For power I would use a 9V 250mAh battery with a reduction circuit out of two resistors to get the 5V output
Using two resistors as a potential divider to obtain 5v is not a very satisfactory solution. Effectively Teensy will not consume a constant current and will therefore appear as a variable resistance to your potential divider circuit giving rise to a non constant voltage supply to the Teensy.

I don't see why you do not want to have "cables" outside the vials. You are already supporting them by "string". This can be replaced by a similar looking cable which can supply the required voltage.

If you can find a USB cable that you like (a quick search found 5m USB cables) then you can send data to an external computer, or even reprogram the Teensy(s) whilst they are in-place. This latter point would be most useful in development, obviating the need to take apart everything to make modifications to the program.

I hope you can make it work in the timescale as it looks like an interesting display. Bye the way you have just used up 10% of your timeframe.
 
Using two resistors as a potential divider to obtain 5v is not a very satisfactory solution[...] I don't see why you do not want to have "cables" outside the vials. You are already supporting them by "string". This can be replaced by a similar looking cable which can supply the required voltage[...]then you can send data to an external computer, or even reprogram the Teensy(s) whilst they are in-place. I hope you can make it work in the timescale as it looks like an interesting display. Bye the way you have just used up 10% of your timeframe.

Huh, interesting, thank you for pointing that out! I did not know that circuit produces an unreliable 5V output.
Initially, I wanted to keep all the electronic components inside for the means of having it "packaged" and easy-to-install at the place of exhibition,
which now kind of lost it's validity since USB cables really seem like a better choice on many levels.
My concern with cables being outside was purely aesthethic with no conceptual content. Will strongly consider this option with my co-builder.

Hehe, thank you for the dopamine/cortisol-inducing countdown, love it! :D
Just to mention as well, the exhibition is not mandatory, I can pull out at any time.
The real deadline is the defending of my project at the academy which is the second half of September. Still close but more time for fixing errors.

Do you have any reccomendations about which of the proposed speakers I should use?
 
The real deadline is the defending of my project at the academy which is the second half of September.
That's better, more than doubles the timeframe.

Mindset is the most important thing when it comes to projects with super close deadlines
...yes but so is realism. So many projects have failed or been spoilt by having an unrealistic timeframe.

Do you have any reccomendations about which of the proposed speakers I should use?


You could try these. I don't know whether you could drive them directly from the T3.2 DAC or whether an amplifier might be required, but they are cheap enough to buy two (they come in packs of 2 from RS) and give it a try.
I don't know if they will fit inside the vial as I can't see a dimension anywhere.

I would be inclined to use a single RGB led (using just green and red). In the quiescent state you could just have the green led "Breathing" on and off. When the vial gets disturbed you would then go to the flashing RED.
 
That's better, more than doubles the timeframe.

...yes but so is realism. So many projects have failed or been spoilt by having an unrealistic timeframe.


I completely agree with you on the realism, and I am aware of it. I just rather anchor myself in good mindset, as it helps me reach the realistic goals, otherwise I just freak out and do nothing.

You could try these. I don't know whether you could drive them directly from the T3.2 DAC or whether an amplifier might be required, but they are cheap enough to buy two (they come in packs of 2 from RS) and give it a try.
I don't know if they will fit inside the vial as I can't see a dimension anywhere.

Allright I'll give those a try! The vials' inner diameter is 35,4mm, meaning they fit and with extra space around it, they will be easy to make into a lid.

I would be inclined to use a single RGB led (using just green and red). In the quiescent state you could just have the green led "Breathing" on and off. When the vial gets disturbed you would then go to the flashing RED.

The "breathing" like pulsation of the LED is a great idea! I will definitely program it that way. Thank you.
 
As far as vibration/tilt sensing is concerned I would start with 3 tilt sensors (your angle sensor) placing them inclined outwardly to form a pyramid. Set the inclination so that they are just not actuated in the steady state. Wire them in series and you will only have one input to sense.

With experiment you might find that this works for you, or you might find that more differentiation of the type of handling is required, in which case the accelerometer approach could be investigated.
 
You could try these...

I found a similar speaker, which are being sold at a store where I live,
and it also has a bit of 200Hz response, which the RS ones don't. What do you think?

https://www.gme.cz/miniaturni-reproduktor-do-dps-kssg-3108

FO (Hz): 1,250+/-200@1.0V
Rated Input (W): 0.1
Sound Pressure Level (dB): 95+/-3dB(0.1W/10cm), 85+/-3dB(1W/1m)@1.5K, 2.0K, 2.5K, 3.0KHz
Maximum Input (W): 0.2
Impedance (Ω): 8+/-20%@1.5KHz 1.0V
Frequency Range (Hz): Fo---4K
Operating Temp (C): -20~+55
Dimension (mm): Φ31.8x20.5


As far as vibration/tilt sensing is concerned I would start with 3 tilt sensors

I'll look into that, thank you! :)
 
It seems that you should not connect a speaker directly to the DAC output and should go through an amplifier.
See here.

I just found this. An integrated speaker and amplifier which will just fit into the vial but not as nicely as the round speaker.
 
I just found this

Looks like a good solution, but the looks of it aren't suiting me.
So, if I get this right, as long as I have an amplifier like the one on the combo before the speaker,
I can have any 1W, 8Ohm speaker connected to it?
 
Yes that should be ok.
See here.

Here is the datasheet for the amplifier board you suggested. It looks like it has all the required Rs and Cs (see reply below).
 
Last edited:
This (PropShield) might be useful, includes amplifier, memory for sound data storage and motion detectors. Anyway the page has a lot of useful information for you (software and hardware) about connecting up the DAC and associated Rs and Cs required. It is sold out at PJRC but available elsewhere.

This supplier has them at a cheaper price, but without the motion temp and pressure detectors.
 
FO (Hz): 1,250+/-200@1.0V
Rated Input (W): 0.1
Sound Pressure Level (dB): 95+/-3dB(0.1W/10cm), 85+/-3dB(1W/1m)@1.5K, 2.0K, 2.5K, 3.0KHz

I'll look into that, thank you! :)

I'm quite confident that if you found the correct loudspeaker you would not need a separate amplifier. Speakers can be a little confusing. In your case it is not about earth shattering power Handling. This is the figure they are quoting when they say "Its a 2W speaker" etc. This is how much average power the speaker will withstand before the voice-coil is damaged. However in your case you are more interested in efficiency. Efficiency is the ability of the speaker to convert electrical energy into sound. This is the 95dB or 85dB etc as quoted BUT make sure you also take into account the distance figure. Sensitivity is measured at a known distance from the loudspeaker. normally 1m with 1W driven into the speaker. But as you see, the speakers you quote, is 95dB @0.1W/10cm. and 85dB @ 1W/1m. Sound pressure (loudness) falls at -6dB for each doubling of distance. Therefore the 95dB speaker @0.1W/10cm, would be a uhhhh... ~47dB @ 0.1/1m. The standard is to measure @1W/1m. As you can see by quoting 0.1W/10cm they have achieved a figure of 95dB. It looks good, but its not what you are interested in. At first glance you see 95dB Great. BUT at 10cm!!!! Watch out for those marketing men, they are crafty.

You do not have much power available from the Audio shield codec (~60mW into 16ohm), .... yes that's right 60 one thousands of a watt....not much However with a very sensitive loudspeaker you might be surprised just how loud this can be. The codec state a minimum load impedance of 16ohm. When you lower the impedance of a loudspeaker the power delivered into the speaker increases.

Power = Vrms^2 * R (HP_Voltage(rms)^2 * Speaker impedance).
In the case of the audio shield the output voltage has a maximum peak-2-peak level of ~3V Now this is not V directly, but V for the formulae can be easily obtained.

Vrms = (Vp2p/2) * 0.707 = 1.061V

Max(rms) power therefore = 1.0602^2/16 = 0.0625Watts this is pretty close to the figures given by the codec datasheet.

Now then if you lower the impedance of the loudspeaker, let us see what happens:

Vrms = 1.061V Speaker impedance = 8ohm

P = Vrms^2/R = 1.061^2/8 = ~140mW

It is not that I would recommend using a lower impedance loudspeaker, but you will get over twice the power output (at the risk of overheating the codec) and this is a risk, its a very tiny device and has very limited power dissipation capabilities. I am also quite sure that the power amplifier used inside it is a classical Class B. This means it is not very efficient and approx 30-40% of the output power will get wasted as heat in the integrated circuit. So 60mW out ~24mW heat in the IC. 140mW out ~56mW heat in the IC Simple really. The question is would this be okay. Hmmm probably... your call.

But to remind you, when you only have such low power output levels you MUST have a VERY VERY sensitive loudspeaker anything over 95dB 1W/1m is getting pretty darn good. If you can find something with 98dB even better. But I doubt you will find anything so sensitive, and if you did you might need a very deep pocket to match.
So back to reality:
Take a look here: https://www.visaton.de/en/products/drivers-accessories/miniature-speakers
Then take a look at what happens as you try to achieve sensitivity: https://faitalpro.com/en/products/LF_Loudspeakers/product_details/index.php?id=401000150


****** Remember each 6dB of extra sensitivity in the speaker will equate to ~double the loudness for the same electrical power. *******

And before anyone criticises this statement I am talking about perceived loudness levels. Psycho acoustic effect.

Just to give you an idea of how loud low powers can be. I will share something personal. I am a street musician. I busk in the streets here in Berlin all the time. I run my amplifiers on batteries. They are designed to last as long as possible, so they do not deliver very much power. ~2.5W maximum power. I can play on a street corner, using an e-guitar and a microphone with 2.5W and I still get the police telling me that residents are complaining.

So bottom line, do not under-estimate how much loudness you can get for low power outputs. Try it from the audio-shield directly with the best cheapest little speaker you can find.

60-100mW its a squeeze for sure, but let us review the other option of separate amplifier. You can not get more power out of a device that has such a low voltage supply. As you saw above the power is determined by both the speaker impedance and also importantly the Voltage(rms). The audio shield has a max 3.3V supply. If the supply voltage where higher and the amplifier designed to use it, then you can make significant output power increases. BUT you need a power supply.

This means you will need 2 separate power supplies for each module. 1 @ 3.3V for the Teensy and the audio shield and another @ a yet undefined voltage for an amplifier. Ohhh man.... what a pain. Yup!

Lets us assume you do decide to use 2 power supplies. Then I would recommend no less than 12V. The reason is that as soon as you go above about 12V you can begin to use many different ICs that are Class D. The amp suggested already is quite interesting as it runs on 6V, so its worth looking at. These class D amps are extremely efficient very robust and can be very compact, but even compact will probably not fit into you vial. Not without a custom solution. There is the concern. It's one thing choosing an IC, its another matter matching that IC to a speaker. As you can see some class D amps are designed to run directly into a loudspeaker without any output filtering. But this does require some careful consideration in regard to the loudspeaker as a filter itself. If not well matched they can be problematic. (see page 9 of the datasheet above). But is may be easier than I suggest, so don't let me put you off.

You can get classical Class B IC, that will run on lower voltages and you might find you can achieve perhaps 1-2W from such a device. But you will then flatten the battery in pretty short order as they are less efficient and will get a little warm. But they are much easier to design with, in fact you might find such a class B amp will only need 2 or 3 external components and no consideration needed for output filtering.

Here is one such : https://www.ti.com/lit/gpn/lm4889

In fact you will probably flatten the battery in pretty short order with Teensy and audio shield alone. These are rated at max 185mA. Now this current would only be consumed if you have the micro-controller running at full speed with plenty of input output going on.

Having said this running LEDs from the Teensy is a relatively high current activity. Let us assume you can keep the current from the Teensy down at 60mA.
Let us assume you use the Audio shield which NOT considering the headphone amplifier will consume ~10mA
The headphone output at full power will consume ~ between 6-10mA

So I would expect ~ 75mA consumption @ 3.3V P = I*V ~ 250mW continuously.

Therefore if you used 2 * 1.5V AA cells to get 3V, actually more like 2.6V, which is rather low as you need 3.3V and as they go flat the voltage drops. What!!!!... yes, sorry.

They typically have a capacity of ~1000mAH. So you could run the Teensy Audio shield combo for 3-4 hours then you will have emptied the batteries. If you put the batteries in the vial, you will need to change them all quite regularly.

I would recommend an external power supply @ ~ 12V and then use a linear or switching regulator inside the vial to deliver 3.3V to the digital electronics, in this way if you feed 12V into the vial, then you could use this for a separate amplifier.

Okay I stop now, have a think read and I will answer further questions as required.
 
Last edited:
Status
Not open for further replies.
Back
Top