This project renders animated pumpkin faces fullscreen using Pygame. Each face has independent eye movement and blinking, while its mouth can either animate continuously or respond to microphone volume.
The display uses the second monitor when one is available and falls back to the primary display otherwise.
The project now uses one program, pumpkin_faces.py:
./run_pumpkin.shChoose the microphone mode by editing MICROPHONE_MODE near the top of
pumpkin_faces.py:
"default"uses the operating system's default microphone. All microphone-enabled pumpkins respond to that one input."custom"uses the two-channelDJI MIC MINIreceiver. Channel 1 drives the left pumpkin's mouth and channel 2 drives the right pumpkin's mouth.
The DJI receiver must output the microphones as separate stereo channels. If it is in mono or merged mode, both USB channels contain the combined signal and both mouths will respond to both microphones.
To switch the DJI receiver to separate stereo output:
- Turn on the receiver and both transmitters.
- Connect the receiver to the computer.
- Press the receiver's Link button to switch the audio output between merged mono and separate stereo.
- Start
./run_pumpkin.shagain after changing the mode.
Create the virtual environment, activate it, and install the dependencies:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txtThe launcher scripts use .venv/bin/python directly, so activation is not
required when using the launchers.
- Press Escape to exit fullscreen mode.
- Edit the
PUMPKINSconfiguration inpumpkin_faces.pyto change positions, scale, appearance, or microphone assignments.
The DJI mode identifies the receiver by the device name DJI MIC MINI. If the
operating system reports a different name, update MICROPHONE_DEVICE.
Settings are edited near the top of pumpkin_faces.py.
The default is AUDIO_SOURCE = "system". This should display the pumpkins on a second screen (projector), output anything you play to your device speakers, as well as forward sound to the second screen's audio output.
Three pumpkins will be displayed on the screen, each with independent mouth and eye movements.
To use the microphone instead, set AUDIO_SOURCE = "microphone" and configure MICROPHONE_MODE and MICROPHONE_DEVICE accordingly. default is the operating system's default microphone.
A custom microphone mode uses the device specified in MICROPHONE_DEVICE and the number of channels specified in MICROPHONE_CHANNELS. Each channel can drive a different pumpkin's mouth. This script is configured to support the DJI MIC MINI with two channels.
BLACKis the background colour.PUMPKINis the main pumpkin colour. You can also disable showing the pumpkin flesh by settingSHOW_PUMPKIN_FLESH = False.CARVE_GLOWis the orange glow used for the carved features.
Colours use RGB tuples, with each component from 0 to 255. For example,
(255, 0, 0) is red.
The program automatically uses display 2 when it is available and otherwise
uses display 1. The fullscreen display selection is controlled by the
target_display expression near the top of the file; its values are
zero-based, so 0 is the first display and 1 is the second.
These settings are available in both programs:
(Leave these alone unless you know what you are doing.)
MICROPHONE_BLOCKSIZEcontrols the number of audio samples processed per callback. Smaller values can reduce latency but use more processing.MICROPHONE_LATENCYis passed to the audio driver."high"gives the speaker output more buffering to avoid playback underflows.AUDIO_SAMPLE_RATEsets the shared input/output sample rate. It is set to48000so the DJI receiver and the speaker output can be used in one duplex stream.AUDIO_OUTPUT_DEVICEselects the speaker output used for live microphone monitoring. It defaults topipewire, which follows the operating system's selected/default speaker or display audio sink on Linux. Set it to an exact speaker or HDMI display audio device name only if you need to override the system default.SYSTEM_AUDIO_NOISE_FLOORprevents low-level speaker-loopback noise from opening the mouths when no system audio is playing.SYSTEM_AUDIO_GAINcontrols how strongly system playback opens the mouths.
Change these only if you need to customize the audio input or output behavior.
AUDIO_MONITORINGtoggles forwarding microphone audio to the selected speaker. Set it toFalseto analyze the microphones without playback.AUDIO_SOURCEselects the signal used for mouth animation:"microphone"uses the configured default or DJI microphone input."system"captures the stereo system-audio loopback fromAUDIO_OUTPUT_DEVICE.
AUDIO_SOURCE_GAINscales the captured waveform before any mouth processing. This changes only animation sensitivity; it does not change the actual microphone or speaker volume. For example,0.5makes all mouths respond to half-strength input, which helps prevent loud songs from holding them fully open.MICROPHONE_MODEselects"default"or"custom".MICROPHONE_CHANNELS, which should remain2for the two-transmitter receiver whenMICROPHONE_MODEis"custom".MICROPHONE_DEVICE, the audio device name used for the DJI receiver whenMICROPHONE_MODEis"custom".
When AUDIO_SOURCE is "system", the script derives the loopback source from
AUDIO_OUTPUT_DEVICE. The generic pipewire value follows the operating
system's default speaker. If AUDIO_OUTPUT_DEVICE is changed to a specific
speaker or HDMI device name, its corresponding monitor is captured instead.
In system-audio mode, the first microphone channel uses the centered
mid-signal (left + right) as a lead-vocal estimate. The second uses the
stereo side-signal (left - right) as a backing-vocal/music estimate. This is
a lightweight stereo heuristic; it cannot perfectly separate vocals from a
finished stereo mix. Audio monitoring is disabled in this mode to avoid
feeding the captured playback back into the speakers.
The PUMPKINS list controls how many pumpkins are drawn. Each dictionary in
the list creates one pumpkin. Add a dictionary to add a pumpkin, remove one to
remove it, or reorder dictionaries to change their order and microphone
assignments.
Each pumpkin supports these settings:
-
center:(x, y)position as normalized coordinates from0.0to1.0.(0.0, 0.0)is the top-left corner and(1.0, 1.0)is the bottom-right. For example,(0.25, 0.5)places a pumpkin one quarter across and halfway down the display. -
scale: pumpkin size as a fraction of the display height. Increase it to make the pumpkin larger. -
angry:Truegives the pumpkin angular angry eyes and mouth;Falsegives it the regular face. -
mouth_speed: speed of the automatic mouth animation when microphone input is disabled. -
mouth_phase: optional starting phase for the automatic mouth animation. This is useful for keeping multiple non-microphone mouths out of sync. -
use_microphone:Truemakes the mouth respond to microphone input;Falseuses the automatic animation instead. -
mouth_audio_gain: per-pumpkin volume control for waveform-driven mouth movement.1.0is the current response,0.5makes the mouth half as sensitive, and values above1.0amplify the response. -
microphone_channel: zero-based input channel used by this pumpkin. Use0for the first receiver channel and1for the second receiver channel whenMICROPHONE_MODEis"custom". It is ignored in"default"mode.
For example, this creates three pumpkins across the display:
PUMPKINS = [
{
"center": (0.20, 0.50),
"scale": 0.16,
"angry": False,
"mouth_speed": 5.0,
"use_microphone": True,
"microphone_channel": 0,
},
{
"center": (0.50, 0.50),
"scale": 0.16,
"angry": True,
"mouth_speed": 4.0,
"mouth_phase": 1.5,
"use_microphone": True,
"microphone_channel": 1,
},
{
"center": (0.80, 0.50),
"scale": 0.16,
"angry": False,
"mouth_speed": 6.0,
"mouth_phase": 3.0,
"use_microphone": False,
},
]In "default" mode, all microphone-enabled pumpkins respond to the single
default microphone. In "custom" mode, each pumpkin uses its configured
microphone_channel.
- Connect HDMI between laptop and projector
- Power on the projector.
- Turn on bluetooth speaker, connect to projector.
- Run ./run_pumpkin.sh
- Align with pumpkins, adjusting values in the
PUMPKINSlist as needed. - Open spotify on laptop, select playlist and set on repeat.
- Ensure pumpkin script is focussed on laptop.
- When ready, start the show by playing the music from phone.
- Enjoy the pumpkin show!
While the programme is running, press 1-9 to select a pumpkin, use the
arrow keys to adjust its centre, and press < or > to decrease or increase
its scale. Hold an arrow key to keep moving the pumpkin. Press Enter to print
the selected pumpkin's center and scale values in the terminal.