|
I know the important theory of formal music: "It ain't over 'til the fat lady sings".
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
This is what I came up with after a lot of googling on the 'fifths' that was mentioned earlier. I use it in my MIDI sequencer. I'm relatively sure I got it right, but not absolutely, so if anyone sees anything I've screwed up, feel free to give me hell! (And I see I should have used non-caps for some, from another comment!) - edit: fixed
const KeySignatures::KeySig KeySignatures::keySigsC[] = {
{ "g# min (af min)", 5, true },
{ "g min", -2, true },
{ "f# min", 3, true },
{ "f min", -4, true },
{ "e min", 1, true },
{ "ef min (d# min)", -6, true },
{ "d# min (ef min)", 6, true },
{ "d min", -1, true },
{ "c# min (df min (unused))", 4, true },
{ "c min", -3, true },
{ "b min", 2, true },
{ "bf min (a# min)", -5, true },
{ "a# min (bf min)", 7, true },
{ "a min", 0, true },
{ "af min (g# min)", -7, true },
{ "Af Maj", -4, false },
{ "A Maj", 3, false },
{ "Bf Maj", -2, false },
{ "B Maj (Cf Maj)", 5, false },
{ "Cf Maj (B Maj)", -7, false },
{ "C Maj", 0, false },
{ "C# Maj (Df Maj)", 7, false },
{ "Df Maj (C# Maj)", -5, false },
{ "D Maj", 2, false },
{ "Ef Maj", -3, false },
{ "E Maj", 4, false },
{ "F Maj", -1, false },
{ "F# Maj (Gf Maj)", 6, false },
{ "Gf Maj (F# Maj)", -6, false },
{ "G Maj", 1, false }
};
modified 9-Jul-20 14:24pm.
|
|
|
|
|
|
Maybe it's just a typo, but you have two of the major keys transposed (bad choice of words maybe in this context!)
Line 2 SHARPS should be "GDAEBFC"
However, there are bigger problems!
This code will return mostly wrong answers. If we look at the sharps only, your code (assume it's major) would return:
C, G# major, D# major, A# major ...
which is incorrect.
The correct sequence (without all the "majors" shown) would be: C G D A E B F# C#
And a sort of reverse applies situation applies to the flats. (C), F, Bb, Eb, Ab, Db, Gb, Cb
Hope that helped!
modified 10-Jul-20 3:54am.
|
|
|
|
|
Hi, I'm not sure what language the pretty generic C-style code is in but I guess it's not Javascript as ToString is Pascal case.
Anyway, this JS library is brilliant for accessing musical theory in code.
|
|
|
|
|
it's C#.. oooh and thank you. I'll take a look
Real programmers use butterflies
|
|
|
|
|
SHARPS string is wrong. Should be GDAEBFC.
Otherwise looks good
|
|
|
|
|
|
The closest I've came was writing a few measures of "music" containing abominations like 4096th notes, and notes with a half dozen dots in a highschool class to spite a teacher I disliked.
(It was trivial - if a bit tedious - to create iteratively by splitting notes in half and inserting the new one randomly, far harder for the teacher to actually add up to make sure it actually had the correct total. )
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius
Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt
|
|
|
|
|
Not sure if this was already mentioned in one of the other responses, but you have E and A in the wrong order for the sharp key signatures. A has 3 and E has 4.
I learned the sequence of sharps (aka circle of fifths) back in piano classes many years ago as "Father Charles Goes Down And Ends Battle". Conveniently, you can reverse the phrase to get the order of flats (ie circle of fourths) and it still makes sense.
|
|
|
|
|
It's not right: major and minor keys have different numbers of sharps or flats. For example, while B major has 5 sharps: C#, D#, F#, G#, A#, B minor has a D natural, and then, if it's a harmonic minor, a G natural; if it's a melodic minor, a G# and A# for an ascending scale, whereas both those are natural for a descending scale. Minor keys are tricky: there's no fixed answer. More here:
musictheory.net[^]
|
|
|
|
|
To simplify that - there are 12 keys in the chromatic scale, so just put an integer from 0...11.
Then you don't have any regional differences.
And if you want major / minor, then add a Boolean.
Should suffice for the most common "Western" music.
PS
|
|
|
|
|
no, this is not even close.
Real programmers use butterflies
|
|
|
|
|
Think it would be a good guess to look at music notation programs like MuseScore
|
|
|
|
|
Note that no flats or sharps is C major (or A minor), but that C minor is three flats (same as E flat).
( scode == 0 ) && (IsMinor) should be A minor, not C minor
I have always enjoyed this presentation of the "circle of fifths": Tolkien Circle of Fifths : lotr[^]
Letter names outside the circle are the major keys.
Lower case letters on the inside of the circle are the minor keys.
This more colorful presentation includes all the sharp & flat keys.
[^]
|
|
|
|
|
They've been bugging me for a few months.
I tried some insecticides, but they just keep on coming, although it's gotten less.
So I was wondering how these ants didn't get infected with COVID-19, as it's possible for the virus to infect animals.
Turns out they have tiny anty-bodies.
Ba dum tsss! I'll get my coat.
Half of the story is actually true though.
|
|
|
|
|
I hear the same thing applies to termites[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
But which half of the story am I laughing at?
|
|
|
|
|
There is an insecticide known as "ant honey" (because it looks like honey). You place drops of it where the ants are to be found (but not near food or on food preparation surfaces!), and the ants take it back to their nest, where it kills the ants in the nest.
It takes a few days to work, but if it does - it works very well.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Daniel Pfeffer wrote: It takes a few days to work, but if it does - it works very well.
If it works, then it works?
That is like saying: "60% of the time, it works every time"
|
|
|
|
|
That's what comes of surfing the net after lunch (when I should be sleeping )
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Burn the house to the ground.
Kills ants, and Covid-19.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The infallible Nero's solution!
|
|
|
|
|
And Rome hasn't recovered since!
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
It recoverd very well, actually.
And, without any doubt, the finest specimens of the humans are born in Rome.
|
|
|
|
|