// File: /workspace/github_cpp_makefile_star2_O1/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 0xc20(%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 0x24ed
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2160
xorl %eax, %eax
movq %rax, 0x38(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x27a0(%rip), %rax      # 0x4ca0
movq %rax, 0x40(%rsp)
leaq 0x27bc(%rip), %rax      # 0x4cc8
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 0x251e
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0xd8(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0xe0(%rsp)
movsd 0xaa5(%rip), %xmm0      # 0x3008
movups %xmm0, 0xf0(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x271c
movq 0x8(%rsp), %rdi
cmpl $-0x32, 0x1bc(%rdi)
je 0x2589
movq (%rdi), %rax
callq *0x38(%rax)
movabsq $0x4000005622, %rax     # imm = 0x4000005622
movq %rax, 0x10(%rsp)
movl $0x1, 0x18(%rsp)
movaps 0xa89(%rip), %xmm0      # 0x3030
movups %xmm0, 0xd8(%rsp)
movaps 0xa8a(%rip), %xmm0      # 0x3040
movups %xmm0, 0xe8(%rsp)
movabsq $0x4000000000000000, %rax # imm = 0x4000000000000000
movq %rax, 0xf8(%rsp)
movq 0x8(%rsp), %rdi
cmpl $-0x32, 0x1bc(%rdi)
je 0x25e4
movq (%rdi), %rax
callq *0x38(%rax)
movq %r14, 0x20(%rsp)
movq %rbx, 0x38(%rsp)
movq 0x30(%rsp), %rdi
leaq -0x24c(%rip), %rsi      # 0x23ae
movq %rbx, %rdx
callq 0x2050
leaq 0x28(%rsp), %rdi
callq 0x27c0
leaq 0x8(%rsp), %rdi
callq 0x29b0
movq 0x299b(%rip), %rbx      # 0x4fb8
leaq 0xa74(%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 0x2969(%rip), %rdi      # 0x4fb8
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x2955(%rip), %rbx      # 0x4fb8
leaq 0xa4c(%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 0x2923(%rip), %rdi      # 0x4fb8
callq 0x2030
movq %rax, %rdi
callq 0x20d0
movq 0x2927(%rip), %rdi      # 0x4fd0
callq 0x2190
leaq 0x8(%rsp), %rdi
callq 0x2a98
leaq 0x28(%rsp), %rdi
callq 0x2110
xorl %eax, %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbx
popq %r14
popq %r15
retq
jmp 0x26d3
movq %rax, %rdi
callq 0x2b50
movq %rax, %r14
jmp 0x2709
movq %rax, %r14
movq 0x40(%rsp), %rdi
cmpq %rbx, %rdi
je 0x2713
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x2160
jmp 0x2713
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x2a98
leaq 0x28(%rsp), %rdi
callq 0x2110
movq %r14, %rdi
callq 0x21e0
nop