Question
In Python. Write a function named tremolo that will produce a heavy tremolo effect on a sound, in this manner: For the first 2500 samples,
In Python. Write a function named tremolo that will produce a heavy tremolo effect on a sound, in this manner:
For the first 2500 samples, double the volume,
For the next 2500 samples, halve the volume,
For the next 2500 samples, double the volume,
For the next 2500 samples, halve the volume,
and so forth.
In other words, alternate increasing and decreasing the volume of the sound, in chunks of 2500 samples, until the end of the sound.
one way to do this problem is to use a sampleCounter variable in your code. Initialize the sampleCounter to zero, and increase sampleCounter by one each time you process a sample. A handy bit of arithmetic works well here: the expression
sampleCounter % 5000
computes the remainder after dividing sampleCounter by 5000. You can test that remainder each time you process a sample in your recipe, to check to see whether the sample should increase or decrease: louder for remainders under 2500 and quieter for remainders over 2499.)
From course using book Introduction to Computing and Programming in Python a Multimedia Approach.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started