As I checked, usually it is 44100 Hz, but I am wondering for my own purposes can it be 490 KHz? Didn't notice any information about that in documentation. I successfully made a wavfile with 48000 Hz, but it's nearly the same that 44100.
import numpy as np
from scipy.io import wavfile
# User input
duration=5.0
toneFrequency_left=500 #Hz (20,000 Hz max value)
toneFrequency_right=1200 #Hz (20,000 Hz max value)
# Constants
samplingFrequency=495000
# Generate Tones
time_x=np.arange(0, duration, 1.0/float(samplingFrequency))
toneLeft_y=np.cos(2.0 * np.pi * toneFrequency_left * time_x)
toneRight_y=np.cos(2.0 * np.pi * toneFrequency_right * time_x)
# A 2D array where the left and right tones are contained in their respective rows
tone_y_stereo=np.vstack((toneLeft_y, toneRight_y))
# Reshape 2D array so that the left and right tones are contained in their respective columns
tone_y_stereo=tone_y_stereo.transpose()
# Produce an audio file that contains stereo sound
wavfile.write('stereoAudio.wav', samplingFrequency, tone_y_stereo)
CodePudding user response:
As far as I know, there isn't a max value for the Hz you can write, I've definitely written to files with higher rates, up to 96 kHz. That's about as high quality it gets as far as I've seen with audio files. Most audio files are 8 kHz I think, 44.1 and 48 are also common. 49 kHz is not as commonly seen.