• 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

    • Weekend PC Game Deals: Anno 117, Final Fantasy VII, Rematch, and more by Pulasthi Ariyasinghe Weekend PC Game Deals is where the hottest gaming deals from all over the internet are gathered into one place every week for your consumption. So kick back, relax, and hold on to your wallets. The Epic Games Store's mystery giveaways may have ended, but its regular freebies didn't miss a step this week. The double drop was for copies of Warhammer 40K Speed Freeks and The Ouroboros King. Speed Freeks lands for multiplayer racing fans, but with plenty of competitive shooting elements too. You will be piloting Ork buggies, tanks, and aircraft modeled after the popular tabletop miniatures while trying to complete objectives and pass finish lines. Next, Ouroboros King is a crossover between chess and tactical roguelikes, offering the chance to create your own army with special rules to beat incoming foes on the board. The double giveaway on the Epic Games Store will be available until June 11, and replacing it will be Citizen Sleeper and ROBOBEAT. The Humble Store brought a new charity bundle to check out this week too. Landing with the name The Complete Inkle Library, this is a large collection of interactive narrative puzzle games from the publisher Inkle. This begins with Heaven's Vault, four parts from the Sorcery series, 80 Days, Overboard, and Pendragon: Narrative Tactics within the starting tier for $9. Hopping up a step to the $12 tier gets you TR-49, Expelled, and A Highland Song for paying at least $12. If you go for the $20 tier, you get four e-books from the Heaven's Vault series. The bundle has almost three weeks on its counter before it goes away. Big Deals There is a larger than normal amount of weekend specials happening this time, including multiple publisher deals, franchise discounts, and indie gems to grab. With those and more, here's our hand-picked big deals list for the weekend: Anno 117: Pax Romana – $44.99 on Steam Clair Obscur: Expedition 33 – $39.99 on Steam Timberborn – $27.99 on Steam EARTH DEFENSE FORCE 6 – $26.39 on Steam Rust – $19.99 on Steam FINAL FANTASY VII REBIRTH – $19.99 on Steam Street Fighter 6 – $19.99 on Steam Returnal – $19.79 on Steam Shape of Dreams – $17.49 on Steam Far Cry 6 – $14.99 on Steam Assassin's Creed Valhalla – $14.99 on Steam Quarantine Zone: The Last Check – $14.99 on Steam REMATCH – $14.99 on Steam EA SPORTS FC 26 – $13.99 on Steam FINAL FANTASY VII REMAKE INTERGRADE – $13.99 on Steam Magicraft – $12.79 on Steam Cult of the Lamb – $12.49 on Steam Dying Light 2: Reloaded Edition – $11.99 on Steam Cuphead – $11.99 on Steam Assassin's Creed Odyssey – $11.99 on Steam Hunt: Showdown 1896 – $11.99 on Steam Sektori – $11.99 on Steam Just Shapes & Beats – $11.99 on Steam Gunfire Reborn – $10.99 on Steam 33 Immortals – $9.99 on Epic Store Baby Steps – $9.99 on Steam Sifu – $9.99 on Steam Hearts of Iron IV – $9.99 on Steam DREDGE – $9.99 on Steam DAVE THE DIVER – $9.99 on Steam Pacific Drive – $9.89 on Steam Mycopunk – $9.74 on Steam Sons Of The Forest – $8.99 on Steam Jotunnslayer: Hordes of Hel – $8.99 on Steam Nuclear Throne – $8.99 on Steam Mechabellum – $8.99 on Steam Deep Rock Galactic: Survivor – $8.44 on Steam TerraTech Legion – $7.99 on Steam Inscryption – $7.99 on Steam Assassin's Creed Unity – $7.49 on Steam Minishoot' Adventures – $7.49 on Steam The Stanley Parable – $7.49 on Steam Oxygen Not Included – $7.49 on Steam Megabonk – $6.99 on Steam Look Outside – $5.99 on Steam Vampire Hunters – $5.24 on Steam MOTHERGUNSHIP – $4.99 on Steam My Friend Pedro – $3.99 on Steam The Messenger – $3.99 on Steam Vampire Survivors – $3.74 on Steam Brotato – $2.99 on Steam Enter the Gungeon – $2.99 on Steam Loop Hero – $2.99 on Steam GRIS – $2.99 on Steam Exit the Gungeon – $2.49 on Steam Hitman: Absolution – $1.99 on Steam CARRION – $1.99 on Steam Don't Starve Together – $1.49 on Steam Golf With Your Friends – $1.49 on Steam Hotline Miami – $0.99 on Steam The Ouroboros King – $0 on Epic Store Warhammer 40K Speed Freeks – $0 on Epic Store DRM-free Specials Hopping over to the DRM-free deals, the GOG store has plenty of discounts running this weekend too. Here are some highlights: Fallout 4: Game of the Year Edition - $15.99 on GOG Fallout: New Vegas Ultimate Edition - $9.99 on GOG Disco Elysium - The Final Cut - $9.99 on GOG Crysis - $9.99 on GOG Tyranny - Standard Edition - $7.49 on GOG Frostpunk: Game of the Year Edition - $7.35 on GOG Banished - $6.79 on GOG Fallout 3: Game of the Year Edition - $6.59 on GOG The Forgotten City - $6.25 on GOG The Age of Decadence - $5.99 on GOG SimCity 3000 Unlimited - $4.99 on GOG Assassin's Creed: Director's Cut - $4.99 on GOG SimCity 4 Deluxe Edition - $3.99 on GOG Vampyr - $3.99 on GOG Torchlight II - $3.99 on GOG Deus Ex GOTY Edition - $3.49 on GOG Primordia - $3.09 on GOG Theme Hospital - $2.99 on GOG SimCity 2000 Special Edition - $2.99 on GOG Total Annihilation: Kingdoms + Iron Plague - $2.99 on GOG Deus Ex: Human Revolution - Director’s Cut - $2.99 on GOG Master of Orion 1+2 - $2.39 on GOG Prince of Persia: The Sands of Time - $1.99 on GOG Prince of Persia: Warrior Within - $1.99 on GOG EVERSPACE - $1.99 on GOG Total Annihilation: Commander Pack - $0.99 on GOG Keep in mind that availability and pricing for some deals could vary depending on the region. That's it for our pick of this weekend's PC game deals, and hopefully, some of you have enough self-restraint not to keep adding to your ever-growing backlogs. As always, there are an enormous number of other deals ready and waiting all over the interwebs, as well as on services you may already subscribe to if you comb through them, so keep your eyes open for those, and have a great weekend.
    • When will the Photos app be updated to remember the window size and position when reopened? They addressed this issue in a 2024 version of the app (though I can't recall the build number). Unfortunately, after that specific version, the problem persists! Please prioritise this fix in your K2 schedule. Additionally, the Snipping Tool has lost the ability to capture the Windows Taskbar starting from the 2024 version!
    • Same, never saw it on Android or iOS. Guess only some people got it *shrugs*
    • Anthropic pulls Fable 5 and Mythos 5 after US export control order by Pradeep Viswanathan In April this year, Anthropic launched the Claude Mythos Preview frontier model with state-of-the-art cyber and coding capabilities for a select set of companies around the world. After preparing appropriate guardrails, early this week, Anthropic launched Claude Fable 5 and Mythos 5, its most capable AI models. Claude Fable 5 is for general users and comes with strict safeguards, while Mythos 5 is designed with fewer safeguards for cybersecurity and biology use cases. Today, Anthropic abruptly suspended access to its Fable 5 and Mythos 5 AI models for all customers after receiving an export control directive from the US government. The company received the directive from the government today at 5:21 p.m. ET, and the received letter did not provide any details regarding the national security concern. Anthropic understands that the government became aware of a method to bypass, or “jailbreak,” Fable 5, which might be the reason behind the directive. The order was issued under national security authorities and requires the company to suspend all access to Fable 5 and Mythos 5 by any foreign national, whether they are inside or outside the United States. The restriction also applies to foreign national employees working at Anthropic. As a result, the company has disabled both models for all customers to ensure compliance. Access to previous Anthropic models like Opus and Sonnet is not affected by this government order. The company highlighted that it had developed strong safeguards to reduce the possibility that Fable is misused for tasks related to cybersecurity. In fact, many developers are complaining that the safeguards are going overboard. Additionally, the company worked with the US government, the UK AISI, multiple private third-party organizations, and internal teams to red-team Fable’s safeguards for thousands of hours. Finally, Anthropic noted that no testers have yet been able to find a universal jailbreak on Fable 5. As expected, Anthropic disagrees that a narrow potential jailbreak should lead to the recall of a commercial model used by hundreds of millions of people. It warned that applying this standard across the AI industry could effectively halt new frontier model deployments. Anthropic concluded by mentioning that it is working to restore access to Fable 5 and Mythos 5 as soon as possible and plans to share more details within the next 24 hours.
  • Recent Achievements

    • Week One Done
      ssd21345 earned a badge
      Week One Done
    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
    • Rookie
      Rimplesnort went up a rank
      Rookie
    • One Year In
      Markus94287 earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      503
    2. 2
      +Edouard
      176
    3. 3
      PsYcHoKiLLa
      147
    4. 4
      ATLien_0
      92
    5. 5
      Steven P.
      79
  • Tell a friend

    Love Neowin? Tell a friend!