Shop OBEX P1 Docs P2 Docs Learn Events
Keyboard frequencies to generate different colored lights? — Parallax Forums

Keyboard frequencies to generate different colored lights?

YvonnessYvonness Posts: 4
edited 2010-07-13 15:45 in BASIC Stamp
Hi, all!· tongue.gif· I'm a newbie to all this.· This is my first time at a forum of any kind.· I'm a pianist and I've had only a bit of Stamp programming at our local community college.· I'd like to make a keyboard communicate with the stamp or propeller to make lights come out that match the color frequencies to the sound frequencies so that we can see the colors (using LEDs, lights, or those colored compact CCFL tubes) of the sounds. So, I'm asking a big question first: is it possible? I've heard about MIDI, but I also know it's possible to "listen" to frequencies.

I realize it's best to ask a specific question next, like "how would I connect it?" and I'll probably do that next.

So, I'd appreciate any general or specific input you could give me at this time.


I'd appreciate any help along any part of the way.· You could reply here or use the PM feature.·
···· MusicallYours,
··········· Yvonness

P.S. I'm at the UPEW expo today at Parallax.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-06-27 22:31
    Congratulations! I wish I was there. I would look closer at MIDI if your keyboard has that capability (I'm assuming you are talking about a musical keyboard and not your computer). A MIDI decoder would be a great use of the propeller and may be able to be done with the stamp but I don't know enough about it to say for sure.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • bill190bill190 Posts: 769
    edited 2010-06-27 22:40
    The following link says... "The frequency of visible light is referred to as color, and ranges from 430 trillion Hz, seen as red, to 750 trillion Hz, seen as violet"...

    http://science.howstuffworks.com/light3.htm

    Then the next link says... " While the range of frequencies that any individual can hear is largely related to environmental factors, the generally accepted standard range of audible frequencies is 20 to 20,000 hertz...

    http://en.wikipedia.org/wiki/Audio_frequency
  • FranklinFranklin Posts: 4,747
    edited 2010-06-27 22:46
    @bill190 thanks but I think we know what light is. [noparse];)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • bill190bill190 Posts: 769
    edited 2010-06-28 00:23
    Franklin said...
    @bill190 thanks but I think we know what light is. [noparse];)[/noparse]

    And the person asking the question knows this as well?

    (My point was the frequencies don't match...)
    ·
  • IroneIrone Posts: 116
    edited 2010-06-28 03:16
    How Ya Doin'? What would happen if we used the stamp to listen for frequencys? Lets say we got 2093 hertz. We could call it something stupid like c7. Then when the stamp heard c7 (2093 hertz) we could tell it to light up a red light. Then listen for the next frequency. If it is 2349 we could call it d7 and light up an orange light. Then 2637 could be e7 and yellow, 2793 could be f7 and blue and so on till we run out of colors. I know I missed the flats and sharps but could we use two colors to show them? I am old and a hillbilly so I only know roy g biv for basic colors but my wife·drives a red Bronco that she calls maroon.

    Casey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I fish, therefore I lie!
  • bill190bill190 Posts: 769
    edited 2010-06-28 03:44
    That you could do.

    Or label different lights and light up an LED next to each label.

    Or make lights less or more bright.

    So far as I have seen, there are just a few colors of LED lights, whereas there are all sorts of keys on a piano/keyboard.

    To my knowledge there is no light which would change color depending on how much electricity is provided to it or what frequency is provided to it?

    So far as I know, lights are one color and on/off?? (There are multi-color LED's, but only 3 different colors.)

    For example with a red LED - on you get red. Less power a dim red LED. More power a bright red LED, etc.

    Also the stamp has only 16 connections. But there are clever ways to have more outputs.

    They also have bar LED's sort of like the progress bar on a computer when you are downloading something. I suppose you could use one of those for a frequency range. Then another for another frequency range. Just like a graphic equalizer on a stereo system.
  • IroneIrone Posts: 116
    edited 2010-06-28 04:12
    How Ya Doin'? Who said we may only light up 1 LED? We have 16 places we can light up Led's. Sixteen to the power of 2 equals 256. Last time I looked at a piano it only had 88 keys. That is almost 3 keys per LED option. I do not believe anybody is going to learn how to play the piano with this setup but it will only be used for a pleasing light application.

    Casey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I fish, therefore I lie!
  • IroneIrone Posts: 116
    edited 2010-06-28 04:23
    How Ya Doin'? Whups,·two to the eights power equals 256. Two to the sixteenth power equals 65536. I have had a few beers, sorry.

    Casey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I fish, therefore I lie!
  • skylightskylight Posts: 1,915
    edited 2010-06-28 08:53
    Yvonness, you should be able to use the Count function to read the note frequency and trigger an output accordingly to light a particular coloured led of your choice for a certain note.
    I think the hardest part for you will be in interfacing your keyboard to the stamp ie the headphone output or the line output would need to be capped to a max of 5V
  • sumdawgysumdawgy Posts: 167
    edited 2010-06-28 14:51
    Yvonness said...
    Hi, all!· tongue.gif· I'm a newbie to all this.· This is my first time at a forum of any kind.· I'm a pianist and I've had only a bit of Stamp programming at our local community college.· I'd like to make a keyboard communicate with the stamp or propeller to make lights come out that match the color frequencies to the sound frequencies so that we can see the colors (using LEDs, lights, or those colored compact CCFL tubes) of the sounds. So, I'm asking a big question first: is it possible? I've heard about MIDI, but I also know it's possible to "listen" to frequencies.

    I realize it's best to ask a specific question next, like "how would I connect it?" and I'll probably do that next.
    Best·to read the freq then act on it.

    Microphone Frequency Sensor·<<< this site gives you a circuit (w/walkthru) to convert the freq to Analog
    So...with an ADC connected, you can work out the freq:voltage ratio you're looking for.

    Try this as yer starting point!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown
  • Spiral_72Spiral_72 Posts: 791
    edited 2010-06-28 15:11
    Someone has done this exact thing. Perhaps Google can help. I remember the project though.

    I suppose it'd be difficult to pick off each key's contact? Too bad though, that'd be easiest. A DTMF decoder does is what you need, you just need a lot more frequencies. Perhaps someone makes such an IC?

    How many lights are you interested in using? 20? 88? (one for each key?) or some other number?


    Oh, and tri-color LEDs can show much more than three colors. That may be an option as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "puff"...... Smile, there went another one.
  • bill190bill190 Posts: 769
    edited 2010-06-28 15:50
    Spiral_72 said...

    Oh, and tri-color LEDs can show much more than three colors. That may be an option as well.
    Interesting! I've only turned on/off each color on these 3 color LEDs...

    What all can you do with them?

    Can you mix two colors and get the mixture?

    And maybe power one color just a little and power another color a lot and get variations?
    ·
  • skylightskylight Posts: 1,915
    edited 2010-06-28 17:05
    bill190 said...

    Can you mix two colors and get the mixture?

    And maybe power one color just a little and power another color a lot and get variations?
    Basically yes, thats it, you are ending up colour mixing with RGB(if the tricolor led is an RGB one of course) you can supposedly achieve 16 million+ colours although in practice the range you see is far smaller and a camera will only pick up a small range of these colours better than others.

    Post Edited (skylight) : 6/28/2010 5:14:22 PM GMT
  • hover1hover1 Posts: 1,929
    edited 2010-06-28 17:16
    Do a Google for "Color Organ". These were popular during the 80's and still are. There are basic 3 channel and 5 chanell circuits out there, but I bet you could find some newer ones that will do 8 or more.

    @bill190
    With a Tri color LED, you shouls be able to create any color you want. You would apply PWM to each LED to vary the intensity of each color to produce the mix of your choice.

    Jim
  • YvonnessYvonness Posts: 4
    edited 2010-06-29 05:00
    There are 12 notes, so 12 colors would be necessary, but if that many colors are available it would be nice to deepen the richness of the colors based on the deepness of the octave.· My main concern now is how to make the communication between the sound and the color.· Also, I've already done the math for what colors relate to which notes based on their mathamatical relation.
    ···· Yvonness
  • YvonnessYvonness Posts: 4
    edited 2010-06-29 05:12
    The microphone idea would be ideal, cuz then it could be completely sound activated. Does this convert it to a frequency?
  • mphmph Posts: 13
    edited 2010-06-29 05:49
    Hi Yvonness,

    when you record sound with a microphone you are measuring the sound vibrations at a fast rate, that is you are recording the amplitude as a function of TIME. It is also likely that different notes are played simultaneously. So a microphone would sense the superposition of the individual notes. To get the individual FREQUENCIES from this you could do two things:

    (1) Have a bunch of bandpass filters, each tuned to one of the notes. Bandpass filters can be designed to transmit in a narrow frequency range and thus listen to just one particular note. I guess you would need as many of those as you have notes on your keyboard. You may have seen bandpass filters on the Equalizer of an "old" high quality stereo set.

    (2) Or you could record the original sound for a short period and then do what is called "Fourier transformation". This is a mathematical algorithm that will give you the spectrum of the sound, that is the result will show you what individual frequencies are contained in the original sound. Fourier transformation takes quite some calculation; I don't know if anyone did that on the Stamp and/or if it would be fast enough.
  • P!-RoP!-Ro Posts: 1,189
    edited 2010-07-02 21:56
    I doubt the Basic Stamp will have enough speed, but this is the schematic you would need for connecting·an electret microphone to·an I/O·pin:

    220px-Electret_condenser_microphone_schematic.png

    I know you're new to programming and electronics, but this is basically how the schematic works:

    The negative terminal is connected to ground (vdd on the board of education) and is tied to the positive terminal of the microphone, pulsing with the frequency of the sound. The v+ (positive voltage, vss on the BOE) connected with a resistor to the positive terminal of the microphone is used·to "pull it up", meaning it allows your microcontroller (Basic Stamp) to differentiate when the electret microphone is triggered (negative) or not (positive). Due to the high frequency of the sound waves, this schematic should make a sort of AC signal·which can be filtered by a capacitor before going to·an I/O pin. Once there, you can program your microcontroller to get a measure of time·between the negative pulses (use the command "rctime" on the·Basic Stamp)·to get a·reading of the frequency of the sound being detected. Then, all you have to do is light·some LEDs!

    Hope you understand this, I know it's a little complex for you at this point. My advice: listen to your professor and go through those Basic Stamp tutorials!

    Good seeing you at the expo, and good luck with this project!
  • YvonnessYvonness Posts: 4
    edited 2010-07-13 04:55
    Is there a MIDI interface for the Stamp or Propeller?

    ~ Yvonness
  • FranklinFranklin Posts: 4,747
    edited 2010-07-13 15:45
    http://itp.nyu.edu/physcomp/Labs/MIDIOutput
    http://www.maxmidi.com/diy/serial/index.html
    Not for Parallax products but they could be converted.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
Sign In or Register to comment.