javasound

How to implement Voice Activity Detection in Java?

亡梦爱人 提交于 2021-02-18 17:05:22
问题 I need to implement a voice activity detection algorithm in Java so that I can know when to start and/or stop recording audio. I am looking for an algorithm that can take either a byte[], a target-data-line, or an audio file as input. Also, a solution would preferably not use external dependencies. 回答1: Give a look at TarsosDSP as source of inspiration: It is so far the best open source Java library to deal with Audio Detection. It is purely written in Java and briefly provides:

Unknown frame size

喜你入骨 提交于 2021-02-10 17:43:25
问题 Trying to get the frame size of an audio file I am getting instead -1. I tried to look for the interpretation of of this result in the JavaDoc but it does not mention anything big. Here's the source code : import javazoom.spi.mpeg.sampled.file.MpegAudioFileReader; /*....*/ File file = new File("/home/songs/audio.mp3"); MpegAudioFileReader mpegAudioFileReader = new MpegAudioFileReader(); AudioInputStream audioInputStream = mpegAudioFileReader.getAudioInputStream(file); AudioFormat format =

How can I read info from .wave file using JavaSound (Java, Java Sound)

自闭症网瘾萝莉.ら 提交于 2021-02-10 05:34:27
问题 Hi I need to read SampleRate, SignalFrequency and Amplitude from .wave file. How can I do that using JavaSound? 回答1: You can get the sampling rate by getting a handle on the AudioFormat object: AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("test.wav")); AudioFormat audioFormat = audioInputStream.getFormat(); Once you have that, you can get the sample rate as follows: float sampleRate = audioFormat.getSampleRate(); As for the amplitude, that is basically the raw

How can I add some sound to my Java JFrame? [closed]

旧巷老猫 提交于 2021-02-05 12:20:05
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 months ago . Improve this question I am making a Java game in JFrame. The game is almost completed but I want to add some sound to it. Like when the game will start, the sound should also start. I have checked the Internet but the codes are either not working or are very long. Can anyone help

I need to convert audio file from μ-law to PCM

会有一股神秘感。 提交于 2021-01-28 10:21:51
问题 I need to convert wav file from FORMAT 1 to FORMAT 2 Format 1 : μ-law, 8000Hz, 64 kbps, mono FORMAT 2 : Container WAV Encoding PCM Rate 16K Sample Format 16 bit Channels Mono Following is the Code snippet : File file = new File("audio_before_conversion.wav"); AudioFormat audioFormat = new AudioFormat(16000, 16, 1, true , true); AudioInputStream audioInputStream1 = new AudioInputStream( new FileInputStream(file), audioFormat, numFrames); AudioSystem.write(audioInputStream1, Type.WAVE, new File

I need to convert audio file from μ-law to PCM

守給你的承諾、 提交于 2021-01-28 10:20:32
问题 I need to convert wav file from FORMAT 1 to FORMAT 2 Format 1 : μ-law, 8000Hz, 64 kbps, mono FORMAT 2 : Container WAV Encoding PCM Rate 16K Sample Format 16 bit Channels Mono Following is the Code snippet : File file = new File("audio_before_conversion.wav"); AudioFormat audioFormat = new AudioFormat(16000, 16, 1, true , true); AudioInputStream audioInputStream1 = new AudioInputStream( new FileInputStream(file), audioFormat, numFrames); AudioSystem.write(audioInputStream1, Type.WAVE, new File

I need to convert audio file from μ-law to PCM

痴心易碎 提交于 2021-01-28 10:18:27
问题 I need to convert wav file from FORMAT 1 to FORMAT 2 Format 1 : μ-law, 8000Hz, 64 kbps, mono FORMAT 2 : Container WAV Encoding PCM Rate 16K Sample Format 16 bit Channels Mono Following is the Code snippet : File file = new File("audio_before_conversion.wav"); AudioFormat audioFormat = new AudioFormat(16000, 16, 1, true , true); AudioInputStream audioInputStream1 = new AudioInputStream( new FileInputStream(file), audioFormat, numFrames); AudioSystem.write(audioInputStream1, Type.WAVE, new File

reading wav/wave file into short[] array

久未见 提交于 2021-01-24 08:15:55
问题 is there an api to read wav files into an array of short[]? i'm trying to read a wav file into short array. i couldn't find any built API for that 回答1: Bring it in via an AudioInputStream as one normally does for sound. With each buffer load you grab from the stream, iterate through it, two bytes at a time (if it is 16-bit encoding) and use your favorite algorithm to convert the two bytes to a single short int. (Depends if file is Big-Endian or Little-Endian.) Then, save the results by

Changing Volume with JLayer

跟風遠走 提交于 2021-01-23 07:54:14
问题 I have a very specific problem with JLayer in my Music-Player project. I want to include something to adjust the volume, but it seems it isn't that easy to implement. This is because JLayer isn't supporting it from itself. I excluded the Player class from my project and changed some methods and it works fine for playing mp3 . For adjusting the volume I added to the Player class this method: public boolean setGain(float newGain) { if (audio instanceof JavaSoundAudioDevice) { System.out.println

Changing Volume with JLayer

China☆狼群 提交于 2021-01-23 07:53:26
问题 I have a very specific problem with JLayer in my Music-Player project. I want to include something to adjust the volume, but it seems it isn't that easy to implement. This is because JLayer isn't supporting it from itself. I excluded the Player class from my project and changed some methods and it works fine for playing mp3 . For adjusting the volume I added to the Player class this method: public boolean setGain(float newGain) { if (audio instanceof JavaSoundAudioDevice) { System.out.println