Sign in to follow this  
Followers 0
czardas

Visual Music String Concept - voo

28 posts in this topic

#1 ·  Posted (edited)

For a while I have been thinking of, and trying to, create several different music programs, but I struggle to understand anything I'm writing. The code I write is so unreadable. It was suggested that I learn midi, but not only can I not read midi, I also doubt that anyone was ever meant to read midi. Of course I gave it some serious consideration, looked at the specs and discovered there are some fundamental design flaws with Midi (speaking from the perspective of a musician). That's three strikes and you're out. Can't read it, can't write it and it is too restrictive (ie unsuitable).

So I have been trying to come up with a system that I can work with. The system needs to be readable and flexible like a score. Music scores use some tricks analogous to compression techniques. One example is repeat marks, but there are a few others - eg key signatures, GoTo ( :oops: ) the last or another section etc...

The idea is to create a language representing musical notes which can be read by a human and easily interpreted. But I thought I need to stop myself here. I've never written a language before, so I'm bound to make mistakes the first time round.

The first consideration is relative note values (or duration). The main system is binary - note values being divided by two: whole note, half note, quarter note etc... Dividing by two is arbitary because a note can be divided by any integer. If you write code that says play 440 Htz for a duration of 1.4 seconds, you will have to be a superhuman-number-whizz kid to spot how all numeric values in your code relate to each other. With midi it probably looks something like this __/\_/¯¯¯|_|\/¯¯¯¯ (nice)

So my plan was to loosely follow rules of notation and use symbols with a vaguely similar appearance to notes in a score. The first thing to consider is that pitch and duration are separate values also separated visually in written music. The rhythm is indicated by a system of stems flags and note head types. The pitch is indicated by vertical note position. So my first thought was to separate the notes from their duration. I can write notes ABC etc followed by their corresponding durations.

A,B,C D1,D2,D3

The rhythm values (D1,D2,D3) need to look more like note values, so here's my visually motivated selection:

L Long (not used)
o Lower case o - Open note without stem - whole note
þ Thorn - Open note + stem - Half note or minim
• Bullet - Closed note - Quarter note or crotchet
- Minus sign - Single flag - Eighth note
= Equals sign - Double flag - Sixteenth note
† Sword - Tripple flag - Thirty-second note
† Double Sword - Quadruple flag - Sixty-fourth Note (very rare)

Relative values
o
þþ
••••
---- ----
==== ==== ==== ====
†††† †††† †††† †††† †††† †††† †††† ††††
†††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† †††† <= These are meant to be double swords. Forum code tags are playing up.

This is now looking a bit more like music. I can group notes and recognize them visually. An interpreter would not necessarily care about the groups or spaces unless instructed otherwise. With a few more symbols I can create strings that relay practically all standard performance instructions found in written music.

