-- Version 0.2 --[[-------------------------------------------------------------------------- This plugin beams the notes on two (or three) RestChords. Just insert it before the first of the RestChords you want to beam. Notice that RestChords might be notated with quarter notes, otherwise 'real' beams will overlap the fake ones from this object. Duration for first and last notes can be set, but it will not affect playback since 'real' duration is set by the rest of the RestChord. Any stem length must be adjusted manually. --]]-------------------------------------------------------------------------- local userObjTypeName = ... local Note1 = nwc.drawpos.new() local Note2 = nwc.drawpos.new() local NoteList = {'Eighth', 'Sixteenth', 'Sixteenth (Beam)', 'Thirty-second', 'Thirty-second (Beam)', 'Sixty-fourth', 'Sixty-fourth (Beam)'} local object_spec = { { id='DurNote1', label='First note duration', type='enum', default=NoteList[1], list=NoteList }, { id='DurNote2', label='Last note duration', type='enum', default=NoteList[1], list=NoteList }, { id='num', label='RestChords', type='enum', default='2', list={'2','3'} }, } local function do_spin(t,d) t.num = t.num + d t.num = t.num end local function do_draw(t) nwcdraw.setPen('solid', 0) if not Note1:find('next', 'objType', 'RestChord') then return end Note1:reset() Note1:find('next', 'objType', 'RestChord') local xN1Tip, yN1Tip = Note1:xyStemTip() local xN1Base, yN1Base = Note1:xyStemAnchor() for var=1,t.num do Note2:find('next', 'objType', 'RestChord') end local xN2Tip, yN2Tip = Note2:xyStemTip() local xN2Base, yN2Base = Note2:xyStemAnchor() local B = yN2Tip-yN1Tip local C = xN2Tip-xN1Tip local A = math.sqrt(B^2 + C^2) local beta = math.atan(B/C) local gamma = math.rad(90)-beta local c = 1 local a = c/math.sin(gamma) local b = c*(1/math.tan(gamma)) ------- --8th-- ------- if Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip) nwcdraw.beginPath() nwcdraw.line(xN2Tip,yN2Tip) nwcdraw.line(xN2Tip,(yN2Tip)-1) nwcdraw.line(xN1Tip,(yN1Tip)-1) nwcdraw.line(xN1Tip,yN1Tip) nwcdraw.closeFigure() nwcdraw.endPath() end if Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip) nwcdraw.beginPath() nwcdraw.line(xN2Tip,yN2Tip) nwcdraw.line(xN2Tip,(yN2Tip)+1) nwcdraw.line(xN1Tip,(yN1Tip)+1) nwcdraw.line(xN1Tip,yN1Tip) nwcdraw.closeFigure() nwcdraw.endPath() end ----------- --1stNOTE-- ----------- ------- --16th-- ------- if t.DurNote1 == NoteList[2] and Note1:stemDir() == -1 or t.DurNote1 == NoteList[4] and Note1:stemDir() == -1 or t.DurNote1 == NoteList[6] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-2) nwcdraw.beginPath() nwcdraw.line(xN1Tip+c,(yN1Tip+b)-2) nwcdraw.line(xN1Tip+c,(yN1Tip+b)-3) nwcdraw.line(xN1Tip,yN1Tip-3) nwcdraw.line(xN1Tip,yN1Tip-2) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[3] and Note1:stemDir() == -1 or t.DurNote1 == NoteList[5] and Note1:stemDir() == -1 or t.DurNote1 == NoteList[7] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-2) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)-2) nwcdraw.line(xN2Tip-c,(yN2Tip-b)-3) nwcdraw.line(xN1Tip,yN1Tip-3) nwcdraw.line(xN1Tip,yN1Tip-2) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[2] and Note1:stemDir() == 1 or t.DurNote1 == NoteList[4] and Note1:stemDir() == 1 or t.DurNote1 == NoteList[6] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+2) nwcdraw.beginPath() nwcdraw.line(xN1Tip+c,(yN1Tip+b)+2) nwcdraw.line(xN1Tip+c,(yN1Tip+b)+3) nwcdraw.line(xN1Tip,yN1Tip+3) nwcdraw.line(xN1Tip,yN1Tip+2) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[3] and Note1:stemDir() == 1 or t.DurNote1 == NoteList[5] and Note1:stemDir() == 1 or t.DurNote1 == NoteList[7] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+2) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)+2) nwcdraw.line(xN2Tip-c,(yN2Tip-b)+3) nwcdraw.line(xN1Tip,yN1Tip+3) nwcdraw.line(xN1Tip,yN1Tip+2) nwcdraw.closeFigure() nwcdraw.endPath() end ------- --32th-- ------- if t.DurNote1 == NoteList[4] and Note1:stemDir() == -1 or t.DurNote1 == NoteList[6] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-4) nwcdraw.beginPath() nwcdraw.line(xN1Tip+c,(yN1Tip+b)-4) nwcdraw.line(xN1Tip+c,(yN1Tip+b)-5) nwcdraw.line(xN1Tip,yN1Tip-5) nwcdraw.line(xN1Tip,yN1Tip-4) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[5] and Note1:stemDir() == -1 or t.DurNote1 == NoteList[7] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-4) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)-4) nwcdraw.line(xN2Tip-c,(yN2Tip-b)-5) nwcdraw.line(xN1Tip,yN1Tip-5) nwcdraw.line(xN1Tip,yN1Tip-4) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[4] and Note1:stemDir() == 1 or t.DurNote1 == NoteList[6] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+4) nwcdraw.beginPath() nwcdraw.line(xN1Tip+c,(yN1Tip+b)+4) nwcdraw.line(xN1Tip+c,(yN1Tip+b)+5) nwcdraw.line(xN1Tip,yN1Tip+5) nwcdraw.line(xN1Tip,yN1Tip+4) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[5] and Note1:stemDir() == 1 or t.DurNote1 == NoteList[7] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+4) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)+4) nwcdraw.line(xN2Tip-c,(yN2Tip-b)+5) nwcdraw.line(xN1Tip,yN1Tip+5) nwcdraw.line(xN1Tip,yN1Tip+4) nwcdraw.closeFigure() nwcdraw.endPath() end ------- --64th-- ------- if t.DurNote1 == NoteList[6] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-6) nwcdraw.beginPath() nwcdraw.line(xN1Tip+c,(yN1Tip+b)-6) nwcdraw.line(xN1Tip+c,(yN1Tip+b)-7) nwcdraw.line(xN1Tip,yN1Tip-7) nwcdraw.line(xN1Tip,yN1Tip-6) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[7] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-6) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)-6) nwcdraw.line(xN2Tip-c,(yN2Tip-b)-7) nwcdraw.line(xN1Tip,yN1Tip-7) nwcdraw.line(xN1Tip,yN1Tip-6) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[6] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+6) nwcdraw.beginPath() nwcdraw.line(xN1Tip+c,(yN1Tip+b)+6) nwcdraw.line(xN1Tip+c,(yN1Tip+b)+7) nwcdraw.line(xN1Tip,yN1Tip+7) nwcdraw.line(xN1Tip,yN1Tip+6) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote1 == NoteList[7] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+6) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)+6) nwcdraw.line(xN2Tip-c,(yN2Tip-b)+7) nwcdraw.line(xN1Tip,yN1Tip+7) nwcdraw.line(xN1Tip,yN1Tip+6) nwcdraw.closeFigure() nwcdraw.endPath() end ----------- --2ndNOTE-- ----------- -------- --16th-- -------- if t.DurNote2 == NoteList[2] and Note2:stemDir() == -1 or t.DurNote2 == NoteList[4] and Note2:stemDir() == -1 or t.DurNote2 == NoteList[6] and Note2:stemDir() == -1 then nwcdraw.moveTo(xN2Tip,yN2Tip-2) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)-2) nwcdraw.line(xN2Tip-c,(yN2Tip-b)-3) nwcdraw.line(xN2Tip-1,(yN2Tip-b)-3) nwcdraw.line(xN2Tip,yN2Tip-3) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[3] and Note1:stemDir() == -1 or t.DurNote2 == NoteList[5] and Note1:stemDir() == -1 or t.DurNote2 == NoteList[7] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-2) nwcdraw.beginPath() nwcdraw.line(xN2Tip,(yN2Tip)-2) nwcdraw.line(xN2Tip,(yN2Tip)-3) nwcdraw.line(xN1Tip,yN1Tip-3) nwcdraw.line(xN1Tip,yN1Tip-2) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[2] and Note2:stemDir() == 1 or t.DurNote2 == NoteList[4] and Note2:stemDir() == 1 or t.DurNote2 == NoteList[6] and Note2:stemDir() == 1 then nwcdraw.moveTo(xN2Tip,yN2Tip+2) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)+2) nwcdraw.line(xN2Tip-c,(yN2Tip-b)+3) nwcdraw.line(xN2Tip-1,(yN2Tip-b)+3) nwcdraw.line(xN2Tip,yN2Tip+3) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[3] and Note1:stemDir() == 1 or t.DurNote2 == NoteList[5] and Note1:stemDir() == 1 or t.DurNote2 == NoteList[7] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+2) nwcdraw.beginPath() nwcdraw.line(xN2Tip,(yN2Tip)+2) nwcdraw.line(xN2Tip,(yN2Tip)+3) nwcdraw.line(xN1Tip,yN1Tip+3) nwcdraw.line(xN1Tip,yN1Tip+3) nwcdraw.closeFigure() nwcdraw.endPath() end -------- --32th-- -------- if t.DurNote2 == NoteList[4] and Note2:stemDir() == -1 or t.DurNote2 == NoteList[6] and Note2:stemDir() == -1 then nwcdraw.moveTo(xN2Tip,yN2Tip-4) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)-4) nwcdraw.line(xN2Tip-c,(yN2Tip-b)-5) nwcdraw.line(xN2Tip-1,(yN2Tip-b)-5) nwcdraw.line(xN2Tip,yN2Tip-5) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[5] and Note1:stemDir() == -1 or t.DurNote2 == NoteList[7] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-4) nwcdraw.beginPath() nwcdraw.line(xN2Tip,(yN2Tip)-4) nwcdraw.line(xN2Tip,(yN2Tip)-5) nwcdraw.line(xN1Tip,yN1Tip-5) nwcdraw.line(xN1Tip,yN1Tip-4) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[4] and Note2:stemDir() == 1 or t.DurNote2 == NoteList[6] and Note2:stemDir() == 1 then nwcdraw.moveTo(xN2Tip,yN2Tip+4) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)+4) nwcdraw.line(xN2Tip-c,(yN2Tip-b)+5) nwcdraw.line(xN2Tip-1,(yN2Tip-b)+5) nwcdraw.line(xN2Tip,yN2Tip+5) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[5] and Note1:stemDir() == 1 or t.DurNote2 == NoteList[7] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+4) nwcdraw.beginPath() nwcdraw.line(xN2Tip,(yN2Tip)+4) nwcdraw.line(xN2Tip,(yN2Tip)+5) nwcdraw.line(xN1Tip,yN1Tip+5) nwcdraw.line(xN1Tip,yN1Tip+4) nwcdraw.closeFigure() nwcdraw.endPath() end -------- --64th-- -------- if t.DurNote2 == NoteList[6] and Note2:stemDir() == -1 then nwcdraw.moveTo(xN2Tip,yN2Tip-6) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)-6) nwcdraw.line(xN2Tip-c,(yN2Tip-b)-7) nwcdraw.line(xN2Tip-1,(yN2Tip-b)-7) nwcdraw.line(xN2Tip,yN2Tip-7) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[7] and Note1:stemDir() == -1 then nwcdraw.moveTo(xN1Tip,yN1Tip-6) nwcdraw.beginPath() nwcdraw.line(xN2Tip,(yN2Tip)-6) nwcdraw.line(xN2Tip,(yN2Tip)-7) nwcdraw.line(xN1Tip,yN1Tip-7) nwcdraw.line(xN1Tip,yN1Tip-6) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[6] and Note2:stemDir() == 1 then nwcdraw.moveTo(xN2Tip,yN2Tip+6) nwcdraw.beginPath() nwcdraw.line(xN2Tip-c,(yN2Tip-b)+6) nwcdraw.line(xN2Tip-c,(yN2Tip-b)+7) nwcdraw.line(xN2Tip-1,(yN2Tip-b)+7) nwcdraw.line(xN2Tip,yN2Tip+7) nwcdraw.closeFigure() nwcdraw.endPath() end if t.DurNote2 == NoteList[7] and Note1:stemDir() == 1 then nwcdraw.moveTo(xN1Tip,yN1Tip+6) nwcdraw.beginPath() nwcdraw.line(xN2Tip,(yN2Tip)+6) nwcdraw.line(xN2Tip,(yN2Tip)+7) nwcdraw.line(xN1Tip,yN1Tip+7) nwcdraw.line(xN1Tip,yN1Tip+6) nwcdraw.closeFigure() nwcdraw.endPath() end -------- end return { spec = object_spec, spin = do_spin, draw = do_draw, }