Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Increment with '#' and decrement with 'b'

2 views
Skip to first unread message

Ivan Shmakov

unread,
Mar 18, 2012, 11:30:30 AM3/18/12
to
>>>>> Henry Law <ne...@lawshouse.org> writes:
>>>>> On 17/03/12 00:54, Ben Morrow wrote:
>>>>> Quoth Henry Law<ne...@lawshouse.org>:

[Cross-posting to news:comp.music.misc, for obvious reasons.]

>>> I'm turning a standard musical notation for a note into a pitch.
>>> The note "A" will be zero,

>> Do you have a reason for not starting with C? It would make more
>> sense.

> As a musician I'd say yes. As a programmer I decided that it would
> make more sense to start at the beginning of the alphabet, as that
> would allow me to do arithmetic on ASCII values if I needed to. It's
> arbitrary, since it's for internal representation only.

Unfortunately, the tone-semitone interval pattern of the
diatonic scale doesn't fit well the ASCII code, so one'd need
some conversion table anyway.

>>> other way, a "#" suffix increases by 1 and "##" by two.

>> Don't you mean 'x'?

> Yes, indeed. I should have included that one too, but ## is an
> acceptable alternative when writing chord charts. You're obviously a
> fellow muso!

I'd like to note that there're quite a few ASCII-based music
notations. The ones that I'd readily recall are:

* the one of the Lilypond [1] typesetting software (c d e f g a
b c makes the C major scale);

* the ABC notation [2];

* the Music Macro Language [3], as originated in certain 8-bit
implementations of the BASIC language (c d e f g a b > c makes
the C major scale), still surviving in such projects as QB64
[4], FreeBSD's spkr(4) [5] (with a few extensions), and
recently implemented in my MMLi project [6].

Perhaps, it'd make sense to reuse one of the above for whatever
project you're working on.

[1] http://lilypond.org/
[2] http://en.wikipedia.org/wiki/ABC_notation
[3] http://en.wikipedia.org/wiki/Music_Macro_Language
[4] http://www.qb64.net/
[5] http://www.gsp.com/cgi-bin/man.cgi?section=4&topic=spkr
[6] http://freecode.com/projects/mmli

[...]

--
FSF associate member #7257

Henry Law

unread,
Mar 18, 2012, 12:55:44 PM3/18/12
to
On 18/03/12 15:30, Ivan Shmakov wrote:
>
> I'd like to note that there're quite a few ASCII-based music
> notations. The ones that I'd readily recall are:
<snip>
>
> Perhaps, it'd make sense to reuse one of the above for whatever
> project you're working on.

That's really useful; I'd looked in CPAN but stopped short of doing that
particular bit of research.

Actually in this project I'm using a notation that already exists, for
better or worse; it's the one in the vast number of chord charts that I
have which need transposing for different singers! I need to be able to
transpose C Am7 Dm7 G7#5b9 to, say, Eb Cm7 Fm7 Bb7#5b9 (and without it
coming out as A#7#5b9 either). And so on.

End of thread ... getting seriously off-topic! I'd welcome
correspondence on the subject, though.

--

Henry Law Manchester, England

Ben Morrow

unread,
Mar 20, 2012, 11:12:18 AM3/20/12
to

Quoth Henry Law <ne...@lawshouse.org>:
>
[ representing musical notes as A=>0, A#=>1, Bb=>1, B=>2, &c.]
>
> Actually in this project I'm using a notation that already exists, for
> better or worse; it's the one in the vast number of chord charts that I
> have which need transposing for different singers! I need to be able to
> transpose C Am7 Dm7 G7#5b9 to, say, Eb Cm7 Fm7 Bb7#5b9 (and without it
> coming out as A#7#5b9 either). And so on.

I don't think you can do that with this representation. Consider
transposing

C F G C => 3 8 10 3

into B major

2 7 9 2 => B E F# B

and Db major

4 9 11 4 => Db Gb Ab Db

The enharmonic information you need to distinguish between F# and Gb is
exactly what you've just thrown away.

I would do a transposing job like this with a circle-of-fifths
representation, perhaps something like

my %sharps = qw( F 0 C 1 G 2 D 3 A 4 E 5 B 6 );
my %acc = qw( # +7 b -7 x +14 ## +14 bb -14 );
my ($accs) = map qr/$_/, join "|", keys %acc;
$acc{""} = 0;

my ($note, $acc, $mods) = /([A-G])($accs)(.*)/i
or die "not a valid chord symbol: '$_'\n";

my $chord = $sharps{uc $note} + $acc{lc $acc};
# transpose $chord

my %base = reverse %sharps;
my %offset = reverse %acc;
$offset{14} = "x"; # or ## if you prefer

my $base = $chord % 7;
my $offset = $chord - $base;

$offset > 14 and die "triple-sharp required\n";
$offset < -14 and die "triple-flat required\n";

my $symbol = "$base{$base}$offset{$offset}$mods";

I don't really like starting with F, but it seems to be the easiest way
to make it work: otherwise you end up with code like

my $base = $chord % 7;
$base == 6 and $base = -1;

which is just ugly when it can easily be avoided.

Ben

0 new messages