Re: [Bluemusic-users] Note Visualization Script
Brought to you by:
kunstmusik
From: Steven Y. <ste...@gm...> - 2007-07-25 05:24:39
|
Hi Michael and All, I updated my visualization script a bit and have pasted it below. An updated example image is available at: http://www.kunstmusik.com/visualization.png Enjoy! Steven from ScriptingUtils import * from java.awt import * from java.awt.image import * from javax.swing import JOptionPane as optPane from javax.swing import JFrame, JScrollPane, JLabel, ImageIcon from java.io import * from javax.imageio import ImageIO from blue.utility import ScoreUtilities as SU import math pObj = blueData.getPolyObject().clone() pObj.generateGlobals(blueData.globalOrcSco.clone()) pObj.generateFTables(blueData.tableSet.clone()) pObj.generateInstruments(blueData.arrangement.clone()) notes = pObj.generateNotes() notes.sort() colors = { 1 : Color(192,192,255,128), 2 : Color(200,255,200,128), 3 : Color(255,192,200,128), 5 : Color(250,250,255,128) } defaultColor = Color(128, 128, 128, 128) # SETUP FOR DRAWING min = 4 max = 13 range = (max - min) * 12 pchHeight = 8 pixelSecond = 8 lastNote = notes[notes.size() -1] endTime = lastNote.startTime + lastNote.subjectiveDuration w = int(math.ceil(endTime) * pixelSecond) h = range * pchHeight img = BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB) g = img.createGraphics() g.setColor(Color.BLACK) g.fillRect(0, 0, w, h) for note in notes: x = int(note.startTime * pixelSecond) pch = note.getPField(4) baseTen = SU.getBaseTen(pch) y = h - (int(baseTen - (min * 12)) * pchHeight) w = int(note.subjectiveDuration) * pixelSecond inum = int(note.getPField(1)) c = colors[inum] if c == None: c = defaultColor g.setColor(c) g.fillRect(x, y, w, pchHeight) print "%i : %i : %i : %i"%(baseTen, x, y, w) frame = JFrame("Orchestra Notes Visualization") label = JLabel(ImageIcon(img)) jsp = JScrollPane(label) frame.contentPane.add(jsp) frame.pack() frame.show() #out = FileOutputStream(File("c:\\test.png")) #mageIO.write(img, "png", out) #out.flush() #out.close() On 7/23/07, Steven Yi <ste...@gm...> wrote: > Hi Michael, > > Yes, the idea right now I had in mind was color per instrument as well > as drawing suble lines like in the pianoRoll to draw a sort of grid. > Since the basic framework is there it shouldn't be too tricky to do. > I'll post another screenshot and script once I have time to do so. > > Thanks for the reply! > stevne > > On 7/23/07, Michael Bechard <got...@ya...> wrote: > > Hey Steven, > > > > I had to read through the code to get a feel for the usefulness of this image, but I get it now. What might be useful would be a color differentiation between different numbered instruments; that way, the image could also serve as a guide to one's instrument distribution. > > > > Michael Bechard > > > > ----- Original Message ---- > > From: Steven Yi <ste...@gm...> > > To: blue users mailing list <blu...@li...> > > Sent: Saturday, July 21, 2007 6:41:31 PM > > Subject: [Bluemusic-users] Note Visualization Script > > > > Hi All, > > > > I was working on a note visualization script for blue to use with > > notes for my instruments that follow the orchestra note standard I > > use. I thought it might be useful so have pasted the script below. A > > screenshot of the window that opens up is available here: > > > > http://www.kunstmusik.com/visualization.png > > > > There is commented out code at the bottom of the script that will do > > saving of the generated image to disk as PNG file. The script is just > > a draft and I'm still working on it but it is somewhat customized to > > my own work and notes, so if you are interested in using you may need > > to modify for your own setup. To use, go to "Script->Manage Script > > Library" and add the script there and modify for your own use. > > > > Enjoy! > > steven > > > > > > [SCRIPT BELOW] > > > > from ScriptingUtils import * > > from java.awt import * > > from java.awt.image import * > > from javax.swing import JOptionPane as optPane > > from javax.swing import JFrame, JScrollPane, JLabel, ImageIcon > > from java.io import * > > from javax.imageio import ImageIO > > from blue.utility import ScoreUtilities as SU > > import math > > > > pObj = blueData.getPolyObject().clone() > > pObj.generateGlobals(blueData.globalOrcSco.clone()) > > pObj.generateFTables(blueData.tableSet.clone()) > > pObj.generateInstruments(blueData.arrangement.clone()) > > > > notes = pObj.generateNotes() > > notes.sort() > > > > > > # SETUP FOR DRAWING > > min = 4 > > max = 13 > > > > range = (max - min) * 12 > > > > pchHeight = 8 > > pixelSecond = 8 > > > > lastNote = notes[notes.size() -1] > > endTime = lastNote.startTime + lastNote.subjectiveDuration > > > > > > w = int(math.ceil(endTime) * pixelSecond) > > h = range * pchHeight > > > > img = BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB) > > g = img.createGraphics() > > g.setColor(Color.BLACK) > > g.fillRect(0, 0, w, h) > > > > g.setColor(Color(128, 128, 128, 128)) > > > > for note in notes: > > x = int(note.startTime * pixelSecond) > > pch = note.getPField(4) > > > > baseTen = SU.getBaseTen(pch) > > > > y = h - (int(baseTen - (min * 12)) * pchHeight) > > > > > > w = int(note.subjectiveDuration) * pixelSecond > > g.fillRect(x, y, w, pchHeight) > > > > print "%i : %i : %i : %i"%(baseTen, x, y, w) > > > > > > frame = JFrame("Orchestra Notes Visualization") > > label = JLabel(ImageIcon(img)) > > jsp = JScrollPane(label) > > frame.contentPane.add(jsp) > > frame.pack() > > frame.show() > > > > #out = FileOutputStream(File("c:\\test.png")) > > #mageIO.write(img, "png", out) > > #out.flush() > > #out.close() > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Bluemusic-users mailing list > > Blu...@li... > > https://lists.sourceforge.net/lists/listinfo/bluemusic-users > > > > > > > > > > > > ____________________________________________________________________________________ > > Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center. > > http://autos.yahoo.com/green_center/ > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > Bluemusic-users mailing list > > Blu...@li... > > https://lists.sourceforge.net/lists/listinfo/bluemusic-users > > > |