Lab 8

C · Local Linux terminal

Find the missing notes in a chord

Your computer

Listen to the reference recording

Embedded Systems · Audio · C on Linux. Build a one-second stereo chord from a thirteen-switch score. You need a C compiler and Python 3. Work from the extracted worksheet directory. The output is a WAV file you can play or measure locally.

Listen to a three-note request

The leftmost bit selects middle C. Each position to its right rises by one semitone. Bit positions 0, 4 and 7 make a C major triad. Predict which pitches a correct program would produce and which of them you actually expect to see after reading the inner loop.

cc -std=c11 -O2 -Wall -Wextra -Werror starter/chord.c -lm -o chord
./chord 1000100100000 before.wav
python3 resources/inspect_audio.py chord before.wav

The meter prints thirteen amplitudes in low-to-high note order. For this recording, an amplitude above 50 identifies a sounding note. Listen if you have speakers. Can a single low-to-high zero-crossing count tell you which three notes are present?

Repair and stress the mixer

Inspect what happens to total every time the inner loop discovers another selected note. Make the smallest edit that retains all contributors to a frame. Recompile, write after.wav, measure it and fill in the table. Use another filename for each trial.

Score Expected note positions Heard or measured before Measured after
1000100100000
0100010010000
0000000000000
1111111111111

Explain why the code scales the sum before converting to a signed integer. Bound the largest possible absolute sample when all thirteen notes are active. Then edit the score to play a two-note interval of your choice. Submit the score, measured positions, before/after triad results and your bound. Include the WAV files or the meter's output.

FPGAcademy audio exercise · Exercise notice · LabsLand source license

Compare three recorded DE1-SoC oscilloscope traces