Get length of .wav from sox output
There is a better way: soxi -D out.wav
There is a better way: soxi -D out.wav
The wav container just adds a simple header to the raw PCM data. The header includes the format, sample rate, and number of channels. Since the raw PCM data does not include this information, you will need to specify it on the command line. Options are specified before the file they apply to, so options … Read more
You will have heard, that audio signals are represented by some kind of wave. If you have ever seen this wave diagrams with a line going up and down — that’s basically what’s inside those files. Take a look at this file picture from http://en.wikipedia.org/wiki/Sampling_rate You see your audio wave (the gray line). The current … Read more
You’re on the right track. Let’s take a look at your example: for(int i = 0; i < data.Length; i++) data[i] = (byte)(256 * Math.Sin(i)); OK, you’ve got 11025 samples per second. You’ve got 60 seconds worth of samples. Each sample is a number between 0 and 255 which represents a small change in air … Read more
Finally I managed to do the following and it works fine import java.io.File; import java.io.IOException; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; public class MakeSound { private final int BUFFER_SIZE = 128000; private File soundFile; private AudioInputStream audioStream; private AudioFormat audioFormat; private SourceDataLine sourceLine; /** * @param filename the name … Read more
As a follow up to Nick Fortescue’s answer, here’s a more complete example of how to record from the microphone and process the resulting data: from sys import byteorder from array import array from struct import pack import pyaudio import wave THRESHOLD = 500 CHUNK_SIZE = 1024 FORMAT = pyaudio.paInt16 RATE = 44100 def is_silent(snd_data): … Read more
Per the documentation, scipy.io.wavfile.read(somefile) returns a tuple of two items: the first is the sampling rate in samples per second, the second is a numpy array with all the data read from the file: from scipy.io import wavfile samplerate, data = wavfile.read(‘./output/audio.wav’)
Java FX has Media and MediaPlayer classes which will play mp3 files. Example code: String bip = “bip.mp3”; Media hit = new Media(new File(bip).toURI().toString()); MediaPlayer mediaPlayer = new MediaPlayer(hit); mediaPlayer.play(); You will need the following import statements: import java.io.File; import javafx.scene.media.Media; import javafx.scene.media.MediaPlayer;