Simple DSP inside core module?

Hey guys! I’m a noob here, so forgive the potentially dumb question…

I want to turn audio signals into midi-cc values. I plan to implement some kind of envelope follower to turn the audio signal into a usable control voltage, then into midi cc from there.

My question is: can I just input the audio into the ain module, and then perform the envelope following digitally, using the pic in the core module? I was originally planning to use a hardware envelope follower design, but I thought that if I could use the core module to do this, I would save money and time and maintain more design flexibility.

I need to do a minimum of 4 distinct audio stream>>envelope followers.

Thanks for moving this…

Didn’t notice the design concepts section. Sorry.

Hi squeal,

no prob.

welcome to the forum :wink:

in guess this should be possible, but IIRC line-in signals are 1.2V max; the AIN would reach it’s maximum at 5V.

Maybe someone else can say something about possible dangers, dunno about the currents?

Although it’s not exactly what you’re after, this userproject might from lylehaze might have some infos of value to you:

http://www.midibox.org/dokuwiki/midiboxmixer

Best,

Michael

Your best bet in terms of ease of programming and reliability would be to take a leaf out of old audio compressor design and use an optical coupler or similar strategy.

The basic premise is that you:

  1. connect a light source (ie an LED) to your audio signal (I would suggest using an op-amp buffer to avoid overloading your audio output, and to give you more juice to drive the LED). Also, the op-amp wants to be optimised so that your hottest signal will give it nearly +5v output.

  2. physically coupled to this LED (and shielded using black tape or a small tubing sleeve, you connect an LDR device.

  3. connect one lead from the LDR to ground, the other end to the analog input on the PIC.

The pic would then treat the LDR as a voltage source, not too different to a pot or fader.

This is the concept. You’ll find it needs a little refining and experimentation.

thanks for the replies. :slight_smile:

A.C.: could you explain what iirc is? As far as AIN, I would need my audio signals to be between 0 and 5V. Is that right?

tilted: I was trying to avoid any extra work (since I need to do 4-6 of these) but that might be the ticket.

Hi squeal,

IIRC = If I Remember Correctly :wink: You do need 0-5V, but as AC mentioned there may be issues with current… I have no idea !

The method which tilted mentioned is often referred to as a ‘vactrol’. Though you might like that as a search term so you can find schematics.

modern compressors use THAT2252  ::slight_smile:

http://www.koen.smartelectronix.com/KTDrumTrigger

seen this one? Why you need envelope data?

IIRC, meh. ;D

Okay, it seems a little background info is in order.

My plan is to create a guitar-like midi synth controller. I plan to use these pickups:

http://www.stewmac.com/shop/Electronics,_pickups/Pickups:_Guitar,_electric/1/Graph_Tech_Ghost_Pickup_System_for_Guitar/Details.html#details

to get separate signals for each string.

I would then need to turn the volume of each signal into a midi-cc value which could be mapped to parameters in a synth engine. Now I could use vactrols or some other analog envelope follower method to create a usable voltage to put into an AIN module, but I was wondering if I could avoid that extra work by simply inputting the raw audio (scaled appropriately of course) to the AIN, and implementing envelope followers in the code.

@ playbo$$- That VST looks awesome, but I don’t necesarily want to use a computer with this midi controller. Thanks for the link, though.  :slight_smile:

OK based on what A.C. says I am gonna go ahead and give this a shot. If I can’t do a digital env follower in the box, then I will just go ahead and build analog env followers.

Does anyone know what the sample rate of the AIN module is? Same as the core(40mhz)?

If anyone has any thoughts or questions on this project, let me know.

Unprocessed audio into AIN wouldn’t give the results you’re looking for.  The sampling rate is not high enough, so as a result you’d get somewhat unpredictable results - and if you tried to “smooth” the input in software it would likely introduce far too much latency.

You will need an analog envelope follower of some sort at the input stage.  There is a variety of simple envelope follower schematics all over the net, including a couple that don’t appear to require expensive and fragile vactrols:

http://www.uni-bonn.de/~uzs159/envf.html

http://www.angelfire.com/music2/theanalogcottage/envfol.htm

(fyi: as i was typing this you posted your last reply, but i’m too lazy to change it)

if you come up with something, be sure to document it in the wiki!

if you come up with something, be sure to document it in the wiki!

I definitely will :slight_smile:

@ nebula: do I REALLY have to build envelope followers? :-[ What is that sample rate?

the PIC ains go into a single successive approximation ADC so its a single converter . Nebula says processing these signals would take big effort and mcu cycles, I think he is right. Please check THAT2252 datasheet and app notes it might be what you want (…)

the PIC ains go into a single successive approximation ADC so its a single converter . Nebula says processing these signals would take big effort and mcu cycles, I think he is right. Please check THAT2252 datasheet and app notes it might be what you want (…)

THAT looks pretty easy. Maybe I will use…THAT.

What is that sample rate?

MIOS samples the AINs every 100ns, so 10khz. I guess that keeping Nyquist in mind, that means the highest frequency you could track would be 5khz.

MIOS samples the AINs every 100ns, so 10khz. I guess that keeping Nyquist in mind, that means the highest frequency you could track would be 5khz.

given that you aren’t interested in returning to frequency domain,

10k sample rate should be enough.  envelope followers roughly follow the

the power level of the input, and the energy level of audio signals above 5k

is usually not very high.  you would only really lose energy information at

or near harmonics of 1/2 sample rate: 5k, 10k, 15k, 20k…

so give it a shot.

(unless you are wanting to track glockenspiel or something, hehe)

given that you aren’t interested in returning to frequency domain,

10k sample rate should be enough.  envelope followers roughly follow the

the power level of the input, and the energy level of audio signals above 5k

is usually not very high.  you would only really lose energy information at

or near harmonics of 1/2 sample rate: 5k, 10k, 15k, 20k…

so give it a shot.

I would not want to see the resulting transients - even if possible :stuck_out_tongue:

OK cool. I’m going for it. :smiley:

No real reason to not try it.

Also, the “audio” that I will be tracking is kind of irrelevant, so I can tailor it to the processing. I am tracking the vibrations of guitar strings, and I am not using the audio for any other thing. The strings could all be tuned to the same note for all I care. I just want it to feel like a normal guitar and extract a usable envelope.

Tomorrow is payday, so I’ll order the pcbs and such and get started. Thanks everyone for the info and advice. :slight_smile:

I would not want to see the resulting transients - even if possible :stuck_out_tongue:

i think transient frequency domain information is irrelevant in this case.

however, this does suggest a problem with midi rates.

if you are interested in the transient info of a guitar pick attack,

i think probably midi is not sufficient to transmit this, no matter how

the data is collected.

on the other hand, if you want to follow average power levels

to control say filter cutoff, you should be alright…