The following string represents the music for 'Happy Birthday to You' in the key of D major (2#): It includes a few other symbols such as colon representing repeat marks, triplet divisions (3) and move the octave range up or down ( ^ v ).

2#AABA¬^DCv:^EDvAA^AFDCvB^GGFDED •3-3••¬•þ:•þ•3-3••••••3-3•••þ

This is easy to write, read and parse. We can set the tempo to any value and there is more. Does anyone have any thoughts/comments on this idea? Are there any downsides that I may have overlooked, or suggestions? Thanks in advance.

Edit

Without the repeat marks the rhythm could look like this:

$strToParse = "•3  -3 •     •   •  þ   •3  -3 •     •   •  þ   •3  -3 •     •   •    •  •  •3 -3 •  •  •  þ"
              ;Hap py birth day to you Hap py birth day to you Hap py birth day dear La La La La La La La La

Adding bar lines gives a clearer indication of meaning:

•3-3|••¬•|þ:|•|þ•3-3|•••|•••3-3|•••|þ

Unlike a midi stream (or so I believe), the time signature does not need to be indicated. This is one of the fundamental flaws of midi files. Instead of addressing the minimum requirements and building the language up from basic principles, they started with the false premise that the language needed to conform to strict theoretical rules (mus). Not all music is like that, and it's an inflexible approach which I would like to avoid.

Edited by czardas

Share this post


Link to post
Share on other sites



Hehe. I finished. This has to be one of the fastest languages ever written in history. Completed before any of you even got a chance to respond. I guess it helped having the syntax already written in advance. Now it's just a question of writing an interpreter. Oh and finding a suitable sound engine. ;)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I certainly hope it will be fun James. Beep will be used for one of the demos. I'm currently formalising the syntax and creating a kind of help file with examples. I have made a start on parsing the strings of commands. Most of it is pretty straight forward but it needs some time yet.

I'm hoping that it will be easy to start writing music using it, even for people without a musical background. Some of the more complicated syntax, such as rules for nested (loop) repeat sections, can be learned as you go along. The most complicated aspect, I've had to think about so far, is changes in tempo where multiple voices need to be synchronised.

With a bit of luck, I'll be able to get my PC to improvise its own (good quality) tunes. I'll be able to understand, from examining the visual output, where I need to tweak a thing or two in my artificial composer. The language will have other applications too of course. ;)

Edited by czardas

Share this post


Link to post
Share on other sites

I did music for my GCSEs, and I still can't understand a word of what you say. I finally got my head around it, working my way through strange looks from people around me as I went through my fourth rendition of Happy Birthday. They all wanted to know whos birthday it was, so I informed them it was my unbirthday today. The all now think I'm mad as a hatter ;)

Do you intend to encode dynamics? If so, how will you do that?

My only comment is that keeping the note and its length in seperate strings is a bad idea. If you want to stream this music over the internet, then you'll have to send two streams at once and try and keep them in sync... it would be a nightmare. I'd also refrain from using characters other than the basic ascii set. You never know what problems are just around the corner when you try and send this stuff to other people.

Share this post


Link to post
Share on other sites

The all now think I'm mad as a hatter Posted Image

it took them a while to catch up to the rest of us.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Do you intend to encode dynamics? If so, how will you do that?

Dynamics markings are as follows.

cresc, dim, ppp, pp, p, mp, mƒ, ƒ, ƒƒ, ƒƒƒ

example

ppp cresc • • • • | þ • • | mƒ o

My only comment is that keeping the note and its length in seperate strings is a bad idea. If you want to stream this music over the internet, then you'll have to send two streams at once and try and keep them in sync... it would be a nightmare. I'd also refrain from using characters other than the basic ascii set. You never know what problems are just around the corner when you try and send this stuff to other people.

I'm only using a few characters from the extended ascii set. It can be encoded however you like, I guess. Having separate streams seems to be the only way forward. It's the job of the interpreter to synchronise everything. If you have several instruments playing at once, I think there will always be a small amount of latency unless you have multiple core processors working together. I am aware that there are limitations. Implementing dynamics is indeed a bit of a problem. But maybe there will be a sound engine somewhere that can handle that. I don't really know.

Share this post


Link to post
Share on other sites

Having separate streams seems to be the only way forward. It's the job of the interpreter to synchronise everything. If you have several instruments playing at once, I think there will always be a small amount of latency unless you have multiple core processors working together. I am aware that there are limitations. Implementing dynamics is indeed a bit of a problem. But maybe there will be a sound engine somewhere that can handle that. I don't really know.

Normally you just fill a buffer up with rendered samples, and then a sound stream / driver collects these in realtime. If not.. i think you would have huge problems with buffer underruns + latency + sync + some more...

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I wasn't necessarily thinking of streaming data over the internet with this. I was going to make the interpreter create a buffer with a list of all commands before the first note is played. Then I was planning on using TimerDiff to trigger events. Synchronisation takes place mathematically in advance. a much earlier attempt by me, which uses this approach. The example plays back simultaneous notes. There is some latency, but it is not noticeable. You will need run the example.

