To save some typing...

by Artelius (Login Mikrondel)
R

 

The following program attempts to further automate the conversion process. The advantage of doing things this way is that you don't have to edit a hundred lines to convert it from printing note names to producing Lilypond output. Of course you will need to modify this program to suit your needs.

The program works by converting the note to a simple number (based on a semitone scale), then converting back into octave/note notation. If you would like anything explained please say so.

DIM NoteNames$(0 TO 11)

NoteNames$(0) = "A"
NoteNames$(1) = "Bb"
NoteNames$(2) = "B"
NoteNames$(3) = "C"
NoteNames$(4) = "C#"
NoteNames$(5) = "D"
NoteNames$(6) = "D#"
NoteNames$(7) = "E"
NoteNames$(8) = "F"
NoteNames$(9) = "F#"
NoteNames$(10) = "G"
NoteNames$(11) = "G#"

DIM StringPitch(1 TO 6)

'E A D G B e
StringPitch(1) = 7
StringPitch(2) = 0 + 12
StringPitch(3) = 5 + 12
StringPitch(4) = 10 + 12
StringPitch(5) = 2 + 12 * 2
StringPitch(6) = 7 + 12 * 2

INPUT "String # "; stri
INPUT "Fret # "; fret

'Deduce the pitch number
pitch = StringPitch(stri) + fret

'Calculate octave and note
octave = pitch \ 12
note = pitch MOD 12

PRINT "Guitar note: Octave"; octave; "note "; NoteNames$(note)

'tranpose to E flat
saxpitch = pitch + 9

'Calculate octave and note
saxoctave = saxpitch \ 12
saxnote = saxpitch MOD 12

PRINT "Sax note: Octave"; saxoctave; "note "; NoteNames$(saxnote)

Posted on Aug 3, 2009, 1:12 AM

Respond to this message   

Goto Forum Home

 Copyright © 1999-2017 Network54. All rights reserved.   Terms of Use   Privacy Statement  

Quantcast