javasound

Conversion of Audio Format

旧时模样 提交于 2019-11-27 23:14:29
I am having trouble in converting the audio format of a WAV file. I am recording sound from my microphone and the sound is recorded in the following format: PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame I want to convert the above format to, ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame I am using the following code, InputStream is = request.getInputStream(); AudioInputStream ais = AudioSystem.getAudioInputStream(is); AudioFormat oldFormat = ais.getFormat(); AudioFormat newFormat = new AudioFormat(AudioFormat.Encoding.ULAW, 8000, 8, 1, 1, 8000, false) ; AudioInputStream lowResAIS =

JavaSound mixer with both Port(s) and DataLine(s)?

时光怂恿深爱的人放手 提交于 2019-11-27 23:03:43
问题 The diagrms in the JavaSound API Programmer's Guide appear to imply (pp. 19-20) that a Mixer can in principle have both DataLines and Ports. However, I was wondering if anyone had actually seen this configuration? What I witness is that where relevant, Mixers come in pairs, one with a source/target data line, and then the other with the corresponding Port. Has anyone witnessed a configuration as implied in the Guide, with a mixer having both port and data line (or am I misinterpreting the

What output and recording ports does the Java Sound API find on your computer? [closed]

妖精的绣舞 提交于 2019-11-27 21:23:35
问题 I'm working with the Java Sound API, and it turns out if I want to adjust recording volumes I need to model the hardware that the OS exposes to Java. Turns out there's a lot of variety in what's presented. Because of this I'm humbly asking that anyone able to help me run the following on their computer and post back the results so that I can get an idea of what's out there. A thanks in advance to anyone that can assist :-) import javax.sound.sampled.*; public class SoundAudit { public static

Sine Wave Sound Generator in Java

不问归期 提交于 2019-11-27 19:53:03
What's the simplest way to generate a sine wave sound at any frequency in Java? A sample size more than 2 bytes would help, but it doesn't really matter. Thanks Andrew Thompson See Beeper for a self-contained example. Perhaps something simpler? That 51 lines of snippet (repeated below - spaced out for single line & in-line comments) as shown at the top of the linked answer, is about as simple as generating a tone gets (OK, you can take out 5+ lines for the harmonic). People seem to assume it should be a method built into the toolkit to produce a pure tone. It is not, and takes a little

Increase playback speed of sound file in java

霸气de小男生 提交于 2019-11-27 18:55:03
问题 I'm looking for information on how I can increase the playback speed of a sound file using Java and it's sound API. I'm currently using a clip and an AudioInputStream to play back the file, but I'll be glad to change that if it means I can increase the playback speed. 回答1: I do this by using linear interpolation. As you step through your samples by some increment, use the fractional distance to create a value to stream. For example if you land at 1.25 (between a sample with value 10 and

Java getting input from MIDI keyboard

℡╲_俬逩灬. 提交于 2019-11-27 18:52:53
I have designed my own synthesizer in java and I now want to connect it with a midi keyboard. My class below searches through all the midi devices that have transmitters. It successfully finds my midi keyboard. I add my own receivers to each transmitter for each device so that it should pick up everything possible. From reading all the help documents and java doc I know that a Transmitter sends MidiEvents to a Receiver which then handles them with the send method. So I wrote my own inner class implementing Receiver and just used a println statement to check if there was anything detected at

javax.sound.sampled.LineUnavailableException : What am I getting this exception?

我只是一个虾纸丫 提交于 2019-11-27 18:48:12
问题 As the following method is called : private void beep_player_1() { try { //clip_Player_2.close(); clip_Player_1 = AudioSystem.getClip(); ais = AudioSystem.getAudioInputStream(new File(Constants.Player1_Default_Tone)); // PATH FOR THE .WAV FILE clip_Player_1.open(ais); clip_Player_1.loop(0); // PLAY ONCE }catch(Exception exc) { System.out.println(exc); } } LineUnavailableException get thrown. What could be the reason for this ? javax.sound.sampled.LineUnavailableException: line with format PCM

How can I draw sound data from my wav file?

情到浓时终转凉″ 提交于 2019-11-27 18:38:22
First off this is for homework or... project. I'm having trouble understanding the idea behind how to draw the sound data waves on to a graph in Java for a project. I have to make this assignment entirely from scratch with a UI and everything so basically making a .wav file editor. The main issue I'm having is getting the sound data into the graph to be drawn. Currently I have a randomly generated array of values just being drawn right now. So far I have a mini-program running and validating the wav file for it to actually be a wav file. I'm reading it in with a FileInputStream and validating:

Reading MIDI files in Java

喜夏-厌秋 提交于 2019-11-27 17:43:20
I'm trying to read in .MID files to a Java program, and would like to separate each note/chord so as to display them on a UI of some sort. I didn't have much luck using the Sequencer API in Java, and trying to use MidiFileReader directly didn't work for me either. I'll attach the code I used here, if anyone wants to see it: package miditest; import java.io.File; import java.io.IOException; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiSystem; import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.Sequence; import javax.sound.midi.Sequencer;

Best way to get Sound on Button Press for a Java Calculator?

↘锁芯ラ 提交于 2019-11-27 16:57:56
问题 I'm a learning Java student working on an independent project for my Resume. I decided to do a Java calculator because I know most of the components that make it up. One thing I don't know how to do is add sound on the button press. I have a vague idea what with the Audiostream input stuff. But I need unique sounds for each button on my calculator. Right now my calculator isn't completely finished (listeners don't work yet.) I was just wondering what would be the best way to incorporate my