  
        // Convert BPM to CPM (1 cycle = 1 beat)
        const bpm = parseInt(document.getElementById('bpm').value);
        code += `var cpm = ${bpm};\n\n`;
        
        // Add each line's pattern
        currentLines.forEach(({type, notes}) => {
            if (notes && notes.length > 0) {
                code += `// ${type.name} line\n`;
                code += `const ${type.id}Pattern = ${notesToStrudelPattern(notes, type)};\n\n`;
            }
        });
        
        // Add the final patter