Dtab Printer - 625 Permutation Printer + Drum Notation Rendering WIP

Started by kevin, January 13, 2011, 07:54:54 PM

Previous topic - Next topic

kevin

  625 Permutation Printer

    Found this project while looking for something else entirely, thought it lost actually..  It was originally written in another language  way back in 10th,Oct,2000, but now it's part of the PlayBASIC family..   The project originally started as an experiment for converting early DTAB (drum Tabs) into sheet music representation.    Surprisingly the idea of converting tabs to sheet music (at that time) went down like a led balloon, so the project got put on the back burner.    Later, I turned it into this permutation builder as teaching aid.

    The builder is a way of generating independence exercise on mass, 625 exercises to be exact.   It's currently hard coded to build snare line against feet combination's.   Not too sure what i'll do with it, but at least it's not lost..            

   Attached is an example of charts it produces.  Which are lot better than i remember, although that's probably just my printer doing a better job of printing it.  
 



kevin

  Drum Notation Rendering

   Been working on various music related projects the past week or so,  which are all related in some way.  In these projects there comes a time when  we need display a sheet music representation.    The previous attempts at this (the 625 permutation printer above for example)  all takes fixed size graphical approach.  While easier, the down side is that the render output can't be sized to the resolution of the printer surface or monitor for that matter.  You can scale it, but it's messy and suffers from a loss of detail.    So this is an experiment is rendering promotional sheet music (for drum kit) using a vector graphic approach.    

  In this (proof of concept) version, the scene is built from a combination of the lines and shape renders.  Obviously the stems are connected using lines/boxes and the note heads and rest symbols are built from PlayBASIC shapes.   Even though the symbols are hand drawn in PlayShape, they give a pretty useful result.   Those with a keen eye will notice the shapes have anti aliasing of sorts.  Which is achieved by pre-rendering the shape to temp image buffer then filtering it that down.  Which helps smooth out the result.   (See example)

  Even though there's a ways to go, i'm pretty happy with the result thus far.   To take this further, it be nice to generate most of the symbols needed using bezier curves.  So the rendering can scale the geometry level.   But that's for another day :)


 

