[JW Lua] Percussion midi map
Charles O. Lawrence
charlesolawrence at bellsouth.net
Mon Jan 20 17:14:38 CET 2014
Jan,
I finally got a chance to try it out, and you are right. In this case the
slot and staff numbers are the same, but that is not guaranteed. As you
suggest, It must have something to do with the channels that the staves are
mapped to. There are only 5 in this case. I don't see anything in the
Class Browser that looks like channel info. Maybe it's not implemented yet.
Jari will have to jump in here. Sorry I couldn't be of more help.
Charles
PS: There is a VirtualChannel in the FCInstrumentDef class, but what is a
virtual channel? Maybe it's related. Don't know.
-----Original Message-----
From: JWLua [mailto:jwlua-bounces at jwmusic.nu] On Behalf Of Jan Angermüller
Sent: Monday, January 20, 2014 10:33 AM
To: The JW Lua script plug-in.
Subject: Re: [JW Lua] Percussion midi map
Charles,
thanks for your input ! But I am not sure, it does not seem to make a
difference here.
In the example I posted region.StartStaff and region.StartSlot both return
7 (and EndStaff== StartStaff, EndSlot == StartSlot), but it should be 5 to
work properly.
Or in code:
region = finale.FCMusicRegion()
region:SetCurrentSelection()
print("Staff:",region.StartStaff,"Slot:",region.StartSlot)
This will print:
Staff: 7 Slot: 7
Jan
Am 20.01.2014 16:16, schrieb Charles O. Lawrence:
> Jan,
>
> Thought I'd throw this out. In the FCMusicRegion class, Slots are
> guaranteed to be consecutive from 1, but staves are not. I ran into
> this on a project I was working on earlier. Use Slot and not Staff
> and I think you will be OK. I'm going from memory here and have not
> tried it yet in your code sample.
>
> Charles Lawrence
>
>
>
>
> -----Original Message-----
> From: JWLua [mailto:jwlua-bounces at jwmusic.nu] On Behalf Of Jan
> Angermüller
> Sent: Monday, January 20, 2014 6:24 AM
> To: The JW Lua script plug-in.
> Subject: Re: [JW Lua] Percussion midi map
>
> Hi Jari,
>
> thanks for the many answers !
>
> Only the percussion MIDI map thing behaves strange.
>
> If you load the attached file in Finale2014, where the percussion is
> on staff 7, i.e. staff:Load(7) should be the solution to load the
> percussion map.
> But actually it works only if you write:
> staff:Load(5).
>
> Below is the full code. You need to load the attached musx file and
> select the percussion staff on the bottom, then run the script.
>
> The code first checks if only one staff was selected and the staff is
> a percussion staff. Then it loads the staff (which is staff 7) and
> tries "CreatePercussionMapNotes()" which returns nil.
> Then it loads staff 5 and suddenly CreatePercussionMapNotes() works.
>
> Any idea ?
> My idea is: although there are 7 staves in the file, in Score Manager
> are only 5 different playback definitions. Two staves share the same
> playback channel.
> So maybe there is some wrong mapping somewhere.
>
> I don't know if you need the following hint:
> the musx file was created by importing a MIDI file to Finale2014a.
> If you require the MIDI file, I can send it to you.
>
> Best regards,
> Jan
>
>
> --Display FCUI alert message
> region = finale.FCMusicRegion()
> region:SetCurrentSelection()
> if not (region.StartStaff==region.EndStaff) then
> local ui = finenv.UI()
> ui:AlertError("Please select one staff only.","Error: Multiple
> staves
> selected")
> return
> end
>
> local staff=finale.FCStaff()
> staff:Load(region.StartStaff)
> print("Staff number in region:", region.StartStaff) if not
> staff:IsPercussion() then
> local ui = finenv.UI()
> ui:AlertError("Please select a percussion staff only.\r\nPlease
> make sure that in ScoreManager\r\nnotation style is set to
> percussion.","Error: No percussion staff selected")
> return
> end
>
> local instrumentdef = staff:CreateInstrumentDef() local mapnotes =
> instrumentdef:CreatePercussionMapNotes()
> if not (mapnotes == nil) then
> for mapnote in each(mapnotes) do
> print (mapnote.NoteType, "= MIDI", mapnote.MidiNote)
> end
> else
> print("CreatePercussionMapNotes() returns nil") end
>
>
> --Now load staff 5 instead and try the same code again print("Loading
> staff
> 5")
> staff:Load(5)
> local instrumentdef = staff:CreateInstrumentDef() local mapnotes =
> instrumentdef:CreatePercussionMapNotes()
> if not (mapnotes == nil) then
> for mapnote in each(mapnotes) do
> print (mapnote.NoteType, "= MIDI", mapnote.MidiNote)
> end
> end
>
>
>
>
> Am 20.01.2014 09:16, schrieb Jari Williamsson:
>> Although percussion and instrument mapping in JW Lua is at a
>> development phase right now, the functionality you're seeking is
>> actually implemented in the beta you're using.
>>
>> Here's some skeleton code to get the percussion midi map for a
>> percussion staff.
>>
>> Since FCInstrumentDef:CreatePercussionMapNotes() will parse the XML
>> file information for the percussion MIDI map, make sure to put it
>> outside any loops for performance.
>>
>> ---
>> local staff = finale.FCStaff()
>> staff:Load(1) -- Or whatever staff ID with percussion
>>
>> local instrumentdef = staff:CreateInstrumentDef()
>>
>> local mapnotes = instrumentdef:CreatePercussionMapNotes()
>> for mapnote in each(mapnotes) do
>> print (mapnote.NoteType, "= MIDI", mapnote.MidiNote) end
>> ---
>>
>> Best regards,
>>
>> Jari Williamsson
>>
>>
>> On 2014-01-19 20:09, Jan Angermüller wrote:
>>> Hi Jari,
>>>
>>> I am now working on a remapping plugin for drum staves that were
>>> imported from MIDI files and that need remapping.
>>> E.g. if MIDI bass drum 35 needs to become MIDI bass drum 36 for
>>> correct playback on a certain drum sampl map.
>>>
>>> What works fine so far:
>>> reading the percussion staves, reassiging the new note pitch,
>>> reading the percussion layouts and matching the note types from
>>> FCPercussionNoteMod and FCPercussionLayoutNote.
>>>
>>> Only one final thing does not work yet:
>>> How do I get the note type for a certain MIDI note ?
>>> So that I can assign the correct note type for the new pitch.
>>> Probably it has to do with FCPercussionMapNote which has the
>>> properties MidiNote and NoteType. But it isn't implemented yet, is it ?
>>>
>>> Would be great to have that class !
>>> And very happy if the plugin is finally working.
>>> That saves hours and hours when importing MIDI.
>>>
>>> I must say again - JW Lua is really fun to program with. Great job !
>>>
>>> Thanks a lot,
>>> Jan
>>>
>>>
>>> _______________________________________________
>>> JWLua mailing list
>>> JWLua at jwmusic.nu
>>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>>
>>>
>>
>>
>> _______________________________________________
>> JWLua mailing list
>> JWLua at jwmusic.nu
>> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>>
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>
_______________________________________________
JWLua mailing list
JWLua at jwmusic.nu
http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
More information about the JWLua
mailing list