Hello everybody,

first this is my first post on this forum and im from Germany, so sorry for some confused language syntax ;-)

I developed a electric circuit that controls some LEDs. This is built into my computer to make some light effects. I wrote a controlprogramm for the microcontroler I used on the circuit board. So the Visual Basic Programm communicates with the microcontroler on the circuit board. I'm able to change some settings and so on... ocer the RS232. This works excellent!

Now I want to expand my software. I like to make an audio-depended effect show. Let me explain:

I have 6 colors (green, blue, red, yellow, white and uv).
I need a source or tip that says me what frequenz at the moment is and how high the level is.
So that I can program: Red LED light up at 100Hz (and maybe 75% audio level) How this information is send to the microcontroller is no problem.

My problem is to scan the soundoutput and get the current frequenz and the audio level.

Any idea to solve or help me a litte bit?

Thanks in advantage and sorry for some confused language.

Greetings
Benny

Hey check out the FMOD Api.. www.FMOD.org this is a fantastic audio engine for many langs, including VB6.

So the Visual Basic Programm communicates with the microcontroler on the circuit board. I'm able to change some settings and so on... ocer the RS232.

If you are controlling the Communications Port (RS232) with the Microsoft Comm Control--which I take it you are since you're using Visual Basic 6.0--then you should code your program to raise events in the MsComm1_OnComm1 event.

Private Sub MSComm1_OnComm()

End Sub

A good way to do this is to design a class module and declare an event: this example's code is from class module named clsMicroController

Option Explicit
Public Event AudioFrequencyReceived(ByVal Hertz As Long)

Public Function ChangeColor(Hertz_Received As Long)
   RaiseEvent AudioFrequencyReceived(Hertz_Received)
End Function

And then you need to declare the event in your main form with the class module as follows:

Option Explicit
Private WithEvents MyRS232 As clsMicroController
Private Const RED = 100
Private Const BLUE = 75
Private Const YELLOW = 50

And then I imagine you already have some code in your ONCOMM event that you can use to determine what Hertz you've sent. Use that section to use the event you declared in your class module

Private Sub MSComm1_OnComm()
   Dim lngHertz As Long, Value_Received As Long
   lngHertz = Value_Received
   ' Raise your event
   MyRS232.ChangeColor (lngHertz)
   
End Sub

At this point the ChangeColor event is fired from your class module and you should see the event in the main form:

Private Sub MyRS232_AudioFrequencyReceived(ByVal Hertz As Long)
   Static Current_Color As Integer
   ' Code to turn on/off your lights
   Select Case Hertz
   Case RED
      ' Turn on RED
      ' Turn off Current_Color
   Case BLUE
      ' Turn on BLUE
      ' Turn off Current_Color
   Case YELLOW
      ' Turn on YELLOW
      ' Turn off Current_Color
   End Select
End Sub

What happens is that the ONCOMM event detects the Hertz, Sends the message to the class module clsMicroController to fire the AudioFrequencReceived event including the frequency, the class module fires the event in the main form (Private Sub MyRS232_AudioFrequencyReceived(ByVal Hertz As Long)), and you code the program accordingly.

This is pretty general, but I hope you get the idea.

Hank

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.