kevin

  Musical Note Shape Editor

   Continuing on from the notation rendering above,  rather than create note heads by hand, I've been knocking a simple shape editor together. The idea being that the shape is constructed from set of control points and edges.  Each edge has it's own 'curve' controls (which can't be edited yet), these default to being perpendicular to the edge.  Which is why they bulge out.   By moving the control points you can control how they curve.    Which in sort of like how vector fonts work.   Which might actually be be viable.. But that's another subject..

    Anyway here's a bit of screenie, sort of looks like a half eaten apple.

 

kevin

  Musical Note Shape Editor V0.02 - Curve Modification

  Added some curve modification tools to the editor yesterday.  It's bit clunky to use at this point, but just does the job for the most part. Bellow is a "C" like shape using the bezier curves for the edges.

 

 Musical Note Shape Editor V0.02b - Curve Modification Continued

   Rewrote some of code this morning, starting with the edge curve control. the previous version worked by trying to detect the action from the click only,  but it causes problems when clicking on overlapping  line segments to drag them, which was rather annoying.   So that's been broken into separate modes,  which eliminates the issue completely, but it does add another 'click' to the process.

  Also, added some controls to increase/decease an edges smoothness and a way to export to the object to a shape (second picture)..  All in all, it's working pretty well.  


kevin

  Musical Note Shape Editor V0.03 - Set Dressing

     Added a bunch of set dressing to the editor this morning and last night.   Mainly stuff like loading and saving shapes and some general alter info.   Looks a bit more like  a real program of sorts now, rather than the thrown together hodge podge that is it.    

     Will most likely post a demo today for the tinkers        



  Musical Note Shape Editor V0.03b - Editing Rest Symbols

       Been actually using the tool to create some note heads starting with some rest symbols (2nd and 3rd pictures), as you can see works pretty. 




kevin


  Scalable Detail

     Added some simple controls to set the overall detail level of the curves.  In the first pic we're bumping up the detail level, and in the other we're scaling it back.   Since the detail is scalable,  then the edge level can be controlled when zooming the shape in or out.  Without this if we zoom the shape in (make it bigger) then eventually you'd notice the curves are made of edges, and if you zoom out, then the edges don't need as must detail.  So they can be reduced.   








kevin

 Musical Note Head Editor V0.06

    Here's a bit of demo for you guys to tinker with.   This version has a number of keys that you'll need to familiarize yourself with if you're going to able to create a shape (listed bellow).  

    The concept is as follows.   The shape is constructed from a set of vertex using the vertex mode.  These are points in 2d space, once some points are added, you move to the edge editor.  Here you can connect the vertex together to form the edges of the shape.  The edges default to bezier curves, so it'll show the connection and the curve between the points and the control points of the curve along this edge.      To alter an edge, we need to swap to manipulation mode (M) - Here we select the edge to alter , then you can drag the control vectors when you want them.  You can toggle the edge curve type also.  Which only has two modes, straight and bezier (T).  

     


Controls:
==========

    -----------------------
    F1  = HELP DIALOG
    -----------------------


    -----------------------
    F2  = Vectex Editor Mode
    -----------------------

             Left Mouse Click = Add Vertex
             Right Mouse Click = MOVE Vertex  (Must be on the vertex)

             Delete Key = Delete nearest Vertex to mouse pointer

             
            Note: If you delete a vertex that has edges attached to it, these will be deleted also.


    -----------------------
    F3  = Edge Editor Mode
    -----------------------

         
          A key = Add/Delete Edge Mode

                  left click to connect closest edge to destination edge

                  Delete key to delete closest edge to the mouse pointer.  (Doesn't delete the vertex)


          M Key  = Modify Edge Mode

                  Left Click to select edge.  

                  Right Click or space bar to deselect edge  

                  When selected,  left click the curve controls to alter curve

                  T = Change select edges curve type.  Two modes, straight and bezier

                   Left/Right Arrows to change to edges smoothness factor (more or less samples along the curve).  


    -----------------------
    F5  = Load
    -----------------------

         
   Load shape into the buffer, this will clear any current project.

    -----------------------
    F6  = Save
    -----------------------

   Save the current buffer to disc.
   

    -----------------------
    F12  = NEW
    -----------------------

   Reset the shape buffer to default. This will clear any changes you've made



    -----------------------
   ENTER
    -----------------------

       Render sized shape


    -----------------------
    SHIFT  LEFT ARROW
    -----------------------

        Scale down shapes overall edge curve factor

         
    -----------------------
    SHIFT  RIGHT ARROW
    -----------------------

        Scale up shapes overall edge curve factor


    -----------------------
    ESC
    -----------------------

         QUIT

Download
 
  Musical Note Head Editor

kevin

  Musical Note Head Editor V0.07

    Added some controls  so the user can define the area within which the shape exists.  In the older version this is basically vertex space, and it'd just assume the widest and  highest vertex are the size of the shape.   Which works for a quick test, but in the real thing we need to be able to define the area a symbol takes, which may or may not be the bounding volume of the vertex/edges.      This allows the output graphic to be centered and aligned to a particular edge position within the graphic.
 
     Bellow we're looking at an apple shape with it's bounds set. In the test output we can see the images keep the same proportions.  Which is what i need for the music rendering and anything else this finds it's way into.  

Apple Shape


[NoteHead]

[Name]
unknown

[SmoothLevel]
5000.0

[Viewport]
0,0,899,699

[Vertex]
6
392.0,203.0
712.0,231.0
609.0,538.0
271.0,580.0
111.0,261.0
331.0,56.0

[Edges]
7
1,1.0
6,48.10887,13.62118
1,48.10887,13.62118
1,1.0
1,4.103757,-49.83131
2,4.103757,-49.83131
1,1.0
2,-268.0,46.0
3,-75.0,-30.0
1,1.0
4,-176.0,145.0
3,278.0,162.0
1,1.0
4,81.0,-56.0
5,270.0,64.0
1,1.0
5,-10.9957,-48.77597
1,-10.9957,-48.77597
1,1.0
1,-48.10887,-13.62118
6,-48.10887,-13.62118

[/NoteHead]







kevin

 DTAB (Drum Tab) Importer  V0.01

   The past day or so i've been pulling the various threads of these libraries together.   Since Ultimately I'd like to build an implementation that can render DTAB drum tabs as sheet music.  So obviously we need to be able to load DTAB files in first.  Which just means porting the loaders over from VB.  The porting for the most part has been pretty painless, apart from the odd WTF moment with the format.   Most of the code cuts and pastes over and runs after a quick bit of syntax tweaking.  The main changes have been with how the file is physical loaded and byte stream was being read.   Which took a bit of time writing a set of emulation functions.  Writing a wrapper just allows the loader routines to run virtually as is, which is simpler (and less error prone) than altering them all manually.  

   Anyway, after a day of messing around the loader is able to read compressed DTAB drum tab files.  Speed wise it works pretty well, loading a 5 minute long Dream Theater track inside 150 milliseconds.   While it can load them, it can't really render them.  So pictured bellow is just the raw bars dumped to the screen.  

   Next we'll try and connect some of this together and see if get working in some form.  Can't imagine it being very pretty initially though.. (understatement of the year :) ).


Proportional Sheet Music

    The second and third pictures are of the next progression of the bare bones sheet music render.  This one has some support for proportional rendering, as well as being able to import bezier note head (current only one note head) and render them to scaled sheet.   Still a ways to go, but we're heading in the right direction now I think.

 

kevin

   Proportional Sheet Music V0.02

     Slowly connecting the parts of the render together.  The attached pic's are another round of  mock up of the page render with some note support.  The notes are just drawn with a routine onto the page using some more bezier note heads.    You'll notice the notes the tied together, but those are just mock ups as at this point.  Still stewing over what's going to be best method of handling the stems and note buffer, since the existing stem connection is a bit clunky (limiting).  Could probably get away with it, but it'd annoy me :)  

     Anyway, a few more pic's.  The Scale (X and Y) show in red in the top left hand corner of the frame.


