From: Dave F. <dav...@co...> - 2004-03-26 08:10:05
|
All, Working on that middle layer. :) I reduced some of trackwin's dependence on global variables tonight, but it ain't pretty. Tomorrow I'll tackle handling selection, which should make it possible to clean up everything I did tonight. :) Mostly I changed a lot of calls to separate global variables to calls within gProject. It's not quite the nice API I'm trying to build yet, though. I might have to implement a track interface at that time, which will be good to get rid of the tSong class. I hope I didn't break anything with this commit, but I probably did. :( It still builds, though. :) Anyway, on handling selection. Here's what I'm shooting for and the steps I'm planning on taking to get there. I'm shooting to have a jppTrack class that stores track data for each track in the song and eliminating the tSong class with it. Most of tSong will get factored into jppProject and jppTrack. Anyway, I want jppTrack to store selection data, and I want some GUI widget to share a pointer (probably use reference counting) to the internal jppTrack that both jppProject and the mysterious GUI widget know about. I want trackwin to dynamically create a new GUI track for each track in the project, and allow for creating new tracks. So I want each jppTrack to store its own selection data. :) So, I figure I'll make an interface to selection data in jppProject as a stepping-stone, and I'll switch trackwin to use that. That will allow me to later work on the jppTrack class and rewrite the selection implementation in jppProject to use the new jppTrack when it's ready. I'll also change the Open and Save methods (now stored in jppProject) to create new jppTracks instead of sticking it in a song. I figure the existing GUI will just ask jppProject what's selected in order to draw it, and when the user makes a new selection it will tell jppProject about the new selection. Ultimately I want the GUI to be able to ask the tracks themselves for selection data, so having a selection interface in jppProject is just a steppingstone and will become deprecated as soon as there's a jppTrack class. :) The main thing about selection is that there's a lot of middle-layer logic in tTrackWin::MousePlay that uses selection data to figure out where to start playing, what to record, and so forth. I consider selection to be data shared between the middle layer and the GUI layer, so I figure I'll move it to the middle layer and give the GUI strong access to it (like having its own pointer and using reference counting or some method like that). Eliminating the tSong class and the corresponding Song global variable is going to affect pretty much everything, near as I can tell. That's ok, though. :) If you want to work on eliminating the Song global variable, you can add your 'extern gProject' line to any file currently using the Song variable and change every reference to Song to gProject->Song. That, at least, brings all the global variables into one place. It won't help to eliminate the class, though. What's needed is an interface in gProject to the tracks themselves that's independent of the backend storage facility, and the tSong class turned into the backend storage facility. So jppProject would be a light layer between the GUI and tSong, but that interface to the tracks themselves is needed to be able to make the change in the backend storage facility. Ultimately I'd like to have Jazz using its own project file format and reading midi files will be done by importing the file. There are bad reasons to do this, and good ones. Mainly I want to be able to embed wav data in a project file, and have a good open project file format that will allow easily adding patterns, templates, and stuff, and easily support multiple midi devices in the studio (similar to RoseGarden, in fact as a proof-of-concept when we get there, someone (me?) should write an importer for RoseGarden projects). Dave -- Visit my website! http://www.davefancella.com/?event=em A fool's brain digests philosophy into folly, science into superstition, and art into pedantry. Hence University education. -- G. B. Shaw |