• 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

    • No its not, there are ton of Youtube videos to get you started, what do you think people did before AI existed?
    • Read this in Humor Simpson 's voice, "Out of my way Moe".
    • You still can, its just under the Transform flyout for WordArt now
    • Likely nothing will be done in corporate America, there have been countless Tesla self-driving incidents. Then again, there have also been countless human operated incidents. It's literally daily news here in Canada, to the extent that it's now odd if we get a day where a collision doesn't get announced on the radio throughout the day...
    • SKG Hand Massager with Heat OS500 hands on by Steven Parker I was offered the chance to test out the SKG Hand Massager with Heat OS500, and full disclosure, they let me keep it regardless of my findings. Anyway, I jumped at the chance due to my long hours sitting at my desk, mousing around. Apologies for the knife cut across the top of the box; that was my doing, being a bit too heavy-handed with opening up the outer packaging. First up, what's in the box: SKG Hand Massager with Heat OS500 1x Type-C charging cable User Manual 1-Year Warranty (card) In short, everything you need to get started. According to the official Amazon listing, here are the key features: Full-Hand Air Compression: OS500 wraps your fingers, palm, and wrist with multi-chamber air compression for a complete hand relaxation experience. The extended massage chamber helps cover more of the hand and wrist area than standard palm-only hand massagers Palm Kneading with 6 Modes & 6 Intensities: Built-in palm kneading rollers add a hands-on massage feel, while 6 preset modes and 6 pressure levels let you choose the comfort level that fits your day—from gentle relaxation to a firmer full-hand massage 3 Heat Levels with Cooling Fan: Choose from 104°F, 113°F or 122°F warmth to suit different seasons and comfort preferences. The built-in cooling fan helps reduce stuffiness during heated sessions, keeping your hand feeling fresh and comfortable Easy Visual Display & Smart Timer: The digital image display clearly shows massage area, mode, intensity, heat level, and remaining time at a glance. Select 10, 15, or 20-minute sessions for quick office breaks, evening relaxation, or everyday hand care Rechargeable, Cordless & Comfortable: A 3000mAh battery supports over 90 minutes of full-function use on a full charge, with convenient USB-C charging. The soft inner lining, smooth ABS/PU finish, and premium black-gold design make OS500 ideal for home, office, or gifting With all that out of the way, here are my own findings. I gave it a try on both left and right hands, and as you can maybe see from the above YouTube Short, (sorry for the shaky video), my whole hand fits in, but my wrist barely enters the Hand Massager. I was able to push through a bit more with my fingertips extending out the other end to get a bit of massaging on the start of my wrist. Usage For some reason, there is a strap that is very difficult to fasten to my wrist with one hand. I am not sure what function it has, and it isn't mentioned in the user manual. The only thing I could find was in the product images that claimed "wrist precision". Unlike the Bob and Brad Hand Massager, this device does not massage the wrist anyway, even though a "wrist mode" is mentioned, which must be for smaller hands than I have, as it is mainly intended for the hand and fingers. In addition, for its steeper price, there are no disposable gloves provided in the box, which is a bit of an issue considering the internal cover (which appears to be elasticated nylon) cannot be removed for washing; so you are left with only one choice: always thoroughly wash your hands before using it. I can imagine this thing getting a bit grimy after a period of use, and that is a bit of a shame. With that said, the buttons on the device, from left to right, do the following: Heat button: 3-level heat control at 104°F, 113°F, or 122°F Mode button: Auto mode Circular mode Soothing mode Relax mode Palm and fingers mode Palm and wrist mode Intensity button: from (First-time users) 15Ka, 25Ka, 35Ka, 45Ka, 55Ka, 60Ka (Intensive relief) Knead button: on or off (6 pressure levels) Power button: Long-press to turn on or off Cooling button: turn on or off the cooling fan Also, in the product imagery, it states there are 36 "custom modes," but nowhere is it listed what these modes are. I can only imagine that they mean a combination of all of the above settings in different intensity levels. The device itself seems to rely on a single "kneading" mechanism located at the palm area of the hand, which spins when in use, and the other massage features are mainly utilized through the air sacs, increasing and decreasing at various levels on the hand and fingers. I am not sure it offered too much relief for someone who is typing and operating a mouse for hours at a time; further testing may be required. It does feel nice, though. Finally, you may be wondering how this fits into the scope of a tech website? Well, let me tell you something: sometimes I sit for up to 15 hours working on Neowin, and although I take breaks in between, it takes a toll on my body. I think in the immediate absence of a partner to apply relief, a good massager like this Hand Massager can shed the strains of the day in just a couple of 15-minute bursts. On the official website, this has an MSRP of $99.99, but luckily for our readers, it is selling at $10 off for just $89.99 right now on Amazon. SKG Hand Massager with Heat OS500 for $89.99 (with $10 off coupon), $99.99 MSRP For me, this gets a thumbs hands(?) down. However, it could be improved by making it so that the protective covering could be removed and thrown into the washing machine, or get yourself some disposable gloves to use with it. As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Dedicated
      Almohandis earned a badge
      Dedicated
    • Dedicated
      JuvenileDelinquent earned a badge
      Dedicated
    • First Post
      DrWankel earned a badge
      First Post
    • Reacting Well
      DrWankel earned a badge
      Reacting Well
    • Week One Done
      Supreme Spray LV earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      +Edouard
      184
    3. 3
      PsYcHoKiLLa
      86
    4. 4
      Michael Scrip
      78
    5. 5
      Steven P.
      76
  • Tell a friend

    Love Neowin? Tell a friend!