• 0

audio input and playback


Question

hi again all! i know i am posting alot lately but hopefully my topics are helping more then just me ... and i will say all the help i have gotten has helped me learn so much!

now I need to move on a bit with my project and start practising with hardware I am not going to ask you to do my work for me but I am asking for a kick start in the right direction ... can someone give me or link me to a bit of code which reads microphone input (I dont know a single thing about programming around hardware so i will just assume that a microphone jack and a built in mic have different bits of code so if you do help could you specify what hardware its accessing)

I then want to process that output and play it back PREFERABLY without out it being saved as a file on my machine as i am sure i could do that without help from you guys (google :D ) when i have a fair understanding on this I am going to try and build a voip ... so can anyone help me with a basic mic and play back program to get me started??

Link to comment
https://www.neowin.net/forum/topic/1127388-audio-input-and-playback/
Share on other sites

13 answers to this question

Recommended Posts

  • 0

The java media framework should do what you need:

http://www.cs.odu.ed...5Capturing.html

can i really call my self a programmer if i just use frameworks though ? :( I have always had a grudge against frameworks I am only going to get a A- max in my php assignment because one of the criteria was to use frameworks but i refused to and programmed it all from scratch, this java is not for an assignment but for personal learning .... do you think i am being silly and every programmer uses frame works or can you see my point?

although further inspection of this website you sent me has allowed me to see its just the basic kind of things rather then a whole program that you tweek xD standard java class sharing

brilliant link

  • 0

can i really call my self a programmer if i just use frameworks though ? :( I have always had a grudge against frameworks I am only going to get a A- max in my php assignment because one of the criteria was to use frameworks but i refused to and programmed it all from scratch, this java is not for an assignment but for personal learning .... do you think i am being silly and every programmer uses frame works or can you see my point?

although further inspection of this website you sent me has allowed me to see its just the basic kind of things rather then a whole program that you tweek xD standard java class sharing

There's no shame in using frameworks. Any way you do it you're already using code someone else wrote, whether it's in the JRE or not.

You can also use the internal javax.sound.sampled:

http://www.jsresources.org/examples/SimpleAudioRecorder.java.html

JMF might help later on though for video if you're interested in doing that.

  • 0

There's no shame in using frameworks. Any way you do it you're already using code someone else wrote, whether it's in the JRE or not.

You can also use the internal javax.sound.sampled:

http://www.jsresourc...order.java.html

JMF might help later on though for video if you're interested in doing that.

I have tried using the sound sampled thing before but I dunno getting the input is fine ... but setting the output as the input directly i am having trouble with i have only played saved files ... video will be a big yes ... I eventually want to make a 100% encrypted text, voice and video program ... stage 1 complete im now on to stage 2 voice :D I already have some methods planned for this should be about 3-5 months and the program should be 100% complete if I can get used to this JMF thing... already having problems with the first example (yes i have downloaded and put the JARS into my lib) its just saying its wrong lol I set di and got everything fine except the vector deviceList... its having a hissy ... if you have used this before could you tell me the issue? obviously im very new to this advanced (well i think its advanced) level of programming


// Get the CaptureDeviceInfo for the live audio capture device
Vector deviceList = CaptureDeviceManager.getDeviceList(new
AudioFormat("linear", 44100, 16, 2));
if (deviceList.size() > 0)
di = (CaptureDeviceInfo)deviceList.firstElement();
else
// Exit if we can't find a device that does linear, 44100Hz, 16 bit, stereo
System.exit(-1);
// Create a Player for the capture device:
try{
Player p = Manager.createPlayer(di.getLocator());
} catch (IOException e) {
} catch (NoPlayerException e) {}
[/CODE]

  • 0

Is it a compile error or a runtime error?

sorry went to bed xD was 5 am....

erm well it just said vector format not reconisged (or applicable) ... so i am trying to build up slowly using all the methods so at moment i am using this ...

and the error is a simple one but I dont understand this thing yet ...

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

The method getDeviceList(Format) in the type CaptureDeviceManager is not applicable for the arguments ()


public class AudioRecorder02 {
static CaptureDeviceInfo di = null;

public static void main(String args[]) {
CaptureDeviceManager.getDeviceList();
CaptureDeviceInfo deviceInfo = CaptureDeviceManager.getDevice("deviceName");
System.out.println(deviceInfo);
}
}
[/CODE]

  • 0

sorry went to bed xD was 5 am....

erm well it just said vector format not reconisged (or applicable) ... so i am trying to build up slowly using all the methods so at moment i am using this ...

and the error is a simple one but I dont understand this thing yet ...

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

The method getDeviceList(Format) in the type CaptureDeviceManager is not applicable for the arguments ()


public class AudioRecorder02 {
static CaptureDeviceInfo di = null;

public static void main(String args[]) {
CaptureDeviceManager.getDeviceList();
CaptureDeviceInfo deviceInfo = CaptureDeviceManager.getDevice("deviceName");
System.out.println(deviceInfo);
}
}
[/CODE]

Make sure you're importing the right CaptureDeviceManager for the empty argument as there are two: [b]javax.media.cdm.CaptureDeviceManager [/b]and[b] javax.media.CaptureDeviceManager[/b]. The first one extends the second one to add a little more functionality to it. The second one doesn't accept an empty argument for getDeviceList though.

  • 0

Make sure you're importing the right CaptureDeviceManager for the empty argument as there are two: javax.media.cdm.CaptureDeviceManager and javax.media.CaptureDeviceManager. The first one extends the second one to add a little more functionality to it. The second one doesn't accept an empty argument for getDeviceList though.

Vector is a raw type. References to generic type Vector<E> should be parameterized

this is whatit says every time i try and use the vector "Vector deviceList = CaptureDeviceManager.getDeviceList();"

  • 0

Usually that should just come up as a warning and not an error. However you can put CaptureDeviceInfo as the parameter for the Vector.

ye that is the warning but i assumed thats what causing the error ... but i think i am wrong I jave changed my code again to try and get the whole data

and it comes up with this ... I am just thumbling around with this thing i really no clue ..

Exception in thread "main" java.util.NoSuchElementException

at java.util.Vector.firstElement(Vector.java:485)

at AudioRecorder02.main(AudioRecorder02.java:20)


import java.io.IOException;
import java.util.Vector;
import javax.media.CaptureDeviceInfo;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.cdm.*;
import javax.media.format.AudioFormat;
public class AudioRecorder02 {
static CaptureDeviceInfo di;


public static void main(String args[]) {
Vector deviceList = CaptureDeviceManager.getDeviceList();
di = (CaptureDeviceInfo) deviceList.firstElement();
System.out.println(di);
// Create a Player for the capture device:}
}
[/CODE]

  • 0

ye that is the warning but i assumed thats what causing the error ... but i think i am wrong I jave changed my code again to try and get the whole data

and it comes up with this ... I am just thumbling around with this thing i really no clue ..

Exception in thread "main" java.util.NoSuchElementException

at java.util.Vector.firstElement(Vector.java:485)

at AudioRecorder02.main(AudioRecorder02.java:20)


import java.io.IOException;
import java.util.Vector;
import javax.media.CaptureDeviceInfo;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.cdm.*;
import javax.media.format.AudioFormat;
public class AudioRecorder02 {
static CaptureDeviceInfo di;


public static void main(String args[]) {
Vector deviceList = CaptureDeviceManager.getDeviceList();
di = (CaptureDeviceInfo) deviceList.firstElement();
System.out.println(di);
// Create a Player for the capture device:}
}
[/CODE]

That means the Vector is empty and it couldn't find any devices. Did you use the installer version and run the JMF Registry scanner?

post-13022-0-70343000-1356356208.png

This topic is now closed to further replies.
  • Posts

    • The better these AI models get, the more this is going to happen. It's gonna turn into government versus government in regards to using proprietary and unavailable security research models to basically find flaws and vulnerabilities in other governments or companies systems. It's basically turning into a cybersecurity arms race. This is actually a good thing. The better AI gets, the more restricted and expensive it's going to become, making it far less mainstream. This is good 👍
    • Crazy. The government fired everyone who was capable of actually understanding this. More security theater. Just checked it is gone from Claude.
    • bring trump to the board, then apple will have some innovation to talk about
    • Microsoft released Windows 11 KB5094149 / KB5095971 / KB5094156 Setup, Recovery updates by Sayan Sen Earlier this week Microsoft released its newest Patch Tuesday updates (KB5094126 / KB5093998 on Windows 11 and KB5094127 on Windows 10). Alongside those, Microsoft also released new dynamic updates. These Dynamic Update packages are meant to be applied to existing Windows images prior to their deployment. Dynamic Updates also help preserve Language Pack (LP) and Features on Demand (FODs) content during the upgrade process. VBScript, for example, is currently an FOD on Windows 11 24H2. This time both recovery and setup updates were released for Windows 11 as well as Windows 10. The company writes: "KB5095185: Safe OS Dynamic Update for Windows 11, version 26H1: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.28000.2269. KB5094149: Safe OS Dynamic Update for Windows 11, versions 24H2 and 25H2: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.26100.8655 KB5095971: Setup Dynamic Update for Windows 11, version 23H2: June 9, 2026 This update makes improvements to Windows setup binaries or any files that setup uses for feature updates in Windows 11, version 23H2. KB5094156: Safe OS Dynamic Update for Windows 11, version 23H2: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.22621.7219 KB5098815: Windows Recovery Environment update for Windows 10, version 21H2 and 22H2: June 9, 2026 This update automatically applies Safe OS Dynamic Update (KB5094154) to the Windows Recovery Environment (WinRE) on a running PC. The update installs improvements to Windows recovery features. KB5094154: Safe OS Dynamic Update for Windows 10, versions 21H2 and 22H2: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.19041.7417. KB5094153: Safe OS Dynamic Update for Windows 10, version 1809 and Windows Server 2019: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.17763.8880. KB5094152: Safe OS Dynamic Update for Windows 10, version 1607 and Windows Server 2016: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.14393.9234." Microsoft notes that both the Recovery and Setup updates will be downloaded and installed automatically via the Windows Update channel.
    • Quantum Error Correction Validated in Nature: Microsoft and Quantinuum Log 800-Fold Improvement Two years after the original press-release announcement, independently peer-reviewed results published in Nature on June 10, 2026, have confirmed that Microsoft and Quantinuum achieved an 800-fold reduction in quantum error rates on real trapped-ion hardware — the largest gap between physical and logical error rates ever independently validated.    What Quantum Error Correction Actually Does — and Why Breaking Even Is Hard https://www.techtimes.com/articles/318329/20260613/quantum-error-correction-validated-nature-microsoft-quantinuum-log-800-fold-improvement.htm   Quantum Computing Wiring Bottleneck Cracked by HKU Silicon Carbide Chip at Qubit Temperature Engineers at the University of Hong Kong have built the first cryogenic control chip that operates at the same temperature as superconducting qubits — 10 millikelvin, or just one-hundredth of a degree above absolute zero — without generating the heat that has forced every competing approach to park its electronics hundreds of meters of cable away. https://www.techtimes.com/articles/318325/20260613/quantum-computing-wiring-bottleneck-cracked-hku-silicon-carbide-chip-qubit-temperature.htm  
  • Recent Achievements

    • Week One Done
      agatameier earned a badge
      Week One Done
    • One Month Later
      agatameier earned a badge
      One Month Later
    • Week One Done
      ssd21345 earned a badge
      Week One Done
    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      +Edouard
      175
    3. 3
      PsYcHoKiLLa
      139
    4. 4
      ATLien_0
      91
    5. 5
      Steven P.
      76
  • Tell a friend

    Love Neowin? Tell a friend!