// File: /workspace/github_cpp_makefile_star2_O3/tobias93[P]piano/main.cpp
// Function: main
int main()
{
    MidiIn midi;
    SimpleSynth synth;
    AudioPlayer player;

    AudioSettings audioSettings;
    audioSettings.bufferFrames = 64;
    player.setAudioSettings(audioSettings);

    Envelope envelope;
    envelope.amplitude = 1;
    envelope.sustain = .5;
    envelope.attack = 0.1;
    envelope.decay = 0.6;
    envelope.release = 2;
    synth.setEnvelope(envelope);
    
    player.setAudioSource(&synth);
    midi.setMidiListener(&synth);
    
    midi.connect_interactive();
    player.play();

    cout << "Have fun playing some music!." << endl;
    cout << "Press [enter] to exit." << endl;

    cin.get();

    return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
leaq 0x50(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x8(%rsp), %r15
movq $0x13, (%r15)
leaq 0x40(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x21f0
movq %rax, (%r14)
movq (%r15), %rcx
movq %rcx, 0x10(%r14)
movups 0xc1e(%rip), %xmm0      # 0x30cd
movups %xmm0, (%rax)
movl $0x746e6569, 0xf(%rax)  # imm = 0x746E6569
movq %rcx, 0x8(%r14)
movq (%r14), %rax
movb $0x0, (%rax,%rcx)
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
movq %r14, %rdx
movl $0x64, %ecx
callq 0x2100
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0x24ef
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2160
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x27d6(%rip), %rax      # 0x4cd8
movq %rax, 0x40(%rsp)
leaq 0x27f2(%rip), %rax      # 0x4d00
movq %rax, 0x50(%rsp)
movl $0x0, 0x58(%rsp)
movl $0x25, %eax
movb $0x0, 0x37(%rsp,%rax)
movl $0x0, 0x3b(%rsp,%rax)
movw $0x2a, 0x3f(%rsp,%rax)
addq $0xc, %rax
cmpq $0x9d, %rax
jne 0x2520
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xd8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0xe0(%rsp)
movsd 0xaa3(%rip), %xmm0      # 0x3008
movups %xmm0, 0xf0(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x2724
movq 0x8(%rsp), %rdi
movb $0x1, %al
cmpl $-0x32, 0x1bc(%rdi)
je 0x259c
movq (%rdi), %rax
callq *0x38(%rax)
movq 0x8(%rsp), %rdi
cmpl $-0x32, 0x1bc(%rdi)
sete %al
movabsq $0x4000005622, %rcx     # imm = 0x4000005622
movq %rcx, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movaps 0xa76(%rip), %xmm0      # 0x3030
movups %xmm0, 0xd8(%rsp)
movaps 0xa77(%rip), %xmm0      # 0x3040
movups %xmm0, 0xe8(%rsp)
movabsq $0x4000000000000000, %rcx # imm = 0x4000000000000000
movq %rcx, 0xf8(%rsp)
testb %al, %al
jne 0x25ed
movq (%rdi), %rax
callq *0x38(%rax)
movq %r14, 0x20(%rsp)
movq %rbx, 0x38(%rsp)
movq 0x30(%rsp), %rdi
leaq -0x255(%rip), %rsi      # 0x23ae
movq %rbx, %rdx
callq 0x2050
leaq 0x28(%rsp), %rdi
callq 0x27c8
leaq 0x8(%rsp), %rdi
callq 0x29b8
movq 0x2992(%rip), %rbx      # 0x4fb8
leaq 0xa6b(%rip), %rsi       # 0x3098
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x2170
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x2960(%rip), %rdi      # 0x4fb8
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x294c(%rip), %rbx      # 0x4fb8
leaq 0xa43(%rip), %rsi       # 0x30b6
movl $0x16, %edx
movq %rbx, %rdi
callq 0x2170
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq 0x291a(%rip), %rdi      # 0x4fb8
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x291e(%rip), %rdi      # 0x4fd0
callq 0x2190
leaq 0x8(%rsp), %rdi
callq 0x2a8a
leaq 0x28(%rsp), %rdi
callq 0x2110
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
jmp 0x26dc
movq %rax, %rdi
callq 0x2b47
movq %rax, %r14
jmp 0x2712
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0x271c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2160
jmp 0x271c
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x2a8a
leaq 0x28(%rsp), %rdi
callq 0x2110
movq %r14, %rdi
callq 0x21e0