wav

change wav file ( to 16KHz and 8bit ) with using NAudio

拥有回忆 提交于 2019-11-27 01:59:24
问题 I want to change a WAV file to 8KHz and 8bit using NAudio. WaveFormat format1 = new WaveFormat(8000, 8, 1); byte[] waveByte = HelperClass.ReadFully(File.OpenRead(wavFile)); Wave using (WaveFileWriter writer = new WaveFileWriter(outputFile, format1)) { writer.WriteData(waveByte, 0, waveByte.Length); } but when I play the output file, the sound is only sizzle. Is my code is correct or what is wrong? If I set WaveFormat to WaveFormat(44100, 16, 1), it works fine. Thanks. 回答1: A few pointers: You

How to handle Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()

試著忘記壹切 提交于 2019-11-27 01:45:44
问题 Below is my code in aspx page to allow playing audio's of wav format in the browser but with my current code I am unable to play wav audios in Chrome browser but it works in Firefox. How can I handle this exception? <script> window.onload = function () { document.getElementById("audio").play(); } window.addEventListener("load", function () { document.getElementById("audio").play(); }); </script> <body> <audio id='audio' controls autoplay> <source src="Sounds/DPM317.wav" type="audio/wav" />

Convert audio stream to WAV byte array in Java without temp file

微笑、不失礼 提交于 2019-11-27 01:25:09
问题 Given an InputStream called in which contains audio data in a compressed format (such as MP3 or OGG), I wish to create a byte array containing a WAV conversion of the input data. Unfortunately, if you try to do this, JavaSound hands you the following error: java.io.IOException: stream length not specified I managed to get it to work by writing the wav to a temporary file, then reading it back in, as shown below: AudioInputStream source = AudioSystem.getAudioInputStream(new BufferedInputStream

Trouble playing wav in Java

巧了我就是萌 提交于 2019-11-27 01:22:53
I'm trying to play a PCM_UNSIGNED 11025.0 Hz, 8 bit, mono, 1 bytes/frame file as described here (1) and here(2) . The first approach works, but I don't want to depend on sun.* stuff. The second results in just some leading frames being played, that sounds more like a click. Can't be an IO issue as I'm playing from a ByteArrayInputStream. Plz share your ideas on why might this happen. TIA. McDowell I'm not sure why the second approach you linked to starts another thread; I believe the audio will be played in its own thread anyway. Is the problem that your application finishes before the clip

How to write stereo wav files in Python?

半世苍凉 提交于 2019-11-26 23:08:36
问题 The following code writes a simple sine at frequency 400Hz to a mono WAV file. How should this code be changed in order to produce a stereo WAV file. The second channel should be in a different frequency. import math import wave import struct freq = 440.0 data_size = 40000 fname = "WaveTest.wav" frate = 11025.0 # framerate as a float amp = 64000.0 # multiplier for amplitude sine_list_x = [] for x in range(data_size): sine_list_x.append(math.sin(2*math.pi*freq*(x/frate))) wav_file = wave.open

java wav player adding pause and continue

时光总嘲笑我的痴心妄想 提交于 2019-11-26 21:45:26
问题 I have this code which plays wav files from a folder with play and stop. How can I add pause and continue? import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; import java.applet.AudioClip; import java.net.URL; public class JukeBox extends JFrame { private JComboBox musicCombo; private JButton stopButton, playButton; private AudioClip[] music; private AudioClip current; public JukeBox(String title) { super(title); getContentPane().add(new

How can I detect whether a WAV file has a 44 or 46-byte header?

老子叫甜甜 提交于 2019-11-26 20:14:35
问题 I've discovered it is dangerous to assume that all PCM wav audio files have 44 bytes of header data before the samples begin. Though this is common, many applications (ffmpeg for example), will generate wavs with a 46-byte header and ignoring this fact while processing will result in a corrupt and unreadable file. But how can you detect how long the header actually is? Obviously there is a way to do this, but I searched and found little discussion about this. A LOT of audio projects out there

C++ Reading the Data part of a WAV file

萝らか妹 提交于 2019-11-26 18:59:47
问题 I plan to create a program that will visualize the audio waveform of a .wav file. So far, I have started by properly reading the header part of the said wav file. The code I use would be this: #include <iostream> #include <string> #include <fstream> using namespace std; using std::string; using std::fstream; typedef struct WAV_HEADER{ char RIFF[4]; // RIFF Header Magic header unsigned long ChunkSize; // RIFF Chunk Size char WAVE[4]; // WAVE Header char fmt[4]; // FMT header unsigned long

What do the bytes in a .wav file represent?

元气小坏坏 提交于 2019-11-26 18:55:17
问题 When I store the data in a .wav file into a byte array, what do these values mean? I've read that they are in two-byte representations, but what exactly is contained in these two-byte values? 回答1: 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

Writing musical notes to a wav file

眉间皱痕 提交于 2019-11-26 17:54:59
问题 I am interested in how to take musical notes (e.g A, B, C#, etc) or chords (multiple notes at the same time) and write them to a wav file. From what I understand, each note has a specific frequency associated with it (for perfect pitch) - for example A4 (the A above middle C) is 440 Hz (complete list 2/3 of the way down This Page). If my understanding is correct, this pitch is in the frequency domain, and so needs the inverse fast fourier transform applying to it to generate the time-domain