kevin


Proportional Sheet Music V0.04 - Connecting Stems

    When originally sitting down to attack this problem, I'd always thought the only real challenge would be making the render scalable. I knew the stems would be difficult, but assumed they would be secondary issue.   That was before having to write something flexible enough to tie a bar of notes together.  Which turns out to be a lot trickier than i'd first thought,  and most likely why many similar programs produce some 'odd' notations in certain circumstances.

   The problem is simple on the surface, connect the notes together by their duration so the durations add up to the bar duration.  Previously I'd been using templates for this, which works,  but it's limiting from the perspective that i'd have to manually build all the stem combinations (by hand or in code).   Didn't like that idea too much,  so wanted to build a parser that would do this task automatically.

    Breaking the stream down into a durations is easy, it gets tricky when balancing the output into something legible for humans.  Since there's any numbers ways of notating the same thing in music.  It's like a question that has more than one answer.  So the trick is getting it to style the output into something that falls hopefully within the most common conventions possible, so us poor humans can understand it.

    I've been working on the problem the last few days, after testing a couple of different approaches the current solution works a lot like the expression resolver in PlayBASIC.   So the parser has multiple passes starting out with the smallest possible fragments then compressing them up until the stream can't get any smaller.  At that time, the resulting stream is a representation of the original but with notes and rests in longest durations.   The render then tries to draw this stream.   

    At this point the test render is already more capable than the template method shown above (although the test currently doesn't draw graphic note heads.. just some text :) ),  since it can handle  dotted notes and rests as well as 32nd resolution as part of the stream.   It's far from perfect, but getting better with each little revision session.   Moreover, it should be possible to render not just groupings in two, but groupings of three.   Making for much nicer output of time signatures that are multiples of 3, like 6/8 and 12/8 for example.   



kevin

#11
  Proportional Sheet Music V0.05 - Connecting Stems Continued

    Haven't really made much visual progress with this since last time, although the converter can now import the loaded DTAB as the note stream.   The sheet music representation is held in a delta time format (ATM), much like Midi files.   Ideally, so I can use the library to render general music and not just DTAB at some point.  Currently it can load a track and render some basic note heads to the staff.  The rests and stems/flags are still a work in progress due to the bar formats constant evolution (changed twice in two days :) ).  If the track was only made up of only evenly distributed notes, it'd make resolving it a lot simpler, but the stream can have triple sections anywhere. grrr


    The picture is of a basic 8th note rhythm.  Just testing the appending flags to the stems.. Looks ok  

ATLUS


kevin

#13
 Proportional Sheet Music V0.06 - Crawling Towards Note Durations

    Been busy much of the last week on other (paid) projects, but I've been getting back to the importers duration conversions.   This takes the raw stream of 32nd note ticks and re-casts them into more approach note & rest durations.    The basic process was actually worked out a while ago,  but bringing all the different threads together has taken a bit longer than i'd expected.   Even at this simple stage  the program is fast approaching 5000 lines.  

   In today's version, the duration casting is up and running and this time the bar render is  drawing from the bars note &  rest duration data.  Currently it can only render 1/4 note and 1/8 note (flagged) note types.  Previous versions above, have no concept of length of each note or rest periods, so they fudge this completely.    Knowing this stuff helps from connecting the stems, drawing rests through to laying out the bars on the sheet (since the width can be calculated).    So while it doesn't look like much of a change from last time, it is.


    The 3 bars pictured bellow are a created from the following simple 3 bar tab.   So in bar #1 we have a 1/8 note groove, bar#2 is 1/4 note groove and bar #3 is combination.




Count:| 1 + 2 + 3 + 4 +  | 1   2   3   4    | 1   2   3   4 +  |
    Hh:| x-x-x-x-x-x-x-x- | x---x---x---x--- | x---x---x---x--- |
   SnD:| ----o-------o--- | ----o-------o--- | ----o-------o-o- |
   BD1:| o-------o------- | o-------o------- | o-------o------- |






kevin


Proportional Sheet Music V0.07 - Basic Drum tab to Sheet Music conversion

   Today we're finally starting to see all the parts pull together, with this version we can see some layout support of the chart on the page, accents, 1/4, 1/8,1/16,1/32 note flagging (no ties as yet) and basic 1/4 note rests.   Which (barely) gives us enough information on the chart that a human can start to understand the sheet music version of the Drum Tab, even if it looks a little odd without the common durations tied together.



Count:| 1e+a2e+a3e+a4e+a | 1 + 2 + 3 + 4 +  | 1   2   3e+a4    |
    Hh:| ---------------- | x-x-x-x-x-x-x-x- | x---x---xxxxx--- |
   SnD:| OoooOoooOooOooOo | ----o-------o--- | ----o-------o--- |
   BD1:| ---------------- | o-------o------- | o-------o------- |


Count:| 1   2   3   4 +  | 1   2 + 3 +a4 +a |
    Hh:| x---x---x---x--- | --------x-x-x-xx |
   SnD:| ----o-------o-o- | ----o-o-----o--- |
   BD1:| o-------o------- | --------o--o---- |