wave

PyAudio - How mix wave file into a continuous stream

穿精又带淫゛_ 提交于 2019-12-11 14:22:26
问题 I want to write a very basic application that passes audio from microphone to speakers. This is very simple with pyaudio as described on https://people.csail.mit.edu/hubert/pyaudio/ . def passthrough(): WIDTH = 2 CHANNELS = 1 RATE = 44100 p = pyaudio.PyAudio() def callback(in_data, frame_count, time_info, status): return (in_data, pyaudio.paContinue) stream = p.open(format=p.get_format_from_width(WIDTH), channels=CHANNELS, rate=RATE, input=True, output=True, stream_callback=callback) stream

Number of Zero-crossings - Equation

梦想与她 提交于 2019-12-11 11:55:21
问题 I have written an algorithm that calculates the number of zero-crossings within a signal. By this, I mean the number of times a value changes from + to - and vice-versa. The algorithm is explained like this: If there are the following elements: v1 = {90, -4, -3, 1, 3} Then you multiply the value by the value next to it. (i * i+1) Then taking the sign value sign(val) determine if this is positive or negative. Example: e1 = {90 * -4} = -360 -> sigum(e1) = -1 e2 = {-4 * -3} = 12 -> signum(e2) =

How can i make the sound louder with Naudio c#?

末鹿安然 提交于 2019-12-11 09:21:28
问题 I am trying to increase the amplitude of the sound wave in my code. I have the buffer consisting of all the bytes needed to make the wave. Here is my code for the audio Playback: public void AddSamples(byte[] buffer) { //somehow adjust the buffer to make the sound louder bufferedWaveProvider.AddSamples(buffer, 0, buffer.Length); WaveOut waveout = new WaveOut(); waveout.Init(bufferedWaveProvider); waveout.Play(); //to make the program more memory efficient bufferedWaveProvider.ClearBuffer(); }

simulation error in verilog

喜你入骨 提交于 2019-12-11 07:28:23
问题 my code for the design block and the testbench compiles, however when i simulate i'm not getting the correct output. Can anyone tell me where i'm going wrong in my code? Here is the code for testbench: module testbench; reg [511:0]FROM_LS; reg CLK; reg [63:0]TO_IF_ID; initial begin CLK= 0; TO_IF_ID[63:0]=63'b0; FROM_LS[511:480]= 32'b00011_00000_00100_01100_11100_10111_01; FROM_LS[479:448]=32'b00_11000_00100_01111_11111_00011_10000; end always begin #10 CLK= ~ CLK; //FROM_LS[511:448]= ~ FROM

constructing a wav file and writing it to disk using scipy

不问归期 提交于 2019-12-11 04:48:51
问题 I wish to deconstruct a wave file into small chunks, reassemble it in a different order and then write it to disk. I seem to have problems with writing it after reassembling the pieces so for now I just try to debug this section and worry about the rest later. Basically I read the original wav into a 2D numpy array, break it into 100 piece stored within a list of smaller 2D numpy arrays, and then stack these arrays vertically using vstack: import scipy.io.wavfile as sciwav import numpy [sr

How to analyse frequency of wave file

不问归期 提交于 2019-12-11 01:23:30
问题 How to analyse frequency of wave file in a simple way? Without extra modules. 回答1: What does it mean "analyse"? It can mean lot of different things, but one of simplest way I know about is to use convolution which you may easily implement for discrete functions (you'll have the points in array or be trying discrete step): Which can be easily done by: for i in main_array: from = i - len(convolution_kernel)/2 // Todo: check boundaries result[i] = 0 for j in convolution_kernel: result[i] +=

Convert .wav file to binary and then back to .wav?

谁都会走 提交于 2019-12-10 22:44:49
问题 I'm doing a project in java which requires me to encrypt a wave file. So, is there a straight forward process to convert a wave file into binary and back? I'll be applying an encryption algorithm on the binary data. 回答1: Yes. File file = new File("music.wav"); byte[] data = new byte[file.length()]; FileInputStream in = new FileInputStream(file); in.read(data); in.close(); //encrypt data FileOutputStream out = new FileOutputStream(file); out.write(data); out.close(); Of course assuming it's

Play the contents of a sound retrieved from an url?

独自空忆成欢 提交于 2019-12-10 20:01:07
问题 I am retrieving the sound from: http://translate.google.com/translate_tts and writing it to a WAV file, when i double-click the file the sound plays ok, but when i use the WAVE module from python to open it, it gives me this error: wave.Error: file does not start with RIFF id I want to know if there is a way for openning this file, or if it is possible to play the sound without writing it before. Here is the relevant code: url = "http://translate.google.com/translate_tts?tl=%s&q=%s" % (lang,

How To Track No Sound Area In A Wav File?

梦想的初衷 提交于 2019-12-10 10:45:02
问题 How to track sections without sounds in a wav file? a small software what I want to develop is deviding a wav file, and it consider a no volume area as a deviding point. how can a program know that volume of a wav file is low? I'll use Java or MFC. 回答1: I've had success with silence detection by calculating RMS of the signal. This is done in the following manner (assuming you have an array of audio samples): long sumOfSquares = 0; for (int i = startindex; i <= endindex; i++) { sumOfSquares =

How create .wav file with a custom frequency tone / wave?

不羁的心 提交于 2019-12-10 09:07:54
问题 I have a problem with my wave generator. I'm trying to create a .wav file with sound of given frequency. The code I use: $freqOfTone = 21000; $sampleRate = 44100; $samplesCount = 80000; $amplitude = 0.25 * 32768; $w = 2 * pi() * $freqOfTone / $sampleRate; for ($n = 0; $n < $samplesCount; $n++) { $data->samples[1][] = 32768 + (int)($amplitude * sin($n * $w)); } Unfortunately, the output wave is incorrect, I get few frequencies instead of one: http://i49.tinypic.com/ab1nx0.png It should look