wave

Plotting wave equation

蹲街弑〆低调 提交于 2019-12-06 04:57:45
问题 I have been trying to plot a plane wave equation in Matlab. I am trying to plot the real part of, $(1/R)E^i(kR+wT)$ i.e. $(1/R)cos(kR+wT)$. So I used the following code in Matlab (for a single instant, say t=5), x=-5:0.1:5; y=-5:0.1:5; t=5; w=1.3; k=1.3; [X,Y]=meshgrid(x,y); R=(X.^2+Y.^2)^1/2; u=20*cos(k*R+w*t); surf(X,Y,u); When I run this code, I get the following surface plot: This looks fine I think, as one would expect. But if I increase the wavenumber and angular frequency factors to 15

Android:Creating Wave file using Raw PCM, the wave file does not play

浪尽此生 提交于 2019-12-05 10:00:04
问题 I have created the header for the wave file, but the wave file which is created does not play. I have used this https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ as a reference to create the wave header. public void WriteWaveFileHeader() throws IOException { File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/aaa.wav"); f.createNewFile(); FileOutputStream fos = new FileOutputStream(f); long longSampleRate=44100; int channels= AudioFormat.CHANNEL_IN_MONO;

How to create a numpy array from a pydub AudioSegment?

非 Y 不嫁゛ 提交于 2019-12-04 23:15:50
I'm aware of the following question: How to create a pydub AudioSegment using an numpy array? My question is the right opposite. If I have a pydub AudioSegment how can I convert it to a numpy array? I would like to use scipy filters and so on. It is not very clear to me what is the internal structure of the AudioSegment raw data. Pydub has a facility for getting the audio data as an array of samples , it is an array.array instance (not a numpy array) but you should be able to convert it to a numpy array relatively easily: from pydub import AudioSegment sound = AudioSegment.from_file("sound1

How to convert a wav file -> bytes-like object?

我是研究僧i 提交于 2019-12-04 16:56:22
I'm trying to programmatically analyse wav files with the audioop module of Python 3.5.1 to get channel, duration, sample rate, volumes etc. however I can find no documentation to describe how to convert a wav file to the 'fragment' parameter which must be a bytes-like object. Can anybody help? file.read() returns a bytes object, so if you're just trying to get the contents of a file as bytes , something like the following would suffice: with open(filename, 'rb') as fd: contents = fd.read() However, since you're working with audioop , what you need is raw audio data , not raw file contents.

Read the data of a single channel from a stereo wave file in Python

谁说胖子不能爱 提交于 2019-12-04 14:49:05
问题 I have to read the data from just one channel in a stereo wave file in Python. For this I tried it with scipy.io: import scipy.io.wavfile as wf import numpy def read(path): data = wf.read(path) for frame in data[1]: data = numpy.append(data, frame[0]) return data But this code is very slow, especially if I have to work with longer files. So does anybody know a faster way to do this? I thought about the standard wave module by using wave.readframes() , but how are the frames stored there? 回答1:

Plotting wave equation

早过忘川 提交于 2019-12-04 10:06:44
I have been trying to plot a plane wave equation in Matlab. I am trying to plot the real part of, $(1/R)E^i(kR+wT)$ i.e. $(1/R)cos(kR+wT)$. So I used the following code in Matlab (for a single instant, say t=5), x=-5:0.1:5; y=-5:0.1:5; t=5; w=1.3; k=1.3; [X,Y]=meshgrid(x,y); R=(X.^2+Y.^2)^1/2; u=20*cos(k*R+w*t); surf(X,Y,u); When I run this code, I get the following surface plot: This looks fine I think, as one would expect. But if I increase the wavenumber and angular frequency factors to 15, I get the following: It appears to be an interference pattern but I have no idea why I am getting

Android:Creating Wave file using Raw PCM, the wave file does not play

依然范特西╮ 提交于 2019-12-03 21:26:03
I have created the header for the wave file, but the wave file which is created does not play. I have used this https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ as a reference to create the wave header. public void WriteWaveFileHeader() throws IOException { File f = new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/aaa.wav"); f.createNewFile(); FileOutputStream fos = new FileOutputStream(f); long longSampleRate=44100; int channels= AudioFormat.CHANNEL_IN_MONO; long totalAudioLen=fos.getChannel().size(); long byteRate=(16 * 44100)/8; long totalDataLen

AVAudioRecorder doesn't write out proper WAV File Header

陌路散爱 提交于 2019-12-03 09:30:36
问题 I'm working on a project on the iPhone where I'm recording audio from the device mic using AVAudioRecorder, and then will be manipulating the recording. To ensure that I'm reading in the samples from the file correctly, I'm using python's wave module to see if it returns the same samples. However, python's wave module returns "fmt chunk and/or data chunk missing" when trying to open the wav file that is saved by AVAudioRecorder. These are the settings I am using to record the file:

Read the data of a single channel from a stereo wave file in Python

此生再无相见时 提交于 2019-12-03 08:32:00
I have to read the data from just one channel in a stereo wave file in Python. For this I tried it with scipy.io: import scipy.io.wavfile as wf import numpy def read(path): data = wf.read(path) for frame in data[1]: data = numpy.append(data, frame[0]) return data But this code is very slow, especially if I have to work with longer files. So does anybody know a faster way to do this? I thought about the standard wave module by using wave.readframes() , but how are the frames stored there? scipy.io.wavfile.read returns the tuple (rate, data) . If the file is stereo, data is a numpy array with

remove silence at the beginning and at the end of wave files with PyDub

空扰寡人 提交于 2019-12-02 20:56:38
How can I remove the silence from the beginning and the end of wave files with PyDub? I guess I should access segment by segment and check whether it's silent or not (but I'm not able to do it) :/ e.g. I have a wave file with silence at the beginning, end, or both (like below) and I want to remove the silence at the beginning and at the end of the file: e.g. I want to import it sound = AudioSegment.from_wav(inputfile) cycle for every sample of sound to check whether it's silent and mark the last silent sample since when the waves starts (marker1), then get to the last sample before the wave