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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!