Similar presentations:
Waves 6 lesson
1. SOUND PROCESSING
12. 6.3.1 USE COMMANDS OF THE WAVE LIBRARY TO PROCESSSOUND FILES
2.
Audio sampling is the process of transforming a musicalsource into a digital file. Digital audio recording does this
by taking samples of the audio source along the
soundwaves at regular intervals.
3.
• An audio frame, or sample, contains amplitude(loudness) information at that particular point in
time. To produce sound, tens of thousands of
frames are played in sequence to produce
frequencies.
4.
5.
6. Wave library
WAVE LIBRARY• Frames of *.wav file
• To get all the frames from an audio file, use the getnframes()
function
7. Wave library
WAVE LIBRARY• Read frames in *.wav file
• wave.readframes(wave.getnframes()) # read all frames from *.wav file.
8. Wave library
WAVE LIBRARY• Get information about wav-file
• You can use:
9.
10. Wave library
WAVE LIBRARY• The wave module provides a convenient interface to the WAV audio format. It does not support
compression/decompression, but it does support mono/stereo.
• To open a *.wav file, use the function open()
• wave.open(filename, mode=None)
• filename - *.wav file which is in the *.py file directory.
11. Wave library
WAVE LIBRARY• mode='rb' - режим только для чтения.
mode = 'wb' - режим только записи.
12. Wave library
WAVE LIBRARY• Download
• in.wav
wave.close() - close *.wav file.
• source.close()
dest.close()
13. Wave library
WAVE LIBRARY• to pass parameters from read file to write file use...
14. Working on google colab
WORKING ON GOOGLE COLABsetparams(tuple)
The tuple should be (nchannels, sampwidth, framerate, nframes, comptype,
compname), with values valid for the set*() methods. Sets all parameters
getparams()
Returns a namedtuple() (nchannels, sampwidth, framerate, nframes,
comptype, compname), equivalent to output of the get*() methods.
writeframes(data)
Write audio frames and make sure nframes is correct. It will raise an error
if the output stream is not seekable and the total number of frames that
have been written after data has been written does not match the
previously set value for nframes.
https://docs.python.org/3/library/wave.html
15. Task " Half sound "
TASK " HALF SOUND "Output the second half part of file in.wav.
16. Task " Reverse sound "
TASK " REVERSE SOUND "• Output to the out.wav reverse of file in.wav.
17.
18. Task " Speed up twice "
TASK " SPEED UP TWICE "• Write a program to speed up a file in.wav twice.
19. Task " Slow down twice "
TASK " SLOW DOWN TWICE "• Write a program to slow down the sound twice of file in.wav.