The practicalities of this method will be limited by processing speed. I think the shortest note I can get away with using AutoIt will be about 30ms duration (a total guess). With multiple instruments this value is likely to change. I imagine that beyond about 10 instruments latency will become an issue. This is adequate for my purposes, but the language itself need not be limited by either my personal level of programming, current computer speeds or any current programming language limitations. I plan to have the interpreter check for potential playback issues and give warnings.

The interpreter will have to sift through the commands and remove those which lie beyond the scope of the playback system (this can be done easily using what is perhaps one of the most humongous regular expressions you ever saw). So an interpreter which uses Beep for playback would ignore terms such as [violin] etc...I appreciate the points that you people have raised. I think some compromise is unavoidable. It will never be possible to reproduce an absolutely clean analogue sound (to begin with).

Edited by czardas

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

My new scripting language now has a name - voo. File extension .voo. V stands for Virtuoso Music Script and oo comes from the following responce.

Oooh, this could be fun.

Still no interpreter, but I have tightened a few nuts and bolts. Here is the first voo file ever. ;)

"Mozart - Menuetto in C Major"
;_______________________________________________________________________________
[Flute]         G 5C E C  G  B  G 6C             5B      G   G G  G  G        
(•146) (3/4)|:§ • |• • • |•  •  • |þ.            |þ      •  |• -  -  •| %      |
[Flute]         ,  E G    B 5D 4B 5C 4B 5C D E F# G 4G   B  5C C 4B 5C D D C D
(•146) (3/4)|:§ • |• þ   |•  •  • |-  -  - - - - |•  •   •  |• -  -  •|• - - • |
[Trumpet]       ,  ,      G     ,  ,              ,         5E E  D  E F F E F
(•146) (3/4)|:§ • |þ.    |þ     • |þ.            |þ.        |• -  -  •|• - - • |
[Trumpet]      3G 4C E C 3G  , 4G  C     ,  5C   4G  ,       G G  G  G      
(•146) (3/4)|:§ • |• • • |•  •  • |•     •   •   |•  þ      |• -  -  •|%       |
[Timpani]      2G 3C   C 2G     G  A     A   A    G  G G G G G         G        
(•146) (3/4)|:§ • |þ   • |þ     • |•     •   •   |•  - - - -|þ.       |þ.      |
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
;_____________________________________________________________________
 G  A B 6C ,      5D 4B  5C  D G F# G F G 4B  5C D ,
 •  • • |• • fin :|• |þ   • |- - -  - - - |þ   •|• • Ø DS/Ø|Ø DC/fin||
4B 5C D  C ,      4B  G   A  ,             G   A B ,
 •  • • |• • fin :|• |þ   • |þ.           |þ   •|• • Ø DS/Ø|Ø DC/fin||
4G  A B  G ,       , 5G          ,         G      4G
 •  • • |• • fin :|• |þ._   |•   þ        |þ._  |• • Ø DS/Ø|Ø DC/fin||
3G  G G 4C ,       , 3G G G 4G            3G G G G ,
 •  • • |• • fin :|• |• • • |þ.           |• • •|• • Ø DS/Ø|Ø DC/fin||
 G  G G 3C         , 2G      G   G    G    G     G G
 •  • • |þ   fin :|• |þ.    |•   •    •   |þ.   |• • Ø DS/Ø|Ø DC/fin||
;¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Edited by czardas
1 person likes this

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Reminds me an awful lot about this.

It only reminds you of that because Jon hasn't fixed the forum code tags, so it looks strange. ;)

Edited by czardas

Share this post


Link to post
Share on other sites

It only reminds you of that because Jon hasn't fixed the forum code tags, so it looks strange. ;)

Ok, then, how should it look?

This looks like a garbled mess:

