![header](./jupyter_images/header.png "Header") 

## General Imports
from qiskit import QuantumCircuit, execute
from qiskit import Aer
from shutil import copyfile
from qiskit.visualization import plot_histogram
from qiskit import IBMQ
import qiskit.tools.jupyter
import os
%qiskit_job_watcher
from IPython.display import Audio
import wave
import numpy as np
## Button Display Imports (Needs installations mentioned above)
from IPython.display import display, Markdown, clear_output
# widget packages
import ipywidgets as widgets
from pydub import AudioSegment

![QuantumGates](./jupyter_images/quantumgates.png "Quantum Gates") #Will redo on quentin's computer tomorrow (today) 

piano_input = [None] * 5
piano = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
piano2 = widgets.Dropdown(
   options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
piano3 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
piano4 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
piano5 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')

box = widgets.VBox([piano, piano2, piano3, piano4, piano5])
box

guitar_input = [None] * 5
guitar = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
guitar2 = widgets.Dropdown(
   options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
guitar3 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
guitar4 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
guitar5 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')

box = widgets.VBox([guitar, guitar2, guitar3, guitar4, guitar5])
box

bass_input = [None] * 5
bass = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
bass2 = widgets.Dropdown(
   options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
bass3 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
bass4 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
bass5 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')

box = widgets.VBox([bass, bass2, bass3, bass4, bass5])
box

trumpet_input = [None] * 5
trumpet = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
trumpet2 = widgets.Dropdown(
   options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
trumpet3 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
trumpet4 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')
trumpet5 = widgets.Dropdown(
    options=['No Gate', 'X-Gate', 'Y-Gate', 'Z-Gate'],
    value='No Gate',
    description='Insert a :')

box = widgets.VBox([trumpet, trumpet2, trumpet3, trumpet4, trumpet5])
box

def GetGates(piano_input, guitar_input, bass_input, trumpet_input):

    if (piano.value == 'No Gate'):
        piano_input[0] = 'n'
    if (piano.value == 'X-Gate'):
        piano_input[0] = 'x'
    if (piano.value == 'Y-Gate'):
        piano_input[0] = 'y'
    if (piano.value == 'Z-Gate'):
        piano_input[0] = 'z'

    if (piano2.value == 'No Gate'):
        piano_input[1] = 'n'
    if (piano2.value == 'X-Gate'):
        piano_input[1] = 'x'
    if (piano2.value == 'Y-Gate'):
        piano_input[1] = 'y'
    if (piano2.value == 'Z-Gate'):
        piano_input[1] = 'z'

    if (piano3.value == 'No Gate'):
        piano_input[2] = 'n'
    if (piano3.value == 'X-Gate'):
        piano_input[2] = 'x'
    if (piano3.value == 'Y-Gate'):
        piano_input[2] = 'y'
    if (piano3.value == 'Z-Gate'):
        piano_input[2] = 'z'

    if (piano4.value == 'No Gate'):
        piano_input[3] = 'n'
    if (piano4.value == 'X-Gate'):
        piano_input[3] = 'x'
    if (piano4.value == 'Y-Gate'):
        piano_input[3] = 'y'
    if (piano4.value == 'Z-Gate'):
        piano_input[3] = 'z'

    if (piano5.value == 'No Gate'):
        piano_input[4] = 'n'
    if (piano5.value == 'X-Gate'):
        piano_input[4] = 'x'
    if (piano5.value == 'Y-Gate'):
        piano_input[4] = 'y'
    if (piano5.value == 'Z-Gate'):
        piano_input[4] = 'z'


    if (guitar.value == 'No Gate'):
        guitar_input[0] = 'n'
    if (guitar.value == 'X-Gate'):
        guitar_input[0] = 'x'
    if (guitar.value == 'Y-Gate'):
        guitar_input[0] = 'y'
    if (guitar.value == 'Z-Gate'):
        guitar_input[0] = 'z'

    if (guitar2.value == 'No Gate'):
        guitar_input[1] = 'n'
    if (guitar2.value == 'X-Gate'):
        guitar_input[1] = 'x'
    if (guitar2.value == 'Y-Gate'):
        guitar_input[1] = 'y'
    if (guitar2.value == 'Z-Gate'):
        guitar_input[1] = 'z'

    if (guitar3.value == 'No Gate'):
        guitar_input[2] = 'n'
    if (guitar3.value == 'X-Gate'):
        guitar_input[2] = 'x'
    if (guitar3.value == 'Y-Gate'):
        guitar_input[2] = 'y'
    if (guitar3.value == 'Z-Gate'):
        guitar_input[2] = 'z'

    if (guitar4.value == 'No Gate'):
        guitar_input[3] = 'n'
    if (guitar4.value == 'X-Gate'):
        guitar_input[3] = 'x'
    if (guitar4.value == 'Y-Gate'):
        guitar_input[3] = 'y'
    if (guitar4.value == 'Z-Gate'):
        guitar_input[3] = 'z'

    if (guitar5.value == 'No Gate'):
        guitar_input[4] = 'n'
    if (guitar5.value == 'X-Gate'):
        guitar_input[4] = 'x'
    if (guitar5.value == 'Y-Gate'):
        guitar_input[4] = 'y'
    if (guitar5.value == 'Z-Gate'):
        guitar_input[4] = 'z'


    if (bass.value == 'No Gate'):
        bass_input[0] = 'n'
    if (bass.value == 'X-Gate'):
        bass_input[0] = 'x'
    if (bass.value == 'Y-Gate'):
        bass_input[0] = 'y'
    if (bass.value == 'Z-Gate'):
        bass_input[0] = 'z'

    if (bass2.value == 'No Gate'):
        bass_input[1] = 'n'
    if (bass2.value == 'X-Gate'):
        bass_input[1] = 'x'
    if (bass2.value == 'Y-Gate'):
        bass_input[1] = 'y'
    if (bass2.value == 'Z-Gate'):
        bass_input[1] = 'z'

    if (bass3.value == 'No Gate'):
        bass_input[2] = 'n'
    if (bass3.value == 'X-Gate'):
        bass_input[2] = 'x'
    if (bass3.value == 'Y-Gate'):
        bass_input[2] = 'y'
    if (bass3.value == 'Z-Gate'):
        bass_input[2] = 'z'

    if (bass4.value == 'No Gate'):
        bass_input[3] = 'n'
    if (bass4.value == 'X-Gate'):
        bass_input[3] = 'x'
    if (bass4.value == 'Y-Gate'):
        bass_input[3] = 'y'
    if (bass4.value == 'Z-Gate'):
        bass_input[3] = 'z'

    if (bass5.value == 'No Gate'):
        bass_input[4] = 'n'
    if (bass5.value == 'X-Gate'):
        bass_input[4] = 'x'
    if (bass5.value == 'Y-Gate'):
        bass_input[4] = 'y'
    if (bass5.value == 'Z-Gate'):
        bass_input[4] = 'z'


    if (trumpet.value == 'No Gate'):
        trumpet_input[0] = 'n'
    if (trumpet.value == 'X-Gate'):
        trumpet_input[0] = 'x'
    if (trumpet.value == 'Y-Gate'):
        trumpet_input[0] = 'y'
    if (trumpet.value == 'Z-Gate'):
        trumpet_input[0] = 'z'

    if (trumpet2.value == 'No Gate'):
        trumpet_input[1] = 'n'
    if (trumpet2.value == 'X-Gate'):
        trumpet_input[1] = 'x'
    if (trumpet2.value == 'Y-Gate'):
        trumpet_input[1] = 'y'
    if (trumpet2.value == 'Z-Gate'):
        trumpet_input[1] = 'z'

    if (trumpet3.value == 'No Gate'):
        trumpet_input[2] = 'n'
    if (trumpet3.value == 'X-Gate'):
        trumpet_input[2] = 'x'
    if (trumpet3.value == 'Y-Gate'):
        trumpet_input[2] = 'y'
    if (trumpet3.value == 'Z-Gate'):
        trumpet_input[2] = 'z'

    if (trumpet4.value == 'No Gate'):
        trumpet_input[3] = 'n'
    if (trumpet4.value == 'X-Gate'):
        trumpet_input[3] = 'x'
    if (trumpet4.value == 'Y-Gate'):
        trumpet_input[3] = 'y'
    if (trumpet4.value == 'Z-Gate'):
        trumpet_input[3] = 'z'

    if (trumpet5.value == 'No Gate'):
        trumpet_input[4] = 'n'
    if (trumpet5.value == 'X-Gate'):
        trumpet_input[4] = 'x'
    if (trumpet5.value == 'Y-Gate'):
        trumpet_input[4] = 'y'
    if (trumpet5.value == 'Z-Gate'):
        trumpet_input[4] = 'z'
        
    return (piano_input, guitar_input, bass_input, trumpet_input)

piano_input, guitar_input, bass_input, trumpet_input = GetGates(piano_input, guitar_input, bass_input, trumpet_input)

#minimum user input will just be for them to fill out the create quantum circuit function inthe backend
n = 5  #number of gates
backend = Aer.get_backend('statevector_simulator')
piano_states = []
guitar_states = []
bass_states = []
trumpet_states = []
def CreateQuantumCircuit(piano_input, guitar_input, bass_input, trumpet_input):
    cct = QuantumCircuit(4,1)
    piano_states = []
    guitar_states = []
    bass_states = []
    trumpet_states = []
    for i in range(n-1):
        cct.h(i-1)
    cct.barrier() 
    for i in range(n):
        if piano_input[i-1] == 'x': 
            cct.x(0)
        if piano_input[i-1] == 'y':
            cct.y(0)
        if piano_input[i-1] == 'z': 
            cct.z(0)
        piano_states.append(execute(cct, backend).result().get_statevector())
        if guitar_input[i-1] == 'x':
            cct.x(1)
        if guitar_input[i-1] == 'y':
            cct.y(1)
        if guitar_input[i-1] == 'z':
            cct.z(1)
        guitar_states.append(execute(cct, backend).result().get_statevector())
        if bass_input[i-1] == 'x':
            cct.x(2)
        if bass_input[i-1] == 'y': 
            cct.y(2)
        if bass_input[i-1] == 'z':
            cct.z(2)
        bass_states.append(execute(cct, backend).result().get_statevector())
        if trumpet_input[i-1] == 'x': 
            cct.x(3)
        if trumpet_input[i-1] == 'y':
            cct.y(3)
        if trumpet_input[i-1] == 'z': 
            cct.z(3)
        trumpet_states.append(execute(cct, backend).result().get_statevector())
        cct.barrier() 
        cct.draw('mpl')
    return piano_states, guitar_states, bass_states, trumpet_states, cct

piano_states, guitar_states, bass_states, trumpet_states, cct = CreateQuantumCircuit(piano_input, guitar_input, bass_input, trumpet_input)
cct.draw(output="mpl")

def SeperateArrays(states, vals_real, vals_imaginary):
    vals = []
    for i in range(n+1):
        vals.append(states[i-1][0])
    for i in range(n+1):
        vals_real.append((states[i-1][0].real))
        vals_imaginary.append((states[i-1][0]).imag)
    return vals_real, vals_imaginary

piano_real = []
piano_imaginary = []
piano_vals = []
guitar_real = []
guitar_imaginary = []
guitar_vals = []
bass_real = []
bass_imaginary = []
bass_vals = []
trumpet_real = []
trumpet_imaginary = []
trumpet_vals = []
piano_real, piano_imaginary = SeperateArrays(piano_states, piano_real, piano_imaginary)
guitar_real, guitar_imaginary = SeperateArrays(guitar_states, guitar_real, guitar_imaginary)
bass_real, bass_imaginary = SeperateArrays(bass_states, bass_real, bass_imaginary)
trumpet_real, trumpet_imaginary = SeperateArrays(trumpet_states, trumpet_real, trumpet_imaginary)

def MusicalTransformation(real, imaginary):
    tune_array=[]
    for i in range(n+1):
        if(real[i-1] < 0 and imaginary[i-1] > 0):
            tune_array.append('c')
            tune_array.append('g')
            tune_array.append('e')
        if(real[i-1] < 0 and imaginary[i-1] <= 0):
            tune_array.append('c')
            tune_array.append('f')
            tune_array.append('g')
        if(real[i-1] < 0 and imaginary[i-1] > 0):
            tune_array.append('d')
            tune_array.append('f')
            tune_array.append('a')
        if(real[i-1] < 0 and imaginary[i-1] <= 0):
            tune_array.append('f')
            tune_array.append('a')
            tune_array.append('c')
        if(real[i-1] > 0 and imaginary[i-1] > 0):
            tune_array.append('g')
            tune_array.append('b')
            tune_array.append('d')
        if(real[i-1] > 0 and imaginary[i-1] < 0):
            tune_array.append('d')
            tune_array.append('f')
            tune_array.append('a')
        if(real[i-1] > 0 and imaginary[i-1] >= 0):
            tune_array.append('e')
            tune_array.append('g')
            tune_array.append('b')
        if(real[i-1] > 0 and imaginary[i-1] < 0):
            tune_array.append('a')
            tune_array.append('c')
            tune_array.append('b')
        if(real[i-1] == 0 and imaginary[i-1] == 0):
            tune_array.append('n')
            tune_array.append('n')
            tune_array.append('n')
    return tune_array

tune_array_piano = MusicalTransformation(piano_real, piano_imaginary)
tune_array_guitar = MusicalTransformation(guitar_real, guitar_imaginary)
tune_array_bass = MusicalTransformation(bass_real, bass_imaginary)
tune_array_trumpet = MusicalTransformation(trumpet_real, trumpet_imaginary)

def PlayPianoTune(character, songs):
    if character == 'a':
        sound_file = "./Audio/Piano/1.wav"
        songs.append(sound_file)
    if character == 'b':
        sound_file = "./Audio/Piano/2.wav"
        songs.append(sound_file)
    if character == 'c':
        sound_file = "./Audio/Piano/3.wav"
        songs.append(sound_file)
    if character == 'd':
        sound_file = "./Audio/Piano/4.wav"
        songs.append(sound_file)
    if character == 'e':
        sound_file = "./Audio/Piano/5.wav"
        songs.append(sound_file)
    if character == 'f':
        sound_file = "./Audio/Piano/6.wav"
        songs.append(sound_file)
    if character == 'g':
        sound_file = "./Audio/Piano/7.wav"
        songs.append(sound_file)
    if character == 'n':
        sound_file = "./Audio/blank.wav"
        songs.append(sound_file)
    return songs

def PlayGuitarTune(character, songs):
    if character == 'a':
        sound_file = "./Audio/Guitar/1.wav"
        songs.append(sound_file)
    if character == 'b':
        sound_file = "./Audio/Guitar/2.wav"
        songs.append(sound_file)
    if character == 'c':
        sound_file = "./Audio/Guitar/3.wav"
        songs.append(sound_file)
    if character == 'd':
        sound_file = "./Audio/Guitar/4.wav"
        songs.append(sound_file)
    if character == 'e':
        sound_file = "./Audio/Guitar/5.wav"
        songs.append(sound_file)
    if character == 'f':
        sound_file = "./Audio/Guitar/6.wav"
        songs.append(sound_file)
    if character == 'g':
        sound_file = "./Audio/Guitar/7.wav"
        songs.append(sound_file)
    if character == 'n':
        sound_file = "./Audio/blank.wav"
        songs.append(sound_file)
    return songs

def PlayBassTune(character, songs):
    if character == 'a':
        sound_file = "./Audio/Bass/1.wav"
        songs.append(sound_file)
    if character == 'b':
        sound_file = "./Audio/Bass/2.wav"
        songs.append(sound_file)
    if character == 'c':
        sound_file = "./Audio/Bass/3.wav"
        songs.append(sound_file)
    if character == 'd':
        sound_file = "./Audio/Bass/4.wav"
        songs.append(sound_file)
    if character == 'e':
        sound_file = "./Audio/Bass/5.wav"
        songs.append(sound_file)
    if character == 'f':
        sound_file = "./Audio/Bass/6.wav"
        songs.append(sound_file)
    if character == 'g':
        sound_file = "./Audio/Bass/7.wav"
        songs.append(sound_file)
    if character == 'n':
        sound_file = "./Audio/blank.wav"
        songs.append(sound_file)
    return songs

def PlayTrumpetTune(character, songs):
    if character == 'a':
        sound_file = "./Audio/Trumpet/1.wav"
        songs.append(sound_file)
    if character == 'b':
        sound_file = "./Audio/Trumpet/2.wav"
        songs.append(sound_file)
    if character == 'c':
        sound_file = "./Audio/Trumpet/3.wav"
        songs.append(sound_file)
    if character == 'd':
        sound_file = "./Audio/Trumpet/4.wav"
        songs.append(sound_file)
    if character == 'e':
        sound_file = "./Audio/Trumpet/5.wav"
        songs.append(sound_file)
    if character == 'f':
        sound_file = "./Audio/Trumpet/6.wav"
        songs.append(sound_file)
    if character == 'g':
        sound_file = "./Audio/Trumpet/7.wav"
        songs.append(sound_file)
    if character == 'n':
        sound_file = "./Audio/blank.wav"
        songs.append(sound_file)
    return songs

piano_song = []
for i in range(len(tune_array_piano)):
    character = tune_array_piano[i-1]
    piano_song = PlayPianoTune(character, piano_song)
os.remove("./pianosounds.wav")
copyfile('./Audio/blank.wav','./pianosounds.wav')
for i in range(len(tune_array_piano)):
    infiles = [piano_song[i-1], "pianosounds.wav"]
    outfile = "pianosounds.wav"
    data= []
    for infile in infiles:
        w = wave.open(infile, 'rb')
        data.append( [w.getparams(), w.readframes(w.getnframes())] )
        w.close()

    output = wave.open(outfile, 'wb')
    output.setparams(data[0][0])
    for i in range(len(data)):
        output.writeframes(data[i][1])
    output.close()

guitar_song = []
for i in range(len(tune_array_guitar)):
    character = tune_array_piano[i-1]
    guitar_song = PlayGuitarTune(character, guitar_song)
os.remove("./guitarsounds.wav")
copyfile('./Audio/blank.wav','./guitarsounds.wav')
for i in range(len(tune_array_guitar)):
    infiles = [guitar_song[i-1], "guitarsounds.wav"]
    outfile = "guitarsounds.wav"
    data= []
    for infile in infiles:
        w = wave.open(infile, 'rb')
        data.append( [w.getparams(), w.readframes(w.getnframes())] )
        w.close()

    output = wave.open(outfile, 'wb')
    output.setparams(data[0][0])
    for i in range(len(data)):
        output.writeframes(data[i][1])
    output.close()

bass_song = []
for i in range(len(tune_array_bass)):
    character = tune_array_bass[i-1]
    bass_song = PlayBassTune(character, bass_song)
os.remove("./basssounds.wav")
copyfile('./Audio/blank.wav','./basssounds.wav')
for i in range(len(tune_array_bass)):
    infiles = [bass_song[i-1], "basssounds.wav"]
    outfile = "basssounds.wav"
    data= []
    for infile in infiles:
        w = wave.open(infile, 'rb')
        data.append( [w.getparams(), w.readframes(w.getnframes())] )
        w.close()

    output = wave.open(outfile, 'wb')
    output.setparams(data[0][0])
    for i in range(len(data)):
        output.writeframes(data[i][1])
    output.close()

trumpet_song = []
for i in range(len(tune_array_trumpet)):
    character = tune_array_trumpet[i-1]
    trumpet_song = PlayTrumpetTune(character, trumpet_song)
os.remove("./trumpetsounds.wav")
copyfile('./Audio/blank.wav','./trumpetsounds.wav')
for i in range(len(tune_array_trumpet)):
    infiles = [trumpet_song[i-1], "trumpetsounds.wav"]
    outfile = "trumpetsounds.wav"
    data= []
    for infile in infiles:
        w = wave.open(infile, 'rb')
        data.append( [w.getparams(), w.readframes(w.getnframes())] )
        w.close()

    output = wave.open(outfile, 'wb')
    output.setparams(data[0][0])
    for i in range(len(data)):
        output.writeframes(data[i][1])
    output.close()

os.remove("./combined.wav")
copyfile('./Audio/blank.wav','./combined.wav')
os.remove("./combined2.wav")
copyfile('./Audio/blank.wav','./combined2.wav')

copyfile('./Audio/blank.wav','./output_song.wav')
sound1 = AudioSegment.from_file("./trumpetsounds.wav")
sound2 = AudioSegment.from_file("./basssounds.wav")
combined = sound1.overlay(sound2)
combined.export("./combined.wav", format='wav')
sound3 = AudioSegment.from_file("./guitarsounds.wav")
sound4 = AudioSegment.from_file("./pianosounds.wav")
combined2 = sound3.overlay(sound4)
combined2.export("./combined2.wav", format='wav')
sound5 = AudioSegment.from_file("./combined.wav")
sound6 = AudioSegment.from_file("./combined2.wav")
output_song = sound5.overlay(sound6)
output_song.export("./outputsong.wav", format='wav')

sound_file = "./outputsong.wav"
Audio(sound_file, autoplay=True)

#https://musescore.org/en/download/musescore.msi
!pip install music21
!pip install RISE

from music21 import *

#for Windows OS error
#us = environment.UserSettings()
#C:\Program Files\MuseScore 3\bin\MuseScore3.exe
#us['musicxmlPath'] = "C:\\Program Files\\MuseScore 3\\bin\\MuseScore3.exe"
#us['musescoreDirectPNGPath'] = "C:\\Program Files\\MuseScore 3\\bin\\MuseScore3.exe"

piano_stream = stream.Stream()
guitar_stream = stream.Stream()
bass_stream = stream.Stream()
trumpet_stream = stream.Stream()
note1 = note.Note("A")
note2 = note.Note("B")
note3 = note.Note("C")
note4 = note.Note("D")
note5 = note.Note("E")
note6 = note.Note("F")
note7 = note.Note("G")

def append_stream(array, stream):
    for i in range(n+1):
        if array[i-1] == 'a':
            stream.append(note1)
        if array[i-1] == 'b':
            stream.append(note2)
        if array[i-1] == 'c':
            stream.append(note3)
        if array[i-1] == 'd':
            stream.append(note4)
        if array[i-1] == 'e':
            stream.append(note5)
        if array[i-1] == 'f':
            stream.append(note6)
        if array[i-1] == 'g':
            stream.append(note7)
    return stream

piano_stream=append_stream(tune_array_piano, piano_stream)

guitar_stream=append_stream(tune_array_guitar, guitar_stream)

bass_stream=append_stream(tune_array_bass, bass_stream)

trumpet_stream=append_stream(tune_array_trumpet, trumpet_stream)

piano_stream.show()

guitar_stream.show()

bass_stream.show()

trumpet_stream.show()

