[Tapper-develop] Color Grid
Status: Pre-Alpha
Brought to you by:
druleeparsec
From: <Gre...@ub...> - 2000-10-17 22:31:05
|
Hi Sean: I have a slightly (OK, significantly) different idea. Each Grid object takes a TuningBlock Object so it knows how many strings there are. No instrument I know of has a tuning with a gap between the strings of more than a 5th (7 frets) (Certainly no player other than Allan Holdsworth has hands that can span more than 7 frets) so if we show a 7 or 8 fret span then that should be enough. However, we would also like to be able to show an entire neck so let's not limit our grid. Instead we'll have a method where we can set the number of frets to be shown. Since we know how many strings there are and we know how wide the Grid object is we can figure out the spacing between the strings (Notice how generic this is all staying, there's no mention of the exact number of strings) Once we know the spacing we can easily calculate the width of the grid. That's how wide the frets should be drawn. Then we draw the strings horizontally. There is a missing class that we still need. We need a fingering class that has a Note object in it, but it also has a string and fret number and an interval name (Root, 2nd, Major 3rd, flat 7th etc). The grid needs to take a collection of these fingering objects. This fingering object should prbably also have a lowest and higest fret (of that fingering) so we know how to number the frets and how to place the fret markers (But never show less than 5 frets, even if a chord can be fingered on only one fret ). Since we already know the vertical and horizontal locations of the frets and strings we can easily compute how to center a dot on the string within a fret. Notice that we are NOT making the frets progressivly closer together as they would on a real instrument. We'll just keep the frets at an equal spacing. That spacing is determined by the size of the panel If the grid has the position of the upper right corner (or whatever corner Java 2D uses as the origin), the offset of each string from that corner, and the offset of each fret from that corner, we can easily place them on the grid. Since we know the spacing of the strings and frets we can compute how big the fingering dot (or text) needs to be. Now, each of these fingering objects also knows how to paint itself. A fingering object would have 2 modes. Mode 1 is the dot mode, mode 2 is the interval node. In mode 1 the fingering object paints it's self as a dot unless it's the root of the chord or scale in which case it paints itself as a circle. In mode 2 the fingering object paints itself as an appropriate string. ie: R, m2, M2, m3, M3, 4, aug4, 5, m6, 6, m7, 7, R, m9, 9, and so on. In either mode if the fingering is "active" (which means we are currently playing it's MIDI note) then it paints itself in the "active fingering" color. So, the paint method will compute the size of the grid object and computer the spacing for the frets and strings. It gets the lowest and highest frets from the fingering collection object and draws the frets and fret markers. (I'll build you a fret position class). Then it draws the strings. Then it goes through each note in the fingering block collection and places that note on the grid using the appropriate mode of drawing. The only thing the fingering block will need to place itself correctly is the upper left corner position and the string spacing and fret spacing. Since the fingering object knows it's on the 3rd string and 5th fret it will place itself correctly. This is close to how I coded the original Tapper (actually, this design is more object oriented than the original) If having the original C++ code is any help I could put it up on the web site. This design isn't final. Go ahead and beat it up and debate me on it. I think it's a good design but if you find some flaws I havn't seen then that's great, we'll just make it that much better. Greg P.S. Here's the requred classes Note (done) FingeringNote (not done) Fingering (not done, this is a collection of Fingering notes with Key and ChordScale objects) FretDotPattern (not done, this shows which frets have fret dots, which fret has a double dot, and if they are big dots or small dots) GridColor (done) GridSomethingOrOther (this is whatever the name of the actual GRID will be. I couldn't think up a good name off the top of my head right now) Tuning (done) TuningBlock (done) ChordScale( not done, the formula for a particular chord or scale) Key (not done) I guess I better get working on these support classes. :-) |