[color=#000000]"Mozart - Menuetto in C Major"[/color]
[Flute]G5CECGBG6C5BGGGGGGAB6C,5D4B5CDGF#GFG4B5CD,
(•146)(3/4)|:§•|•••|•••|þ.|þ•|•--•|%|•••|••fin:|•|þ •|------|þ•|••ØDS/Ø|ØDC/fin
[Flute],EGB5D4B5C4B5CDEF#G4GB5CC4B5CDDCD4B5CDC,4BGA,GAB,
(•146)(3/4)|:§•|•þ|•••|------|•••|•--•|•--•|•••|••fin:|•|þ•|þ.|þ•|••ØDS/Ø|ØDC/fin
[Trumpet],,G,,,5EEDEFFEF4GABG,,5G,G4G
(•146)(3/4)|:§•|þ.|þ•|þ.|þ.|•--•|•--•|•••|••fin:|•|þ._|•þ|þ._|••ØDS/Ø|ØDC/fin
[Trumpet]3G4CEC3G,4GC,5C4G,GGGG3GGG4C,,3GGG4G3GGGG,
(•146)(3/4)|:§•|•••|•••|•••|•þ|•--•|%|•••|••fin:|•|•••|þ.|•••|••ØDS/Ø|ØDC/fin
[Timpani]2G3CC2GGAAAGGGGGGGGGG3C,2GGGGGGG
(•146)(3/4)|:§•|þ•|þ•|•••|•----|þ.|þ.|•••|þfin:|•|þ.|•••|þ.|••ØDS/Ø|ØDC/fin

Share this post


Link to post
Share on other sites

Ok, then, how should it look?

Here you go...

menuetto.zip

I added a midi version so you can compair the code. That is what I call a garbled mess. The midi code is so ugly I wouldn't even attempt to post a sample.

Share this post


Link to post
Share on other sites

"Mozart - Menuetto in C Major"
[Flute]       G5CEC G B G6C       5B   G  GG G G      GA B6C,    5D4B5C DGF#GFG4B5C D,
(•146)(3/4)|:§•|•••|• • •|þ.      |þ   • |•- - •|%   |•• •|••fin:|•|þ •|--- ---|þ •|••ØDS/Ø|ØDC/fin
[Flute]       , EG  B5D4B5C4B5CDEF#G4G B 5CC4B5C DDCD4B5CD C,    4B G A ,       G A B,
(•146)(3/4)|:§•|•þ |• • •|- - ----|• • • |•- - •|•--•|• ••|••fin:|•|þ •|þ.     |þ •|••ØDS/Ø|ØDC/fin
[Trumpet]     , ,   G   , ,        ,     5EE D E FFEF4GA B G,     ,5G     ,     G   4G
(•146)(3/4)|:§•|þ. |þ   •|þ.      |þ.    |•- - •|•--•|• ••|••fin:|•|þ._|• þ    |þ._|••ØDS/Ø|ØDC/fin
[Trumpet]    3G4CEC3G ,4G C   ,5C 4G ,    GG G G     3G GG4C,     ,3GGG4G      3GGG G,
(•146)(3/4)|:§•|•••|• • •|•   • • |• þ   |•- - •|%   |• ••|••fin:|•|•••|þ.     |•••|••ØDS/Ø|ØDC/fin
[Timpani]    2G3C C2G   G A   A A  G GGGG G      G    G GG3C      ,2G   G G  G  G   GG
(•146)(3/4)|:§•|þ •|þ   •|•   • • |• ----|þ.    |þ.  |• ••|þ fin:|•|þ. |• •  • |þ. |••ØDS/Ø|ØDC/fin

Or ..

Share this post


Link to post
Share on other sites

Thanks, that looks much better. ;) All lines are read simultaneously. You can see where the music gets more busy from the clustering.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

How do you think it'll look with some syntax highlighting? Perhaps that'd help.

It certainly would help a lot. I'm currently half way through writing a tutorial. It starts very easy with the musical version of Hello World. The Mozart sample is actually quite advanced.

Edited by czardas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0