secondsPerBeat,
                    velocity: note.velocity
                });
            });
        });

        // Convert to MIDI file and download
        const bytes = midi.toArray();
        const blob = new Blob([new Uint8Array(bytes)], { type: 'audio/midi' });
        const url = window.URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = 'goldenpond.mid';
        document.body.appendChild(a);
        a.click();
        document.body