|
|
|
05-18-2020, 05:57 AM
|
#1
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Build chords depending on region name
Hi
I'm still looking for a script with which I can build chords for 4 vertically selected items.
As can be seen in the gif, I select 4 items with the same pitch.
The script should now build a chord by entering special pitch values.
e.g. from bottom to top (-12, + 4, + 7, + 14) or (-13, + 2, + 7, + 14) etc.
I would prefer to be able to step through multiple chords each time I run the script.
Thanks
Last edited by Dragonetti; 09-06-2020 at 12:56 PM.
|
|
|
05-19-2020, 03:22 AM
|
#2
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Who can help?
Each time the script is run, it should select a new table.
In this code he always takes table1.
This is probably also possible with "cycle action", but it would be nicer within a script.
Thanks
Code:
--------------- chord builder -----------------
local items = reaper.CountSelectedMediaItems()
if items == 0 then return end
reaper.Undo_BeginBlock()
reaper.PreventUIRefresh(1)
table1 = {12,7,4,-12}
table2 = {12,7,0,-8}
table3 = {12,7,4,0}
table4 = {16,12,7,-12}
table5 = {16,12,7,-8}
table6 = {16,12,7,0}
table7 = {19,16,12,-12}
table8 = {19,16,12,0}
for i = 0, items-1 do
local item = reaper.GetSelectedMediaItem(0,i)
local take = reaper.GetActiveTake(item)
if take then
local pitch = reaper.GetMediaItemTakeInfo_Value(take, 'D_PITCH')
local new_pitch = table1[i+1]
if new_pitch ~= pitch then
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',new_pitch)
reaper.UpdateItemInProject(item)
end
end
end
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock('Chords_builder_Major', -1)
|
|
|
05-22-2020, 02:12 AM
|
#3
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
bump!
|
|
|
05-22-2020, 06:03 AM
|
#4
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
I thought about doing that but thought it's easy just using midi ?
When I run it, it just gives the same table1 chord
if I change
new_pitch = table1[i+1]
to
new_pitch = table2[i+1]
it will give the table2 chord
not sure how you want it to work ?
|
|
|
05-22-2020, 06:16 AM
|
#5
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
Are you looking for it to toggle through the chords each time you run it ?
You could get it to set the chord by region name, so as you change the region name it will change the chord and even mute the notes not used of the selected items.
Or pick the chords from a GUI.
|
|
|
05-22-2020, 08:23 AM
|
#6
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Thank you for your answers.
These are all three great options.
I thought the easiest was to toggle, but ....
I have to think it over carefully now.
|
|
|
05-22-2020, 03:15 PM
|
#7
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
I have Script: ReaTrak create midi chords from region chord name.lua
It would do it all with a bit of modification.
It's just sets the root note
if root == "C" then note1 = 60
you could set that to 0 if all the note samples are "C"
then depending on the chord type
if string.find(",Maj,M,", ","..chord..",", 1, true) then note2=4 note3=7 end
that will set each note that amount of semitones above the first note.
set these to -1 instead of 0
note2 = 0
note3 = 0
note4 = 0
note5 = 0
note6 = 0
note7 = 0
so if the note is not set with the chord it will be muted -1
table1 = {note7,note6,note5,note4,note3,note2,note1}
You could also have a note below note1 for slash chords.
I'll give it more thought if you need any help with that.
|
|
|
05-22-2020, 03:57 PM
|
#8
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
There are also GUIs/Circle of Fifths to create/enter/change the chords (regions)
you could combine it to an all in one script.
|
|
|
05-23-2020, 01:49 AM
|
#9
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Thanks for your extensive script.
That would be awesome if I could convert it for my purposes.
I don't use midi tracks.
Only audio items should be manipulated.
In my case it must
"reaper.SetMediaItemTakeInfo_Value (take, 'D_PITCH', new_pitch)"
to get integrated.
Example:
I write Cm7 in the region, select my audio items.
Now the appropriate pitch values are entered when executing the script.
|
|
|
05-23-2020, 05:17 AM
|
#10
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
You have
reaper.SetMediaItemInfo_Value( item, B_MUTE, 1)
reaper.GetMediaItemInfo_Value( item, B_MUTE)
to mute the unused chord notes
I think it should be pretty easy to modify and add your script on the end.
Have a look at it, if you can't work it out I'll look at it in the morning here.
|
|
|
05-23-2020, 04:56 PM
|
#11
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
ReaTrak set selected audio items pitch from region chord name.lua
EDIT:updated
Try this with 8 items.
It's only set to do one chord region where the cursor is at the moment but it can be set to update all chord regions in one go.
You can loop the end part but I just set all 8 separately to work it out first.
Last edited by MusoBob; 05-23-2020 at 05:35 PM.
|
|
|
05-23-2020, 08:18 PM
|
#12
|
Human being with feelings
Join Date: Oct 2018
Posts: 367
|
Quote:
Originally Posted by Dragonetti
That would be awesome if I could convert it for my purposes.
|
You could put your sample in ReaSamplomatic5000 and then you'd be able to use midi chords like this https://youtu.be/VxEGphq0Gck?t=193
|
|
|
05-24-2020, 02:16 AM
|
#13
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
@pandbot
Thanks
The items are already in the arrangement and should stay that way. The items have to be selected and then changed(pitch) by script.
@MusoBob
Thank you very much MusoBob
for your script idea.
I don't need a mute function.
I only want to select certain items and manipulate the items depending on the RegionName.
The script should be executed with a toolbar button.
|
|
|
05-24-2020, 11:21 AM
|
#14
|
Human being with feelings
Join Date: Sep 2019
Posts: 1,115
|
RS5k is an inferior option since it changes the length of audio wave at pitch shift
|
|
|
05-24-2020, 02:07 PM
|
#15
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
Quote:
I don't need a mute function.
I only want to select certain items and manipulate the items depending on the RegionName.
The script should be executed with a toolbar button.
|
How many vertical items do you have 4 ? 5,6,7,8 ?
If you don't want to mute the item that are not used, what pitch do you want them to be, the chord root note ?
Do you want the script to update all chords at the same time ?
or just update the chord under the cursor ?
or update the time selection that could be one chord a few chords or all chords.
Do you have items on other tracks that are not chord notes ?
or do you just have the chord note items ?
so the script can "Item: Select all items in current time selection"
|
|
|
05-24-2020, 03:05 PM
|
#16
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
The script should only process selected items (maximum 8).
All unselected remain as they are.
Yes, update all selected items at the same time.
Cursor and time selection are not important.
There will be a lot of items that have no chord notes.
If I only selected 1 item, the chord root note would have to come.
Thank you for the effort
I hope it is easier to understand now
I have 2 examples here.
2 selected
8 selected
|
|
|
05-24-2020, 08:47 PM
|
#17
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
Try this and see if it works
ReaTrak set selected audio items pitch from region chord name v2.lua
Put you cursor under the chord region
select the items
run script
It is only doing one chord at a time
there is no slash chord note
it will still mute notes more than the chord notes
so if you have a Major chord and select 4 notes it will mute the top note,
but you can disable that by commenting these lines out or set mute to 0
reaper.SetMediaItemInfo_Value(item4, "B_MUTE", 1)
To reset pitch choose notes/all run Item properties: Reset item pitch
|
|
|
05-25-2020, 02:22 AM
|
#18
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Thank you for the effort
works quite well.
Is it possible to edit all selected items in a region at once? In this gif you have to edit each chord individually with the script.
|
|
|
05-26-2020, 12:08 PM
|
#19
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
Try this and see if it works
ReaTrak set selected audio items pitch from region chord name v2.lua
This will do all selected items across all chords.
It still mutes any extra notes that are not in the chord but as mentioned you can disable that.
If your notes are offset to create a strum, set all the reaper.SetEditCurPos "+.2" to a greater value to select all items, so it over the latest item.
You can add reaper.PreventUIRefresh( prevent_count ) to make it quicker.
I'll make another v3 that will use 8 notes to allow for slash chords.
Last edited by MusoBob; 05-26-2020 at 12:21 PM.
|
|
|
05-27-2020, 04:19 AM
|
#20
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
super tool
@ MusoBob, thank you very much
I still have to improve the voicing.
Installing a voicing improvement directly in your script becomes too confusing.
I have to make a new script request.
Should I open a new thread or will I get in trouble?
Last edited by Dragonetti; 05-27-2020 at 04:51 AM.
|
|
|
05-27-2020, 05:02 AM
|
#21
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
What does it need to do ?
|
|
|
05-27-2020, 06:02 AM
|
#22
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
There are still big jumps in voicing.
The new script must find the highest pitch value of the selected items, then transpose it down 1 octave and rearrange the chord so that the pitch stays from the bottom up.
If you do this a few times you get tight voicing.
edit:
reordering here does not mean moving audio items as can be seen in the GIF.
Reordering only means changing the pitch entries like this.
Last edited by Dragonetti; 05-27-2020 at 06:08 AM.
Reason: GIF doesn't quite show it
|
|
|
05-27-2020, 11:56 PM
|
#23
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
Can you just add
if new_pitch > 19 then new_pitch = new_pitch -12 end ?
or are they offset like a strum or do they all start at the same time ?
|
|
|
05-28-2020, 01:08 AM
|
#24
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
They start always at the same time, but
where do I have to enter that
"if new_pitch > 19 then new_pitch = new_pitch -12 end"
|
|
|
05-28-2020, 02:30 AM
|
#25
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
Try this
set octave to maximum note
you can leave the old code there with
--[[
old code
--]]
Code:
octave = 19 -- set to maximum octave note
if note7 == 255 and item_table[7] then
item7 = reaper.GetSelectedMediaItem(0,item_table[7])
reaper.SetMediaItemInfo_Value(item7, "B_MUTE", 1)
reaper.UpdateItemInProject(item7)
elseif item_table[7] then
item7 = reaper.GetSelectedMediaItem(0,item_table[7])
take = reaper.GetActiveTake(item7)
if note7+note1 > octave then note7 = note7 -12 end
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note7+note1)
reaper.SetMediaItemInfo_Value(item7, "B_MUTE", 0)
reaper.UpdateItemInProject(item7)
end
if note6 == 255 and item_table[6] then
item6 = reaper.GetSelectedMediaItem(0,item_table[6])
reaper.SetMediaItemInfo_Value(item6, "B_MUTE", 1)
reaper.UpdateItemInProject(item6)
elseif item_table[6] then
item6 = reaper.GetSelectedMediaItem(0,item_table[6])
take = reaper.GetActiveTake(item6)
if note6+note1 > octave then note6 = note6 -12 end
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note6+note1)
reaper.SetMediaItemInfo_Value(item6, "B_MUTE", 0)
reaper.UpdateItemInProject(item6)
end
if note5 == 255 and item_table[5] then
item5 = reaper.GetSelectedMediaItem(0,item_table[5])
reaper.SetMediaItemInfo_Value(item5, "B_MUTE", 1)
reaper.UpdateItemInProject(item5)
elseif item_table[6] then
item5 = reaper.GetSelectedMediaItem(0,item_table[5])
take = reaper.GetActiveTake(item5)
if note5+note1 > octave then note5 = note5 -12 end
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note5+note1)
reaper.SetMediaItemInfo_Value(item5, "B_MUTE", 0)
reaper.UpdateItemInProject(item5)
end
if note4 == 255 and item_table[4] then
item4 = reaper.GetSelectedMediaItem(0,item_table[4])
reaper.SetMediaItemInfo_Value(item4, "B_MUTE", 1)
reaper.UpdateItemInProject(item4)
elseif item_table[4] then
item4 = reaper.GetSelectedMediaItem(0,item_table[4])
take = reaper.GetActiveTake(item4)
if note4+note1 > octave then note4 = note4 -12 end
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note4+note1)
reaper.SetMediaItemInfo_Value(item4, "B_MUTE", 0)
reaper.UpdateItemInProject(item4)
end
if note3 == 255 and item_table[3] then
item3 = reaper.GetSelectedMediaItem(0,item_table[3])
reaper.SetMediaItemInfo_Value(item3, "B_MUTE", 1)
reaper.UpdateItemInProject(item3)
elseif item_table[3] then
item3 = reaper.GetSelectedMediaItem(0,item_table[3])
take = reaper.GetActiveTake(item3)
if note3+note1 > octave then note3 = note3 -12 end
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note3+note1)
reaper.SetMediaItemInfo_Value(item3, "B_MUTE", 0)
reaper.UpdateItemInProject(item3)
end
if note2 == 255 and item_table[2] then
item2 = reaper.GetSelectedMediaItem(0,item_table[2])
reaper.SetMediaItemInfo_Value(item2, "B_MUTE", 1)
reaper.UpdateItemInProject(item3)
elseif item_table[2] then
item2 = reaper.GetSelectedMediaItem(0,item_table[2])
take = reaper.GetActiveTake(item2)
if note2+note1 > octave then note2 = note2 -12 end
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note2+note1)
reaper.SetMediaItemInfo_Value(item2, "B_MUTE", 0)
reaper.UpdateItemInProject(item2)
end
if note1 == 255 and item_table[1] then
item1 = reaper.GetSelectedMediaItem(0,item_table[1])
reaper.SetMediaItemInfo_Value(item1, "B_MUTE", 1)
reaper.UpdateItemInProject(item1)
elseif item_table[1] then
item1 = reaper.GetSelectedMediaItem(0,item_table[1])
take = reaper.GetActiveTake(item1)
reaper.SetMediaItemTakeInfo_Value(take, 'D_PITCH',note1)
reaper.SetMediaItemInfo_Value(item1, "B_MUTE", 0)
reaper.UpdateItemInProject(item1)
end
|
|
|
05-28-2020, 02:51 AM
|
#26
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
I have set the maximum to 14.
now the deepest tone must be down, etc
|
|
|
05-28-2020, 03:21 AM
|
#27
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
No matter what track you play the sample on it will all sound the same.
Is there any reason they have to be in an order ?
|
|
|
05-28-2020, 04:44 AM
|
#28
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Unfortunately must be.
For example a string quartet or choir.
The division of parts is always bass tenor alto soprano or
Cello Viola Violin2 Violin1
Voice crossings shouldn't be.
The tracks will also get different sounds .
|
|
|
05-28-2020, 08:59 AM
|
#29
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Hi MusoBob
Would that be makeable with your script?
the script is only applied to one track and creates a scale according to the region name.
Cmaj gives 0, 2, 4, 5, 7, 9, 11, 12
Am gives -3, -1 , 0, 2, 4, 5, 7, 9
I don't want to change the region names because of the overview.
Thanks for the attention
|
|
|
05-28-2020, 04:40 PM
|
#30
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
I just get the chord root when I do one line.
|
|
|
05-29-2020, 06:05 AM
|
#31
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
If the items are distributed irregularly, the script will not work.
Can you improve that?
Maybe the script just has to consider the items on the different tracks and different regions
post#30:
I had asked if that would be possible.
Last edited by Dragonetti; 05-29-2020 at 06:11 AM.
|
|
|
05-29-2020, 07:23 PM
|
#32
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
You might be better with a GUI to do all the different things.
Like create scale for selected items, selected track.
What chord note for selected items, selected track.
|
|
|
06-01-2020, 08:50 AM
|
#34
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Unfortunately does not work.
Wouldn't it be better to foreget the cursor position and search for selected items within a region?
|
|
|
06-01-2020, 02:30 PM
|
#35
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
What's not working ? it won't run at all ? the notes are wrong ?
With the cursor position it's counting one lot of items vertically at a time so the top item is 0 and bottom item 6.
This is what I get:
|
|
|
06-01-2020, 03:42 PM
|
#36
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
The voicing is super but
if there is a rhythmic variation in the chords, the script stops
Furthermore you have to make Undo for each chord, which is a bit cumbersome.
Thanks
Last edited by Dragonetti; 06-02-2020 at 02:18 AM.
|
|
|
06-02-2020, 02:49 AM
|
#37
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
If you have a different amount of items of different lengths on different tracks you would be best to make another script that will count the tracks rather than items, so whatever items are on a particular track and within a particular region will be pitched accordingly.
|
|
|
06-02-2020, 03:11 AM
|
#38
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
Thanks
That is probably the solution
edit:
I found this in Reapack
Script: X-Raym_Select only tracks of selected items.lua
Unfortunately I can not integrate that.
Last edited by Dragonetti; 06-02-2020 at 03:58 AM.
|
|
|
06-02-2020, 04:20 AM
|
#39
|
Human being with feelings
Join Date: Sep 2014
Posts: 2,640
|
It is already using
Code:
commandID2 = reaper.NamedCommandLookup("_SWS_SELTRKWITEM")
reaper.Main_OnCommand(commandID2, 0) -- SWS: Select only track(s) with selected item(s) _SWS_SELTRKWITEM
that's how you call on another script, if it's a native reaper one:
Code:
reaper.Main_OnCommand(40297, 0) --Track: Unselect all tracks 40297
if you right click in the Action window you will get the ID.
Or you can copy the code from another script and put it in a function.
Code:
function select_tracks()
[scriptcode]
end
Code:
select_tracks() -- call on function
|
|
|
06-02-2020, 05:04 AM
|
#40
|
Human being with feelings
Join Date: Feb 2017
Location: Kiel
Posts: 974
|
First of all, no prospects of success
I have to get this:
pitch to all selected items of a track, depending on the region
is unfortunately too difficult
Last edited by Dragonetti; 06-02-2020 at 07:36 AM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:23 AM.
|