arn(`No instrument found for ${type.name} (id: ${type.id})`);
            }
        });
    }

    // Define instrument mappings
    const INSTRUMENT_PROGRAMS = {
        'chords': 0,    // Acoustic Grand Piano
        'bass': 32,     // Acoustic Bass
        'top': 73,      // Flute
        'arp': 46,      // Harp
        'random': 25    // Acoustic Guitar
    };

    function downloadMidi() {
        console.log('Starting MIDI export with Tone.js...');
        
        // Create a new MIDI file
        co