• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Newbie: question about captured input
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie: question about captured input


  • Subject: Newbie: question about captured input
  • From: Ryan Patrick <email@hidden>
  • Date: Fri, 22 Apr 2005 09:29:56 -0700

Hello-
What I am trying to do:
Capture input from the default input device and analyze the input (perform a FFT on it). And, just for fun, do this in java.

Pseudo-code:
1) get the default input device- I simply used the AudioHardware functions instead of creating an AudioUnit (is that correct?)
2) setup an AudioDeviceIOProc with the execute method to handle the returned data
3) collect the data in a buffer and perform FFT once a large enough sample has been captured

Sample Code (only pieces of it of course):
public class AMCaptureInput {
public void start() {
try {
device = AudioHardware.getDefaultInputDevice();
active=true;
// setup device
ioProc = new AMAudioDeviceIOProc();
device.addIOProc(ioProc);
// start device
device.start(ioProc);
} catch(CAException cae) {}
}
}
public class AMAudioDeviceIOProc implements AudioDeviceIOProc {
public int execute(AudioDevice device,AudioTimeStamp inNow,AudioBufferList inInputData,AudioTimeStamp inInputTime
,AudioBufferList outOutputData,AudioTimeStamp inOutputTime) {
AudioBuffer ab=inInputData.getBuffer(0);
byte bufferData[]=new byte[ab.getSize()];
ab.copyToArray(0,ab.getSize());
buffer.addToBuffer(bufferData);


System.out.println("Results: ");
int x=0;x<ab.getSize();x++) {
System.out.print(ab.getFloatAt(x)+",");
}


return CAErrors.kAudioHardwareNoError;
}
}

My question:
If I correctly understand what is happening, the 'inInputData' AudioBufferList contains an AudioBuffer that is a single sample from the device. Therefore, if I collect enough of these, I should be able to generate a wave. However, in order to use the FFT function that I wrote, I need to have an array of floats. Therefore, how do I get the 'bufferData' array as a float? Or, is the audio buffer a collection of samples (I always get 12 bytes returned?)? Every time that I use getFloatAt I only get a really small number...

Thanks in advanced and sorry for the long message
-Ryan
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: synth soundbank
  • Next by Date: Internal Microphone
  • Previous by thread: Re: synth soundbank
  • Next by thread: Internal Microphone
  • Index(es):
    • Date
    • Thread