c4 d4 e4 … rather than 60 62 64?

Hello, I land here :slight_smile:

A simple question: is it possible to notate music with letters (a b c d …) rather than with midi note numbers? I find that the decimal system is not very suitable for writing on a 12-step scale.

THANKS :slight_smile:

see: Are note names supported in Scamp? - #4 by MarcEvanstein

THANKS,
I tried to apply it and it works in this case:

from scamp import *
named_notes = {
     f"{letter}{alteration}{octave}": [9, 11, 12, 14, 16, 17, 19]["ABCDEFG".index(letter.upper())] + \
     12 * octave + [-1, 0, 1][("b", "", "#").index(alteration)]
     for letter in "ABCDEFGabcdefg"
     for alteration in ("b", "", "#")
     for octave in range(0, 9)
}
s = Session()
s.tempo = 60
clarinet = s.new_part("clarinet")
clarinet.play_note(named_notes["c4"], 1, 0.5)

But not in this case:

from scamp import *
named_notes = {
     f"{letter}{alteration}{octave}": [9, 11, 12, 14, 16, 17, 19]["ABCDEFG".index(letter.upper())] + \
     12 * octave + [-1, 0, 1][("b", "", "#").index(alteration)]
     for letter in "ABCDEFGabcdefg"
     for alteration in ("b", "", "#")
     for octave in range(0, 9)
}
s = Session()
s.tempo = 60
tuba = s.new_part("tuba")

pitch_list = ["c3, d3, g3, a3, g3, f3, e3"] # I also tried ["c3", "d3", "g3", "a3", "g3", "f3", "e3"], without success.
hard_list = [1.0, 0.5, 1.0, 0.5, 1.0, 0.5, 1.0]
vol_list = [0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.5]

for pitch, duration, volume in zip(pitch_list, dur_list, vol_list):
     tuba.play_note(pitch, volume, duration)

What is the solution?

Hopefully you’ve found your bug by now and got this working but if not, this may help. I think if you try this, it may work better - you forgot the named_notes in your second piece of code.

.
.
.
pitch_list = ["c3", "d3", "g3", "a3", "g3", "f3", "e3"] # define the list this way
hard_list = [1.0, 0.5, 1.0, 0.5, 1.0, 0.5, 1.0]
vol_list = [0.2, 0.4, 0.6, 0.8, 1.0, 0.8, 0.5]

for pitch, duration, volume in zip(pitch_list, dur_list, vol_list):
     tuba.play_note(named_notes[pitch], volume, duration)

named_notes is a dictionary your created. pitch_list is a list of strings that are used as dictionary keys for the named_notes dictionary.
named_notes[“c3”] will return the value associated with the key “c3”

2 Likes

Thank you very much, it works !

I just modified this function from Marc, so that the octave changes occur on note C rather than A:

named_notes = {
    f"{letter}{alteration}{octave}": [12, 14, 16, 17, 19, 21, 23, 24]["CDEFGAB".index(letter.upper())] + \
    12 * octave + [-1, 0, 1][("b", "", "#").index(alteration)]
    for letter in "ABCDEFGabcdefg"
    for alteration in ("b", "", "#")
    for octave in range(0, 9)
}

The best would obviously be not to need to use quotation marks to enter the notes, but hey, that’s already not bad…