AutoHotkey Community

It is currently May 27th, 2012, 6:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: November 30th, 2005, 11:54 pm 
Quote:
Source code and tutorials. For those of you who'd like to do some programming of their own, we are making availbable the C++ source (7k) of the Fast Fourier Transform algorithm. You may use it freely in your commercial software. The only thing we are asking in return is to display the acknowledgment to Reliable Software and the address of our web site in the About box of your program. (Being associated with Reliable Software is by itself good advertisment for your program.) There is also version 2.0 source available as part of our WinLib project (which is also free). Read the directions at our Forum.

For those interested in understanding the Fourier Tranform (and we had a lot of requests!), we have a detailed tutorial. It explanins, among other things, the main formula that we are using:
Image
By popular demand we have included a tutorial on how to sample input from the microphone using Win32 API. It's really not that difficult, and Windows provides pretty good abstraction on top of the sound hardware.
Quote:
Sampling sounds in Windows 32 is relatively simple—once you know how to deal with asynchronous input. Here's how it works: Windows tells your soundcard to start sampling the input from the microphone and store the samples in a client buffer. Once the buffer is full, Windows notifies the client, who is supposed to process the bufferful of data. There are several notification options. The simplest (but pretty much useless) is for the client to keep polling a flag until Windows changes its value. This of course eats up a lot of CPU time that could be spent doing some useful work.
The second option is to get notifications in the form of a Windows messages.

The third and, in my opinion, the best is the solution available only in Win32. The client creates a separate thread which is suspended waiting on an event. The event is triggered by Windows when the samples are ready. The client thread then wakes up, does the necessary work and goes back to sleep waiting for the next event.

I will describe the multi-threaded solution. If you haven't gone through my tutorial on threads, events and active objects, now's the time. Just click here and come back later.

Now that you're back, with the knowledge about active objects fresh in your mind, let me explain how to create a concrete active object that is responsible for processing sound samples. It waits for the buffer, calculates the Fourier transform of the samples and graphs the results. Since its main purpose is to display the results, I called it Painter. It doesn't talk directly to the Windows multimedia subsystem. That's the duty of another object, the Recorder.

Notice the two View objects passed to the Painter's constructor. These objects encapsulate the two panes used for displaying the sample data and its FFT. The sampling parameters are passed to the constructor as initial settings and to the ReInit method as new settings. The FFT transformer and Recorder are hidden inside smart pointers PtrFft and PtrRecorder. Finally, the Painter object contains two synchronization objects—a mutex to ensure serialized access to Painter's data and an event that is used for synchronization with the multimedia subsystem (that's the event we'll be waiting on). Notice that, as explained in the ActiveObject tutorial, the consturctor of Painter has to call _thread.Resume () to start the execution of the captive thread.

[HowTo]
[More...]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 1st, 2005, 12:59 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
There are many free FFT code samples out there, but I really would like to know, how I could get sound or video samples directly to an AHK script. There could be some interesting actions triggered by a loud voice or when turning on/off the light. Even a motion detector is feasible.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 3rd, 2005, 11:58 pm 
Offline

Joined: March 16th, 2005, 10:33 pm
Posts: 969
Location: Frisia
Directly? You want the raw data?

Video:

Not raw, but you could use still images to disk/read and process with one of the programs listed here (I assume you meant video from a webcam)...

Sound:

LineInCode (GNU GPL)

Quote:
This program captures audio data and dumps it as raw PCM data into its standard output (STDOUT)


And since I'm interested in the subject, I searched a bit, and found some other interesting code, programs and sites on the subject(s):

Real Time Sound Comparator, does exactly what you wanted, but is a fullscreen DOSBox payware (trial/demo available), and needs a Sound Blaster 16... :?

Quote:
The program is designed for real time scale concurrence detection of a sound signal with previously recorded patterns.

One of the most attractive features of the program is the sound signal monitoring (TV, Radio, Video ads clipping, the advertising announcements passing reliability, songs ratings, on air copyrights control etc.).

It is important to note, that the program is compared a COPYES of the same sounds and is not designed for announcer verification or speech identification purposes.

