javasound

What exactly does AudioInputStream.read method return?

一世执手 提交于 2019-12-08 06:19:26
I have some problems finding out, what I actually read with the AudioInputStream . The program below just prints the byte-array I get but I actually don't even know, if the bytes are actually the samples, so the byte-array is the audio wave . File fileIn; AudioInputStream audio_in; byte[] audioBytes; int numBytesRead; int numFramesRead; int numBytes; int totalFramesRead; int bytesPerFrame; try { audio_in = AudioSystem.getAudioInputStream(fileIn); bytesPerFrame = audio_in.getFormat().getFrameSize(); if (bytesPerFrame == AudioSystem.NOT_SPECIFIED) { bytesPerFrame = 1; } numBytes = 1024 *

How to draw a graph of sounds while recording in java sound?

人盡茶涼 提交于 2019-12-08 05:26:54
问题 I successfully recording java sounds from my micro phone and can draw the recorded wave file graph as in attached image. (I have tried to upload image from here a lot, but it is failed every time.i also used tinypic also but failed in uploading , i think there is some error in my internet connection, i will upload it later here. ) I am also attaching all my code. http://pastebin.com/EgW2ZcyJ Now, my question is i want to display Graphs for the sound while recording in real time .so if i try

Trimming audio (mp3 or wav file)

限于喜欢 提交于 2019-12-08 02:25:28
问题 I have a quick question regarding the modification of an audio file. I can access the samples through the input stream(decoding etc), but I cannot figure out a way to manipulate the samples in that input stream(could be the case of multiple samples). What I would like to achieve is to get a file Ex A.mp3 , cut out some seconds out of it and finally store it to a new file. By looking at the JavaSoundApi examples, I found that a file can be created in the following way: File fileOut = new File

Working with audio in Java

假装没事ソ 提交于 2019-12-08 02:03:36
问题 I went over Java's tutorial on sounds but somehow it is way too complex for a beginner. It is here My aim is this: Detect all the audio input and output devices let the user select a audio input device capture what the user says output it to the default audio output device Now how do I go about doing that? Is there a better tutorial available? What I have tried: import javax.sound.sampled.*; public class SoundTrial { public static void main(String[] args) { Mixer.Info[] info = AudioSystem

How to implement seek on mp3

大兔子大兔子 提交于 2019-12-08 01:52:52
问题 I am about to get into a project that involves decoding + playing an mp3 stream. I have a Java decoder (JLayer), but as far as I can see it has no seek functionality (I don't use the built in player, I need to implement my own player). Also, the stream is encrypted, so I need to decrypt + decode in real time - can't have an entire decrypted file. So how do you approach seeking on mp3 stream? I would like to set a time value, and get the appropriate offset in the file to decode from. Please

java.io.IOException: mark/reset not supported Java Audio Input Stream / Buffered Input Stream

白昼怎懂夜的黑 提交于 2019-12-08 01:13:51
问题 I'm in the process of creating a 2D Java Platform Game and I'm trying to get audio to play from a .wav file while the game is running... Below is an AudioPlayer class I created to take care of loading the resource into an Audio Input Stream import javax.sound.sampled.*; import java.io.*; import java.util.*; import java.net.*; public class AudioPlayer { private Clip clip; public AudioPlayer(String s) { try { /************/ InputStream is = getClass().getResourceAsStream(s); AudioInputStream

Popping/Crackling When Using a Java Source Data Line for Audio

萝らか妹 提交于 2019-12-08 00:27:03
问题 I am having a problem with a Java Source Data Line. I need to play a tone, so I've created a Tone class that just represents a tone. Everything works fine, except that when I play the sound, the speakers pop at the beginning of the sound. Is there any way to fix this? It is for a research project and needs to run without the crackling, as that could affect results. Source code below. Thanks! package edu.jhu.halberda.audiopanamath; import javax.sound.sampled.AudioFormat; import javax.sound

Simulate microphone Input

女生的网名这么多〃 提交于 2019-12-07 08:06:10
问题 I am trying to write a little program that reads a wav file and sends the output as if it would come from my microphone. Unfortunately I do not have much experience with the sound API. Background: What I am basically trying to realize is a program that plays a sound while I am in a voicechat (i.e Teamspeak, Ventrilo). To get that to work now I would have to switch the recording device to "What you hear", play the sound and then switch back to microphone. The program should simulate input from

Downsampling audio from 44.1kHz to 16kHz in Java

徘徊边缘 提交于 2019-12-07 04:47:09
问题 I have an application that records a speech sample from the user's microphone and uploads it to a server which then does some stuff with it. It seems I must record with the following parameters to avoid an IllegalArgumentException : Encoding encoding = AudioFormat.Encoding.PCM_SIGNED; float sampleRate = 44100.0F; int sampleSizeInBits = 16; int channels = 2; int frameSize = 4; float frameRate = 44100.0F; boolean bigEndian = false; But I need to have it recorded at 16khz, not 44.1, (sampleRate

Convert mp3 to wav in Java

时光怂恿深爱的人放手 提交于 2019-12-06 13:40:41
I installed the mp3spi to support reading mp3 files in my Java 8 project usng the javax.sound* libraries. My goal now is to write mp3 to a wav file. However, the result is incorrect. Here's the code in its simplest format: public static void mp3ToWav(InputStream mp3Data) throws UnsupportedAudioFileException, IOException { AudioInputStream mp3Stream = AudioSystem.getAudioInputStream(mp3Data); AudioFormat format = mp3Stream.getFormat(); AudioFormat convertFormat = new AudioSystem.write(mp3Stream, Type.WAVE, new File("C:\\temp\\out.wav")); } There's one other way as outlined here ( mp3 to wav