Jump to content

Simple DSP inside core module?


squeal

Recommended Posts

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.

Link to comment
Share on other sites

Hi squeal,

no prob.

welcome to the forum ;-)

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

thanks for the replies. :)

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.

Link to comment
Share on other sites

Hi squeal,

IIRC = If I Remember Correctly ;) 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.

Link to comment
Share on other sites

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.  :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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 :P

Link to comment
Share on other sites

OK cool. I'm going for it. :D

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. :)

Link to comment
Share on other sites

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

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...

Link to comment
Share on other sites

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...

Now I do want it to twiddle the volume parameter of my synth engine, among other possible uses. I don't really need it to be very guitar like in the shape of the transient, but I do want it to be as fast as possible. A slow attack would make it less satisfying to play, I would imagine.

Link to comment
Share on other sites

OK so I've been mucking about with some VST code putting bit reduced audio into envelope followers, and I'm fairly convinced that any signal degradation due to the bit reduction causes negligible change to the envelope. I mean this depends on the env folloewer's parameters and structure, but I think that in most cases it won't matter.

Specifically, I compared 44.1k audio into env follower with 4.41k audio into env follower, and the outputs looked about the same.

New question:

The C code envelope follower I am thinking of using is comprised of 2 cascaded single pole filters. There is more to it than that, but that is the part I want to implement in code. So, for four channels I would need to do 8 individual single pole filters. Could the pic reasonably handle this using the mios framework?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...