oneshotlm
Compare all models on this prompt →

Piano synth · qwen3-coder-flash

Using the pre-provided tone.min.js (global Tone), build a playable piano keyboard controlled by mouse and computer keys that synthesizes notes with an ADSR envelope and visual key feedback.

⚠ no runnable output

This one-shot run produced no runnable artifact.

agent produced no index.html

The transcript below shows what the model did — read it to see why the one shot fell short.

transcript · 2 messages
user

Using the pre-provided tone.min.js (global Tone), build a playable piano keyboard controlled by mouse and computer keys that synthesizes notes with an ADSR envelope and visual key feedback.

assistant

I'll create a playable piano keyboard with mouse and keyboard controls, ADSR envelope synthesis, and visual feedback. Let me build this as a single HTML file. ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Playable Piano Keyboard</title> <script src="tone.min.js"></script> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #1a2a6c, #b21f1f, #1a2a6c); font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; overflow: hidden; } .container { text-align: center; padding: 20px; background: rgba(0, 0, 0, 0.7); border-radius: 20px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: 90%; } h1 { color: #fff; margin-bottom: 10px; text-shadow: 0 0 10px rgba(255, 255, 255, 0.5); font-size: 2.5rem; } .subtitle { color: #ddd; margin-bottom: 30px; font-size: 1.1rem; } .keyboard { position: relative; height: 200px; margin: 0 auto; user-select: none; } .key { position: absolute; background: white; border: 1px solid #ccc; border-radius: 0 0 5px 5px; cursor: pointer; transition: all 0.1s ease; display: flex; justify-content: center; align-items: flex-end; padding-bottom: 10px; font-weight: bold; color: #333; box-shadow: 0 4px 0 #ddd, 0 6px 4px rgba(0, 0, 0, 0.2); } .white-key { width: 40px; height: 100%; z-index: 1; } .black-key { width: 24px; height: 60%; z-index: 2; background: #000; color: white; margin-top: 0; } .key.active { transform: translateY(2px); box-shadow: 0 2px 0 #aaa, 0 3px 2px rgba(0, 0, 0, 0.2); } .white-key.active { background: #ffd700; } .black-key.active { background: #ff8c00; } .controls { margin-top: 30px; color: white; } .control-group { margin: 15px 0; } label { display: block; margin-bottom: 5px; font-weight: bold; } input[type="range"] { width: 100%; margin: 5px 0; } .instructions { color: #aaa; margin-top: 20px; font-size: 0.9rem; line-height: 1.5; } .key-label { position: absolute; bottom: 5px; width: 100%; text-align: center; font-size: 12px; font-weight: bold; } .white-key .key-label { color: #333; } .black-key .key-label { color: white; } @media (max-width: 768px) { .keyboard { height: 150px; } .white-key { width: 30px; } .black-key { width: 18px; } h1 { font-size: 1.8rem; } } </style> </head> <body> <div class="container"> <h1>Interactive Piano Keyboard</h1> <p class="subtitle">Play with mouse or computer keyboard</p> <div class="keyboard" id="keyboard"></div> <div class="controls"> <div class="control-group"> <label for="attack">Attack: <span id="attack-value">0.1</span>s</label> <input type="range" id="attack" min="0.01" max="1" step="0.01" value="0.1"> </div> <div class="control-group"> <label for="decay">Decay: <span id="decay-value">0.3</span>s</label> <input type="range" id="decay" min="0.01" max="1" step="0.01" value="0.3"> </div> <div class="control-group"> <label for="sustain">Sustain: <span id="sustain-value">0.7</span></label> <input type="range" id="sustain" min="0" max="1" step="0.01" value="0.7"> </div> <div class="control-group"> <label for="release">Release: <span id="release-value">0.5</span>s</label> <input type="range" id="release" min="0.01" max="2" step="0.01" value="0.5"> </div> </div> <div class="instructions"> <p><strong>Keyboard Controls:</strong> A S D F G H J K L ; '</p> <p><strong>Mouse:</strong> Click on keys to play notes</p> </div> </div> <script> // Initialize Tone.js synth with ADSR envelope const synth = new Tone.PolySynth(Tone.Synth).toDestination(); // Set up ADSR envelope parameters const envelope = { attack: 0.1, decay: 0.3, sustain: 0.7, release: 0.5 }; // Update envelope values from sliders document.getElementById('attack').addEventListener('input', function() { envelope.attack = parseFloat(this.value); document.getElementById('attack-value').textContent = envelope.attack.toFixed(2); }); document.getElementById('decay').addEventListener('input', function() { envelope.decay = parseFloat(this.value); document.getElementById('decay-value').textContent = envelope.decay.toFixed(2); }); document.getElementById('sustain').addEventListener('input', function() { envelope.sustain = parseFloat(this.value); document.getElementById('sustain-value').textContent = envelope.sustain.toFixed(2); }); document.getElementById('release').addEventListener('input', function() { envelope.release = parseFloat(this.value); document.getElementById('release-value').textContent = envelope.release.toFixed(2); }); // Define piano keys - white and black keys with their frequencies const whiteKeys = [ { note: 'C4', frequency: 'C4', key: 'A' }, { note: 'D4', frequency: 'D4', key: 'S' }, { note: 'E4', frequency: 'E4', key: 'D' }, { note: 'F4', frequency: 'F4', key: 'F' }, { note: 'G4', frequency: 'G4', key: 'G' }, { note: 'A4', frequency: 'A4', key: 'H' }, { note: 'B4', frequency: 'B4', key: 'J' }, { note: 'C5', frequency: 'C5', key: 'K' }, { note: 'D5', frequency: 'D5', key: 'L' }, { note: 'E5', frequency: 'E5', key: ';' }, { note: 'F5', frequency: 'F5', key: '\'' } ]; const blackKeys = [ { note: 'C#4', frequency: 'C#4', key: 'W', position: 30 }, { note: 'D#4', frequency: 'D#4', key: 'E', position: 70 }, { note: 'F#4', frequency: 'F#4', key: 'T', position: 150 }, { note: 'G#4', frequency: 'G#4', key: 'Y', position: 190 }, { note: 'A#4', frequency: 'A#4', key: 'U', position: 230 } ]; // Create keyboard elements const keyboard = document.getElementById('keyboard'); // Create white keys whiteKeys.forEach((key, index) => { const keyElement = document.createElement('div'); keyElement.className = 'key white-key'; keyElement.dataset.note = key.note; keyElement.dataset.frequency = key.frequency; keyElement.dataset.key = key.key; keyElement.style.left = `${index * 40}px`; const label = document.createElement('div'); label.className = 'key-label'; label.textContent = key.key; keyElement.appendChild(label); keyboard.appendChild(keyElement); }); // Create black keys blackKeys.forEach(key => { const keyElement = document.createElement('div'); keyElement.className = 'key black-key'; keyElement.dataset.note = key.note; keyElement.dataset.frequency = key.frequency; keyElement.dataset.key = key.key; keyElement.style.left = `${key.position}px`; const label = document.createElement('div'); label.className = 'key-label'; label.textContent = key.key; keyElement.appendChild(label); keyboard.appendChild(keyElement); }); // Play note function function playNote(frequency, note) { synth.triggerAttackRelease(frequency, "8n", Tone.now()); // Visual feedback const keyElement = document.querySelector(`[data-note="${note}"]`); if (keyElement) { keyElement.classList.add('active'); setTimeout(() => { keyElement.classList.remove('active'); }, 200); } } // Add event listeners for mouse clicks document.querySelectorAll('.key').forEach(key => { key.addEventListener('mousedown', () => { const frequency = key.dataset.frequency; const note = key.dataset.note; playNote(frequency, note); }); key.addEventListener('touchstart', (e) => { e.preventDefault(); const frequency = key.dataset.frequency; const note = key.dataset.note; playNote(frequency, note); }); }); // Add event listeners for keyboard window.addEventListener('keydown', (e) => { // Prevent spacebar from scrolling if (e.key === ' ') { e.preventDefault(); } const key = e.key.toUpperCase(); const keyElement = document.querySelector(`[data-key="${key}"]`); if (keyElement) { const frequency = keyElement.dataset.frequency; const note = keyElement.dataset.note; playNote(frequency, note); // Visual feedback keyElement.classList.add('active'); setTimeout(() => { keyElement.classList.remove('active'); }, 200); } }); // Add event listeners for keyboard releases window.addEventListener('keyup', (e) => { const key = e.key.toUpperCase(); const keyElement = document.querySelector(`[data-key="${key}"]`); if (keyElement) { keyElement.classList.remove('active'); } }); // Initialize with default envelope values synth.set({ envelope: envelope }); // Update synth envelope when values change function updateEnvelope() { synth.set({ envelope: envelope }); } // Update envelope when any slider changes document.querySelectorAll('input[type="range"]').forEach(input => { input.addEventListener('input', updateEnvelope); }); // Initial envelope update updateEnvelope(); </script> </body> </html> ``` This interactive piano keyboard includes: 1. **Visual Design**: - Attractive gradient background - Responsive keyboard layout with white and black keys - Visual feedback when keys are pressed - Clean, modern interface with clear instructions 2. **Functionality**: - Playable with both mouse and computer keyboard - Computer keyboard mapping: A S D F G H J K L ; ' - Visual key labels for keyboard controls - ADSR envelope synthesis using Tone.js - Adjustable envelope parameters (Attack, Decay, Sustain, Release) 3. **Features**: - Real-time visual feedback when keys are played - Responsive design that works on different screen sizes - Smooth animations for key presses - Touch support for mobile devices - Clear instructions for users The piano has 11 white keys and 5 black keys spanning from C4 to F5. The ADSR envelope is fully customizable through the sliders at the bottom of the interface. All functionality is contained in a single HTML file with no external dependencies beyond the provided tone.min.js file.

TAKE IT TO CODE

This run produced no artifact — reuse the prompt with a different model or your own pi-agent run.

RUN

modelqwen3-coder-flash
vendorQwen
harnesspi-agent
generated2026-08-01

METRICS

runtime30.1s
tokens in1.2k
tokens out3.1k
cached512
cost / run$0.0033