Go Down

Topic: FreqOut- Audio/Midi synth | MCP4725 I2C DAC (Read 2094 times) previous topic - next topic

Pitchoilcan

May 23, 2011, 09:26 pm Last Edit: May 24, 2011, 03:44 am by Pitchoilcan Reason: 1
Hi all, I am working on a project that involves reading 16 analog inputs to output musical note based on which of the sensors are touched, ...code copied from http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html. At the moment I am able to send midi note and I would like to add audio Out. This much I get...:http://itp.nyu.edu/physcomp/Labs/ToneOutput http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation
Hardware:
8ohm speaker/piezo
resistor
to digital pin and ground.
Software:
pitches.h http://www.arduino.cc/playground/Main/Freqout
I have a file called pitches.h which contain the note frequencies.
That much I understand.
Now can I have both midi out and audio out that the same time, and how might I implement that?
I've also noticed that I'm getting multiple midi notes on one piezo sensor (not good),
Quote


I am thinking adding a capacitor to each input would fix that. Any thoughts?  

Thanks in advance
Caesar
================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

CrossRoads

How many notes do you want to sound at one time?
I believe you can do analogWrite(frequency) and it will go out as PWM until you stop the write.
(have not actually tried this myself, but I think it works that way, built in atmega hardware function).
Thus you have a fast loop that checks for a keypress, check a list of flags and see if you have a "free" PWM output, assign that note to the "free" PWM pin and set the flag to "in-use", next time thru the loop see if the key is still pressed, if not stop the note  with analogwrite(0) and set its flag to "free". (maybe watch how long its been in use and free after some time limit, so quasi-piano like vs organ/synthesizer?)
Take all the PWMs and mix together using a summing amplifer o-amp or similar:
http://masteringelectronicsdesign.com/how-to-derive-the-summing-amplifier-transfer-function/
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Pitchoilcan

#2
May 24, 2011, 12:19 am Last Edit: May 24, 2011, 03:45 am by Pitchoilcan Reason: 1
One note per sensor. So in this case 16 notes. The original idea came to me after seeing Musical arduino Mididrumkithttp://todbot.com/blog/2006/10/29/spooky-arduino-projects-4-and-musical-arduino/. See schematic below. Output pin 1 is transmiting midi. For audio out I plan  to attach the speaker and resistor to PWM output pin 9 and ground. #include pitches.h and then.....????? Is it matter of doing digtalwrite on pin1 (TX) for midi and pin 9 for FREQOUT? I have a MCP4725 I2C DAC 12Bit DAC I picked up at sparkfun. I read somewhere it's good for implementing audio on musical instruments built using Arduino. At the moment all I have are two multiplexers reading Analog input 0-1 i.e. 16 inputs. I havn't included the DAC, or the port expander (as in midifootsteps) for the LED array yet. At this point I am concerned with PWM
================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

Pitchoilcan

code for a one octave sensor board
Quote
/*
   keyboard
 
  Plays a pitch that changes based on a changing analog input
 
  circuit:
  * 13 force-sensing resistors from +5V to analog in 0 through 5
  * 13 10K resistors from analog in 0 through 5 to ground
  * 8-ohm speaker on digital pin 8
 
  created 21 Jan 2010
  by Tom Igoe
 
  */

#include "pitches.h"

const int threshold = 10;    // minimum reading of the sensors that generates a note

// notes to play, corresponding to the 3 sensors:
int notes[] = {
   NOTE_C4, NOTE_CS4, NOTE_D4, NOTE_D#4, NOTE_E4, NOTE_F4, NOTE_FS4, NOTE_G4, NOTE_GS4, NOTE_A4, NOTE_AS4, NOTE_B4, NOTE_C3  };

void setup() {

}

void loop() {
   for (int thisSensor = 0; thisSensor < 13; thisSensor++) {
     // get a sensor reading:
     int sensorReading = analogRead(thisSensor);

     // if the sensor is pressed hard enough:
     if (sensorReading > threshold) {
       // play the note corresponding to this sensor:
       tone(8, notes[thisSensor], 20);
     }
   }
   Serial.println();
}
================================
http://twit.tv/floss61
Think different
Think UbuntuStudio
============================

Go Up