Musicians, look here.

new topic     » topic index » view thread      » older message » newer message

Hey ladies and gents,

So this is my first project, thank you to the boarders that helped me get started. It's a program designed to give a list of usable musical chords to play once the user has selected a root note and a mode.

If anybody is well versed enough in musical theory to confirm that the program is accurate, that feedback would be awesome. Otherwise, enjoy.

--This program will (hopefully) be able to randomly generate, or let the user select a key and mode.  
--then let the user know what chords to play in that mode 
--Thanks to Irv at open Euphoria for debugging help 
 
-- 
 
include get.e 
 
sequence root,  mode, chords, useranswernote 
atom mx, x 
sequence Amajor, Bbmajor ,Bmajor, Cmajor, Dbmajor, Dmajor, Ebmajor, Emajor, Fmajor, Gbmajor, Gmajor, Abmajor 
 
root = {0, 0, 0} 
mode = {} 
chords = {} 
mx = 0  
x = 0 
Amajor = 	{{'A',0,0}, {'B',0,'m'}, {'D','b','m'}, {'D',0,0}, {'E',0,0}, {'G','b','m'}, {'A','b','X'}} 
Bbmajor = 	{{'B','b',0}, {'C',0,'m'}, {'D',0,'m'}, {'E','b',0}, {'F',0,0}, {'G',0,'m'}, {'A',0,'X'}} 
Bmajor = 	{{'B',0,0}, {'D','b','m'}, {'E','b','m'}, {'E',0,0}, {'G','b',0}, {'A','b','m'}, {'B','b','X'}} 
Cmajor = 	{{'C',0,0}, {'D',0,'m'}, {'E',0,'m'}, {'F',0,0}, {'G',0,0}, {'A',0,'m'}, {'B',0,'X'}} 
Dbmajor =	{{'D','b',0}, {'E','b','m'}, {'F',0,'m'}, {'G','b',0}, {'A','b',0}, {'B','b','m'}, {'C',0,'X'}} 
Dmajor = 	{{'D',0,0}, {'E',0,'m'}, {'G','b','m'}, {'G',0,0}, {'A',0,0}, {'B',0,'m'}, {'D','b','X'}} 
Ebmajor =	{{'E','b',0}, {'F',0,'m'}, {'G',0,'m'}, {'A','b',0}, {'B','b',0}, {'C',0,'m'}, {'D',0,'X'}} 
Emajor = 	{{'E',0,0}, {'G','b','m'}, {'A','b','m'}, {'A',0,0}, {'B',0,0}, {'D','b','m'}, {'E','b','X'}} 
Fmajor = 	{{'F',0,0}, {'G',0,'m'}, {'A',0,'m'}, {'B','b',0}, {'C',0,0}, {'D',0,'m'}, {'E',0,'X'}} 
Gbmajor = 	{{'G','b',0}, {'A','b','m'}, {'B','b','m'}, {'B',0,0}, {'D','b',0}, {'E','b','m'}, {'F',0,'X'}} 
Gmajor = 	{{'G',0,0}, {'A',0,'m'}, {'B',0,'m'}, {'C',0,0}, {'D',0,0}, {'E',0,'m'}, {'G','b','X'}} 
Abmajor = 	{{'A','b',0}, {'B','b','m'}, {'C',0,'m'}, {'D','b',0}, {'E','b',0}, {'F',0,'m'}, {'G',0,'X'}} 
 
puts (1, "\nPlease type a Root Note: ") 	 
puts (1, "\n(For example: Ab, C, D#)\n") 	 
--useranswernote = {0,0} 
 
--while useranswernote[1] < 65 and useranswernote[1] > 71 do  
	useranswernote = gets(0)				--Getting user input, string 
--end while  
 
if useranswernote[1] = 'r' then 
	x = rand (7) + 64 			-- randomized number for key name (A, B, C, etc) 
	root [1] = x 				-- assigning number to root 
	x = rand (2)				-- randomizing number for b or # 
	if x = 2 then root[2] = 98 end if	--assigning value for flats 
 
	if root [1] = 67 and root[2] = 98 then root[2] = 0 end if 	--preventing Cb 
	if root [1] = 70 and root[2] = 98 then root[2] = 0 end if	-- preventing F 
else 
	root[1] = useranswernote[1] 
end if 
 
 
if useranswernote[2] = 98 then root[2] = 'b'  
elsif useranswernote[2] = 35 then  
	root[1] = root[1] + 1 
	root[2] = 'b'  
	 
end if 
  
puts (1, "\n\n1:Ionian (Major)\n2:Dorian\n3:Phygrian\n4:Lydian\n5:Mixolydian\n6:Aeolian (Minor)\n7:Locrian\n8:Random \n\n") 
 
 
mx = prompt_number("Select a Mode (1-8): ", {1, 8}) 		--keyboard input, number 
 
 
if mx = 8  then 
 
 
 
mx = rand (7)			 	--randomizing value for mode selection 
					--setting value for mode 
end if  
 
 
 
if mx = 1 then mode = {"Ionian (Major)"}  
	elsif mx = 2 then mode = {"Dorian"} 
		root[3] = 'm' 
	elsif mx = 3 then mode = {"Phygrian"} 
		root[3] = 'm' 
	elsif mx = 4 then mode = {"Lydian"} 
	elsif mx = 5 then mode = {"Mixolydian"} 
	elsif mx = 6 then mode = {"Aeolian (Minor)"} 
		root[3] = 'm' 
	elsif mx = 7 then mode = {"Locrian"} 
		root[3] = 'X' 
end if 
 
 
if root [1] = 67 and root[2] = 98 then 				--preventing Cb, which doesn't exist, and turning it into B 
		root[2] = 0  
		root[1] = root[1] - 1 
end if 								 
 
if root [1] = 70 and root[2] = 98 then 				--Same idea with Fb, turning it into E 
		root[1] = root[1] - 1 
		root[2] = 0  
end if								 
			 
puts (1, "\nKey: " & root [1] & root [2] )		--printing the root  
puts (1, "\nMode: ")					--printing the mode 
for i = 1 to length(mode) do puts(1,mode[i])		--printing mode 
end for 
 
if equal (root, Amajor[mx])   then chords = Amajor 
elsif equal (root, Bbmajor[mx])  then chords = Bbmajor 
elsif equal (root, Bmajor[mx])  then chords = Bmajor 
elsif equal (root, Cmajor[mx])   then chords = Cmajor 
elsif equal (root, Dbmajor[mx]) then chords = Dbmajor 
elsif equal (root, Dmajor[mx])   then chords = Dmajor 
elsif equal (root, Ebmajor[mx])   then chords = Ebmajor 
elsif equal (root, Emajor[mx])   then chords = Emajor 
elsif equal (root, Fmajor[mx])   then chords = Fmajor 
elsif equal (root, Gbmajor[mx])   then chords = Gbmajor 
elsif equal (root, Gmajor[mx])   then chords = Gmajor 
elsif equal (root, Abmajor[mx])  then chords = Abmajor 
else chords = {"Not a valid chord, sorry. Try again."} 
end if 
 
puts (1, "\n\nThese are the chords you might want to use: \n") 
for i = 1 to 7 do  
	for ix = 1 to 3 do puts(1,chords[i][ix] ) end for			 
if i = mx  then puts (1, " Root Chord" ) end if			--printing ID of root chord 
puts (1, "\n") 
end for 
 
puts (1, "\n\n\n\n\nWritten in Euphoria") 
puts (1, "\nPlease send bugs to the.novemberist(at)yahoo.ca") 
puts (1, "\nMay 2009, Alex Parker") 
 
? getc(0) 
 
 
new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu