Ejemplo n.º 1
0
 def __init__(self, tuning_name, *, min_fret=0, max_fret=24):
     self.tuning_name = tuning_name
     self.tuning = DEFAULT_TUNINGS.get(tuning_name, tuning_name)
     self.strings = tuple(self.tuning.split())
     self.midi = tuple(str2midi(s) for s in self.strings)
     self.num_strings = len(self.strings)
     self.min_fret = min_fret
     self.max_fret = max_fret
Ejemplo n.º 2
0
def note_name_to_numeral(note_name):
    """
    This function takes a data structure different from my note data structure
    """
    letter = note_name.strip()[0].upper()
    octave = note_name.strip()[-1]
    if len(note_name) == 3:
        letter = note_name.strip()[0:2].replace('s', '#').upper()
    return str2midi(letter + octave)
Ejemplo n.º 3
0
def note_name_to_numeral(note_name):
    """
    This function takes a string letter
    """
    letter = note_name.strip()[0].upper()
    octave = note_name.strip()[-1]
    if len(note_name) == 3:
        letter = note_name.strip()[0:2].replace('s', '#').upper()
    return str2midi(letter + octave)
Ejemplo n.º 4
0
def note_to_numeral(note):
    """
    This function takes my internal note data structure.
    {'note': 'c', 'octave': 4}
    """
    letter = note['note'].strip()[0].upper()
    octave = note['octave']
    if len(note['note']) == 2:
        letter = note['note'].strip().replace('s', '#')
        letter = letter[0].upper() + letter[1:]
    return str2midi(letter + str(octave))
def Generate():

    print("What order would you like to generate at? (0-6)")
    order = input()
    order = int(order)

    print("How many notes would you like to generate?")
    length = input()
    length = int(length)


    choice = "N"
    if(order >= 2):
        print("Would you like to choose the start? Y/N")
        choice = input()

    if(choice == "Y" and order > 1):
        print("Choose a note sequence " + str(order-1) + " notes long:")
        start = input()
    else:
        start = random.choice(list(pairList[order-2]))

    output = machine.buildSequence(order, pairList, probList, start, length)

    print("")
        #Bring back in the sharp notes (They were removed during pre-processing due to errors with RE)
    output = output.replace("s", "#")
    output = output.split(" ")
    output.pop()

        #Convert notes into MIDI degrees
    print(output)
    for x in range(0, len(output)):
        output[x] = str2midi(output[x])

    res = 0


    return output
Ejemplo n.º 6
0
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Musical keyboard synth example with a QWERTY keyboard
"""

from audiolazy import (str2midi, midi2freq, saw_table, sHz, Streamix, Stream,
                       line, AudioIO, chunks)
import sys
try:
    import tkinter
except ImportError:
    import Tkinter as tkinter

keys = "awsedftgyhujkolp;"  # Chromatic scale
first_note = str2midi("C3")

pairs = list(enumerate(keys.upper(), first_note + 12)) + \
        list(enumerate(keys, first_note))
notes = {k: midi2freq(idx) for idx, k in pairs}
synth = saw_table

txt = """
Press keys

W E   T Y U   O P
A S D F G H J K L ;

The above should be
seen as piano keys.
Ejemplo n.º 7
0
# Created on Wed Oct 16 13:44:10 2013
# danilo [dot] bellini [at] gmail [dot] com
"""
Musical keyboard synth example with a QWERTY keyboard
"""

from audiolazy import (str2midi, midi2freq, saw_table, sHz, Streamix, Stream,
                       line, AudioIO, chunks)
import sys
try:
  import tkinter
except ImportError:
  import Tkinter as tkinter

keys = "awsedftgyhujkolp;" # Chromatic scale
first_note = str2midi("C3")

pairs = list(enumerate(keys.upper(), first_note + 12)) + \
        list(enumerate(keys, first_note))
notes = {k: midi2freq(idx) for idx, k in pairs}
synth = saw_table

txt = """
Press keys

W E   T Y U   O P
A S D F G H J K L ;

The above should be
seen as piano keys.
Ejemplo n.º 8
0
 def __init__(self, raw_str):
     self.raw_str = raw_str
     matches = re.finditer(r"(?<=\()[^\)]+(?=\))|(?=R)|[^R ()]+", raw_str)
     self.simnotes_names = [match.group().split() for match in matches]
     self.simnotes = [[str2midi(note_name) for note_name in note_names]
                      for note_names in self.simnotes_names]
Ejemplo n.º 9
0
if starting_beats > 0:
  inoisy_stream = filt(gauss_noise()) * env
  inoisy_thub = thub(inoisy_stream.append(0).limit(beat_duration),
                     starting_beats)
  inoisy = chain.from_iterable(repeat(inoisy_thub).limit(starting_beats))
  smix.add(.1 * s, inoisy)
  smix.add(starting_beats * beat_duration - dur, []) # Event timing

# Wavetable lookup initialization
square_table = TableLookup([1] * 256 + [-1] * 256)
harmonics = dict(enumerate([1, 3, 2, 1, .3, .1, .7, .9, 1, 1, .5, .4, .2], 1))
table = sin_table.harmonize(harmonics).normalize()
mem_table = (3 * saw_table + (sin_table - saw_table) ** 3).normalize()

# Notes synth
midi_tuning = str2midi([gs.tune for gs in guitar])
midi_pitches = [midi_tuning[string_idx] + fret for string_idx, fret in notes]
for freq in midi2freq(midi_pitches):
  ks_memory = .1 * gauss_noise() + .9 * mem_table(freq * Hz)
  ks_snd = distortion(karplus_strong(freq * Hz,
                                     tau=.2 * s,
                                     memory=ks_memory))
  tl_snd = .5 * table(freq * Hz) * env
  smix.add(dur, .5 * ks_snd + .5 * tl_snd)

# Shows synthesis wavetables
pylab.subplot(2, 1, 1)
pylab.plot(table.table)
pylab.title("Table lookup waveform")
pylab.axis(xmax=len(table) - 1)
pylab.subplot(2, 1, 2)
Ejemplo n.º 10
0
if starting_beats > 0:
    inoisy_stream = filt(gauss_noise()) * env
    inoisy_thub = thub(
        inoisy_stream.append(0).limit(beat_duration), starting_beats)
    inoisy = chain.from_iterable(repeat(inoisy_thub).limit(starting_beats))
    smix.add(.1 * s, inoisy)
    smix.add(starting_beats * beat_duration - dur, [])  # Event timing

# Wavetable lookup initialization
square_table = TableLookup([1] * 256 + [-1] * 256)
harmonics = dict(enumerate([1, 3, 2, 1, .3, .1, .7, .9, 1, 1, .5, .4, .2], 1))
table = sin_table.harmonize(harmonics).normalize()
mem_table = (3 * saw_table + (sin_table - saw_table)**3).normalize()

# Notes synth
midi_tuning = str2midi([gs.tune for gs in guitar])
midi_pitches = [midi_tuning[string_idx] + fret for string_idx, fret in notes]
for freq in midi2freq(midi_pitches):
    ks_memory = .1 * gauss_noise() + .9 * mem_table(freq * Hz)
    ks_snd = distortion(karplus_strong(freq * Hz, tau=.2 * s,
                                       memory=ks_memory))
    tl_snd = .5 * table(freq * Hz) * env
    smix.add(dur, .5 * ks_snd + .5 * tl_snd)

# Shows synthesis wavetables
pylab.subplot(2, 1, 1)
pylab.plot(table.table)
pylab.title("Table lookup waveform")
pylab.axis(xmax=len(table) - 1)
pylab.subplot(2, 1, 2)
pylab.plot(mem_table.table)