One of the following inputs of sound card can be chosen as the signal source: Microphone, Audio Compact Disk (CD), Linear input of a sound card. The Linear input could be connected to an external device, e.g. TV/FM tuner, a radio receiver, TV-set etc.

It is possible to create up to 255 sound patterns (PCM, 6144 Hz, 16 bit, 4 sec, mono each one). The patterns are recorded into WAV files with names from patt001.wav to patt255.wav and stored into \Patterns subdirectory.

Up to 12 patterns can simultaneously be compared to the signal of one channel (Mono, Left, Right). Or up to 6+6 patterns, when two channels used (Left & Right) simultaneously.


Interesting stuff (maybe even worth running on an old box), but I couldn't really get it to work with VDMSound to test...

Quote:
VDMSound is a program that overcomes what has probably been the most exasperating limitation of DOS boxes since Windows NT - sound support. VDMSound is an open, plug-in oriented platform that emulates an MPU-401 interface (for outputting high-quality MIDI music), a SoundBlaster compatible (SB16, SBPro 2, SB2, SBPro, etc.) implementation (for digital sound effects and FM/AdLib music), as well as a standard game-port interface (for playing games with joystick support). In development are improvements to the existing joystick emulation, and possibly VESA support.

Unlike all the Win9x SoundBlaster ISA ‘legacy’ drivers available from a variety of PCI soundcard manufacturers, VDMSound is not a mere ‘wrapper’ or ‘bridge’ to existing audio hardware. It is a self-contained, 100% software emulation program that is completely independent of your audio hardware type and settings. VDMSound works with any soundcard, and will even work on computers that have no audio hardware at all (for instance, instead of outputting sounds through your soundcard using the standard Windows drivers, VDMSound can easily output them to disk).


Interesting command line software for soundanalysis can be found on the Picosound homepage too (untested).

Also interesting: Music Explorer

But, for analysis of incoming data to be really useful, it should be able to 'tap' from the source only, not take the whole source and make it unavailable to other programs.

I couldn't find a free multi-client driver for audio, but Virtual Audio Cable (Payware, demo available) offers exactly that:

Quote:
Virtual Audio Cable is a Windows multimedia driver allowing you to transfer audio (wave) streams from one application to another. It creates a pair of Wave In/Out devices for each cable. Any application can send audio stream to Out device, and any other application can receive this stream from In device.

If more than one applications are sending audio to VAC, it will mix all streams together. If more than one applications are receiving audio from VAC, it will share the same audio data between all targets.


If you are interested in writing your own version :P here is a very simple sounding explanation (Writing a virtual audio driver)...

There is a freeware multi-client driver for video, SplitCam, but it insists on phoning home :evil: so, avoid it...

Oh, and something else I found:

You can invoke the "Volume Controls" with this command line:

Code:
%WINDIR%\SNDVOL32.EXE


Not really exiting, but you can invoke the "Record Controls" with this command line:

Code:
%WINDIR%\SNDVOL32.EXE /R


And, more interesting, if you invoke the "Volume Controls" with this command line, you'll get the different inputs.:

Code:
%WINDIR%\SNDVOL32.EXE /D[0-n]


Two related handy dandy programs:

QuickMix

Quote:
QuickMix is a simple applet that allows you to store all or part of the current state of your audio mixer in a settings file, and to restore the mixer to that state whenever you want.


Quick Mixer

Quote:
Quick Mixer is a tray-agent alternative to the Windows Volume Control (SNDVOL32.EXE). Quick Mixer is re-sizeable and has many settings which affect the way it looks and acts. Quick Mixer is a great replacement for that little yellow speaker icon that may now be in your tray! Quick Mixer controls Main-Volume, Main-Treble, Main-Bass and up-to 16 playback audio sources! Quick Mixer gives you access to every available playback mute on your sound-card. Quick Mixer gives you access to the first on/off check under Advanced, Other Controls. Quick Mixer allows you to create 10 audio profiles and optionally starts up with a default profile.

_________________
Image mirror 1mirror 2mirror 3ahk4.me • PM or Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2005, 5:25 am 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
Great post. Excellent resource. Thanks you very much.

_________________
//TODO: Create kewl sig...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group