|
|
|
09-11-2013, 05:11 PM
|
#1
|
Human being with feelings
Join Date: Sep 2013
Posts: 137
|
ReaChorder a new extension
EDIT: This extension is under development. Newer versions maybe posted, check the thread for the latest version. Most often, the last uploaded version is the one that works best. From now on, only Python 3.3 and up is supported.
Required software:
Reaper 4.5.2+: http://reaper.fm/
Python 3.3: http://www.python.org/download/releases/3.3.0/
SWS extension v2.4.0 #1: http://www.standingwaterstudios.com/
How to install Python for Reaper: http://forum.cockos.com/showthread.php?t=127110
Mac OS tkinter issues? See: http://www.python.org/getit/mac/tcltk/
------------------------------------------------------------------------------------------------
I've created a new ReaScript plugin for Reaper, called ReaChorder. With ReaChorder one can create a "song" from scratch. A kind of song wizard that proposes chord/song structures based upon the circle of fifths. It proposes the best possible chords for a chosen mood, key and scale. It then draws the song structure into the MIDI editor. Cheating? perhaps! Of course, it isn't fool-proof, but that wasn't the intention. It's just for fun and inspiration.
For it work:
1. Move the contents of the .zip to your /Scripts/ folder in Reaper. For NT this can be: C:\Users\<username>\AppData\Roaming\REAPER\Scripts
2. Import the ReaChorder.py into the action window (new/load).
Then you can load it in the MIDI piano-roll editor, or add script action to the toolbar as a shortcut. (right click on the toolbar in the MIDI editor).
In any event, it must be called from the MIDI piano roll editor.
Would love to hear what you think about it. And if you have some improvements, I would love to hear them too.
Download: https://stash.reaper.fm/v/17939/Rea-Chorder.zip
-
Last edited by Sasje; 11-22-2013 at 03:06 AM.
|
|
|
09-11-2013, 06:22 PM
|
#2
|
Human being with feelings
Join Date: Mar 2012
Location: Kentucky, USA
Posts: 254
|
Maybe just me but I get this error when I load the script.
If I click OK I get the error again. Click OK again and the script appears to run. I'm running Reaper v4.52x64/Win7x64.
|
|
|
09-11-2013, 06:56 PM
|
#3
|
Human being with feelings
Join Date: Sep 2013
Posts: 137
|
Hi mwe,
I also get that sporadically. Sometimes it starts fine, and sometimes it throws. Why it happens is a mystery to me... I'm not very well versed in Python, in fact, it's my 2nd Python script. Maybe we can suppress it, or maybe it's just a bug...
Microsoft says: "This is an unsupported way to load Visual C++ DLLs."
Probably something to do with tkinter?
...so if anyone has a suggestion/idea?
-
Last edited by Sasje; 09-11-2013 at 07:02 PM.
|
|
|
09-11-2013, 07:36 PM
|
#4
|
Human being with feelings
Join Date: Mar 2012
Location: Kentucky, USA
Posts: 254
|
I'm not really a programmer at all so this is multiple orders of magnitude beyond me. FWIW, I'm running Python v3.2.5 and SWS 2.4.0.
|
|
|
09-13-2013, 07:11 AM
|
#5
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Thanks for this.
I just tested it, no errors here so far, seems to work fine.
I like such "creativity aids" when the damn writer's block is round the corner.
Though I hope the Reaper devs can somehow make working with tkinter apps like this a little less quirky.
Currently:
- hides behind Reaper's window when clicking anywhere in Reaper
- no undo (as said, but probably hard to implement)
- steals Reaper's keyboard shortcuts when in focus
|
|
|
09-13-2013, 08:44 AM
|
#6
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Quote:
Originally Posted by Sasje
Hi mwe,
I also get that sporadically. Sometimes it starts fine, and sometimes it throws. Why it happens is a mystery to me... I'm not very well versed in Python, in fact, it's my 2nd Python script. Maybe we can suppress it, or maybe it's just a bug...
Microsoft says: "This is an unsupported way to load Visual C++ DLLs."
Probably something to do with tkinter?
...so if anyone has a suggestion/idea?
-
|
Working fine here (Win XP 32bit), thank you.
Quote:
Originally Posted by nofish
Thanks for this.
I just tested it, no errors here so far, seems to work fine.
I like such "creativity aids" when the damn writer's block is round the corner.
Though I hope the Reaper devs can somehow make working with tkinter apps like this a little less quirky.
Currently:
- hides behind Reaper's window when clicking anywhere in Reaper
|
It is possible to place the tkinter window on top of other windows with "wm_attributes("-topmost", 1)":
Code:
class Application:
def __init__(self, root):
self.root = root
self.root.title('ReaChorder')
self.root.wm_attributes("-topmost", 1)
ttk.Frame(self.root, borderwidth=5, relief="sunken", width=740,height=300).pack()
self.init_widgets()
Quote:
Originally Posted by nofish
- no undo (as said, but probably hard to implement)
|
Undo should work if these (bolded) lines are added to ReaChord_Functions.py:
Code:
from sws_python import *
from contextlib import contextmanager
from random import randint
@contextmanager
def undoable(message):
RPR_Undo_BeginBlock2(0)
try:
yield
finally:
RPR_Undo_EndBlock2(0, message, -1)
posi = 0
.
.
.
def drawMidi(a,b,c,d,e):
with undoable("Undo point name here"):
selAllNotesTselection()
deleteSelectedNotes()
MidiPos = 11520
rand = randint(0, 2)
#drawChords(a,b,c,d,0,'verse',rand)
e = int(e)
d = int(d)
if e == 0 or e == 1: # Chords only
.
.
.
Here's another "undo" example (flip selected notes - post #38):
http://forum.cockos.com/showthread.php?t=91871
Quote:
Originally Posted by nofish
- steals Reaper's keyboard shortcuts when in focus
|
This is the most annoying thing with tkinter - ReaScript doesn't support multithreading .
Last edited by spk77; 09-13-2013 at 09:09 AM.
|
|
|
09-13-2013, 08:57 AM
|
#7
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Thanks for the info, spk77.
|
|
|
09-13-2013, 10:29 AM
|
#8
|
Human being with feelings
Join Date: Feb 2012
Location: UK
Posts: 33
|
Working here too. Useful. It's in 3/4 time. Can it be set to other time signatures?
Thanks for your efforts
|
|
|
09-14-2013, 05:01 AM
|
#9
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
You can change it to 4/4 by finding this in ReaChord_Functions....
in drawMidi
Code:
selAllNotesTselection()
deleteSelectedNotes()
MidiPos = 11520 ### ~~~~ change this to 15360
rand = randint(0, 2)
#drawChords(a,b,c,d,0,'verse',rand)
e = int(e)
d = int(d)
in drawChords
Code:
# create chords
position = [0,length * 3,length * 6, length * 9, length * 12, length * 15, length * 18, length * 21, length * 24, length * 27, length * 30, length * 33] ### ---- delete this line
position = 0 ### ++++ add this line
for i, val in enumerate(progressions[int(a)-1]):
if ChordMode == 'verse':
x = int(chartselect[int(val)])
if ChordMode == 'chorus':
x = int(useCircle[int(val)])
# for j, vm in enumerate(Chords[x]):
### ~~~~~ change the following lines to
note = addNote(midiTake,channel,velocity,position + p,int(Chords[x][0])-12,length*4,0)
note = addNote(midiTake,channel,velocity,position + p,int(Chords[x][1])-12,length*4,0)
note = addNote(midiTake,channel,velocity,position + p,int(Chords[x][2])-12,length*4,0)
position += length*4 ### ++++ add this line
... I've been doing quite a bit to the code actually, if it's okay with sasje I'll share it in the next day or so. It now (should) work(s) in Python 2 and 3 (wasn't in v2 now is) and does 3/4 and 4/4. I've also been changing the structure of the data and how it's read to make it easier to add new things to it.
|
|
|
09-14-2013, 10:29 AM
|
#10
|
Human being with feelings
Join Date: Feb 2012
Location: UK
Posts: 33
|
Thanks. I look forward to seeing what you have done
|
|
|
09-18-2013, 05:12 PM
|
#11
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
I've changed the structure of the code a bit and it now has a Settings window. This probably needs testing in P3 because I don't know if there are any P2 vs P3 differences in there.
It now does a bass note on another channel, draws regions too (both optionally), allows you to choose channels for the different parts and stores/recalls those settings.
Thanks very much for this Sasje, you can see I've commented out some settings which I'm going to add later. I was going to code something like this from scratch so you've saved a heap of time.
Cheers.
|
|
|
09-18-2013, 05:24 PM
|
#12
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
Is this basically like Band in a box or ChordPulse? If so, that would be so awesome!! Need to DL Python before I try it.
|
|
|
09-19-2013, 02:43 AM
|
#13
|
Human being with feelings
Join Date: Sep 2013
Posts: 137
|
I'm sorry for the late reply, I am very sick at the moment and unable to use a computer for more than 30 minutes.
If anyone wants to join in on developing this extension: feel free to post your version. It's yours, it's the Reaper spirit. ...Then we can take it from there? collaboration? and work from newly posted versions? ...the new features sound great. Keep 'em coming. Thanks for the kind help and suggestions.
I have some additional ideas:
- more chord formula's. (pentatonic, dorian, aeolian...)
- random/reverse chord function based upon the chosen formula (since the verse is pretty much fixed right now)
- add strum patterns (for guitar?)
- drum pattern generator?
- more chords? (it only has min, maj and dim right now) and maybe a chord picker in a new tab? (to manually draw chords)
When I'm a bit better I'll check it out. Looking forward to it.
-
Last edited by Sasje; 09-19-2013 at 03:07 AM.
|
|
|
09-19-2013, 06:46 AM
|
#14
|
Human being with feelings
Join Date: Feb 2012
Location: UK
Posts: 33
|
Hi
I am getting a global name error "unicode is not defined" (line 12 of the module path os.path.dirname(unicod(_file_,encoding))
I am using P3, so it might be that?
|
|
|
09-19-2013, 09:29 AM
|
#15
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by BeardyWeirdy
Hi
I am getting a global name error "unicode is not defined" (line 12 of the module path os.path.dirname(unicod(_file_,encoding))
I am using P3, so it might be that?
|
Same here.
[img]http://img809.**************/img809/8572/wxd.png[/img]
Also using Python 3.2, WinXP
|
|
|
09-19-2013, 10:08 AM
|
#16
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
EDIT: The attached version is still broken... do NOT download. Merci.
@Sasje: sorry to hear about your illness, you've put in a great shift so far getting this done. Re the drum and guitar patterns, at the moment it's just about ready to output MIDI to trigger different notes per section so using it in combination with other existing plugins would get better results more quickly than coding it from scratch in this. So before that the other ideas would be quicker to implement.
The code/data in general could do with more organizing as well to make it easier to add the extras in. I haven't touched the text output section for example, but this isn't linked to the actual MIDI output at the moment so there are things like that could do with getting sorted out first imo.
@BeardyWeirdy/nofish: sorry, it seems like I am the spanner in the works by using P2. I've attached a version that should fix that (unicode is now str in P3), but at least the imports up until that point have worked. There are tiny differences like in the ttk library Frame is now frame.
I should really get Python 3 installed and working with Reaper. The last time I tried I came across the same issues that people in the other thread have encountered but P2 was plug and play so I just used that. I'll give it another shot.
Last edited by Lazarus; 09-19-2013 at 12:10 PM.
|
|
|
09-19-2013, 11:38 AM
|
#17
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
I'd love to try this but I am having a Python problem. I can't get rescript to work, I guess I'm setting the python directory wrong. Where should it be, what DLL do I set it for????
|
|
|
09-19-2013, 12:02 PM
|
#18
|
Human being with feelings
Join Date: Sep 2013
Posts: 137
|
To get Python working: install any version you want. I prefer 3.1 Then manually copy the pythonXX.dll from C:/Windows/system32/ to: C:\pythonXX\ and C:\pythonXX\DLLs\ - if you have Windows... You can use any version this way. This is because Python doesn't copy the dll to it's location for Reaper to discover it.
I use Python 3.1 but I can also use Python 2.7 this way.
|
|
|
09-19-2013, 12:09 PM
|
#19
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
I just installed Python 3 and in Preferences -> ReaScript, set the custom path to C:\Windows\System32 and put python33.dll in the "Force Python to use .dll" field.
So I am now on P3 and can see that Sasje#s wonderful script is still broken in P3. I'll fix it tonight.
|
|
|
09-19-2013, 02:23 PM
|
#20
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
That's it working (only) in P3 now after a couple of name changes. I've attached it here.
|
|
|
09-19-2013, 04:55 PM
|
#21
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
Thanks guys!!! Got the Python to work... kinda... Made a new track and put a midi item in it. Then opened the ME and went to actions and tried to execute the reachord. (I installed the .py when I finally got python working.)
What am I doing wrong now?
|
|
|
09-19-2013, 05:06 PM
|
#22
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
You just need to install the SWS/S&M extensions so that the script can use the MIDI stuff in it.
|
|
|
09-19-2013, 07:01 PM
|
#23
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
I did that, now I think I am close. But I am now getting this error. It did open up a reachorder window, but it is frozen and empty.
|
|
|
09-20-2013, 12:12 AM
|
#24
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
Hmmm, it's working here in 3.3 and 3.2 but not 3.1 or 3.0. What version are you using?
edit: hmmm, didn't change any dimensions in the GUI between the v2 version and the v4 and the labels in the background image are out of alignment. Strange things are afoot at Camp Python.
Last edited by Lazarus; 09-20-2013 at 02:28 AM.
|
|
|
09-20-2013, 02:32 AM
|
#25
|
Human being with feelings
Join Date: Feb 2012
Location: UK
Posts: 33
|
I get same error as FWD0120 here
I am on win 7, 32bit version, and Python is 33
We are getting closer! I hope I can help more soon, I am just starting to learn python, (Worked in pascal for years), I will see if I can bug hunt at all this end
|
|
|
09-20-2013, 05:12 AM
|
#26
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
It smells like the hack I used for including ReaChord_Functions from the resources directory is the issue. If you move that into the same directory as ReaChorder and in ReaChorder put...
Code:
from ReaChord_Functions import *
... it may well even possibly slightly work!
|
|
|
09-20-2013, 06:48 AM
|
#27
|
Human being with feelings
Join Date: Feb 2012
Location: UK
Posts: 33
|
I tried it - but no luck, still the same error as before with the same message as fwd0120 posted (expt line number have moved on omen obviously.
it now looks like
from reaper_python import *
from ReaChord_Functions import *
import os
import sys
sys.argv=["Main"]
and I copied ReaChord_Functions up to the same folder as the main py script.
Still getting the stuck window behind reaper as well
Sorry!
|
|
|
09-20-2013, 07:22 AM
|
#28
|
Human being with feelings
Join Date: Sep 2013
Posts: 137
|
Can't get it to work. I tried: Python 2.7, 3.0, 3.1 and 3.3 each versions throws different errors...
I get this error in 3.3: It tries to find images/icons and fails. It tries to find it in /Documents and Settings/ But I have Windows 7 so that directory doesn't exist...?
That DIR isn't hardcoded anywhere, so it's really strange to what is happening...?
Sorry, I'm too sick to come up with a solution right now.
|
|
|
09-20-2013, 05:03 PM
|
#29
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
Hmmm.... I'll take the graphics out and put everything in the same folder and upload again tomorrow.
|
|
|
09-21-2013, 06:26 PM
|
#30
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
Okay, here's a version with the images removed by default (unless you want to enable them by graphics = True at top of main file).
It works with the images used or not here... Python 3.3 32bit, standard install of Reaper 4.52 32bit, Windows 7 64bit.
|
|
|
09-21-2013, 07:59 PM
|
#31
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
(BTW, I'm using the latest stable python, sws, and have Reaper 4.51 and windows XP 32bit)
Got this new error, tried loading up the latest reachord.
Sorry to be a pain in the rear, I honestly don't intend to! lol
Can't wait to get to get it working though. Been waiting to see a plug like this in reaper.
|
|
|
09-22-2013, 12:47 AM
|
#32
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Quote:
Originally Posted by fwd0120
(BTW, I'm using the latest stable python, sws, and have Reaper 4.51 and windows XP 32bit)
Got this new error, tried loading up the latest reachord.
Sorry to be a pain in the rear, I honestly don't intend to! lol
Can't wait to get to get it working though. Been waiting to see a plug like this in reaper.
|
I got it working when I edited RetrieveSettings() function in ReaChord_Functions.py:
Code:
def RetrieveSettings(self):
self.msg("RetrieveSettings - enter")
if not RPR_HasExtState(RC.REACHORD, "FirstTime"):
RPR_SetExtState(RC.REACHORD, "FirstTime", "NotFirstTime", True)
else:
for key, val in RC.Settings.items():
RC.Settings[key][0] = str(RPR_GetExtState(RC.REACHORD, str(key)))
RC.Settings[key][1] = int(RPR_GetExtState(RC.REACHORD, str(key)+"1"))
self.msg("Retrieved... "+key+".... "+str(RC.Settings[key][0])+".... "+str(RC.Settings[key][1]))
self.msg("RetrieveSettings - exit")
|
|
|
09-22-2013, 01:13 AM
|
#33
|
Human being with feelings
Join Date: Feb 2011
Posts: 23
|
I've got the script running without any errors but nothing is ever generated on the track. Any suggestions?
|
|
|
09-22-2013, 02:10 AM
|
#34
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
You need to have the MIDI editor open and it writes into the active take in it.
@spk77: nice one, I didn't notice that check through the cloud of sawdust generated by my hacking.
|
|
|
09-22-2013, 02:19 AM
|
#35
|
Human being with feelings
Join Date: Aug 2013
Posts: 1,355
|
Oops, here the version with spk77's fix....
ps. are the graphics still causing problems with graphics=True?
|
|
|
09-22-2013, 02:55 AM
|
#36
|
Human being with feelings
Join Date: Feb 2011
Posts: 23
|
Quote:
Originally Posted by Lazarus
You need to have the MIDI editor open and it writes into the active take in it.
|
I do have the editor open and it will draw the regions but no notes are created. I've made sure that the event filter is disabled also. I think it might be time for a fresh install.
EDIT: I figured it out. The checkboxes in the settings panel were checked but were all "greyed out" except for the Regions checkbox. Working now and thanks for the help.
|
|
|
09-22-2013, 03:00 AM
|
#37
|
Human being with feelings
Join Date: Feb 2006
Location: decepticon mothership in a hidden place inside a mountain
Posts: 3,754
|
Thank you, it looks like a fun extension !
|
|
|
09-22-2013, 09:52 AM
|
#38
|
Human being with feelings
Join Date: Sep 2013
Posts: 137
|
Works great so far.
I checked the images, when I set it to True this attached screenshot will show again. I don't have a /Documents and Settings/, I'm on Windows 7, so it should read /Appdata/Roaming/REAPER/...
Maybe it's due to the hardcoded sys.hexversion?
EDIT:
I played a bit with it, and this seems to fix it. Yes it's hardcoded for Win7/Vista
Code:
#self.resource_path = _getdirectory_.module_path() + '/' #+"/resources/"
self.resource_path = os.environ.get("APPDATA") + '\\REAPER\\Scripts\\ReaChorder\\' #+"\resources\"
So I think we need a OS sniffer?
btw: I actually think it looks cleaner without the images/icons they seem to be a bit misaligned on my system.
-
Last edited by Sasje; 09-22-2013 at 10:29 AM.
|
|
|
09-22-2013, 10:18 AM
|
#39
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
Working!!!! At least It seems so. I'll follow up this post.
|
|
|
09-22-2013, 10:33 AM
|
#40
|
Human being with feelings
Join Date: Aug 2011
Posts: 296
|
Okay, after playing around with it for a few minutes:
I really like it! Great potential. It did crash (incl. Reaper) after 5 minutes, but I know that happens at such an early stage.
If I were to have any input, here are some features I would find useful.
It would be great to write-in your own progressions to tweak them. Also if it had a legend (more like a library of basic types) for chords and inversions. Chordpulse (there is a demo) does this very well. Anyway, that would be a huge thing for this.
Also, it would be great to have a little more control of the structure. Be able to set the length of the verse, chorus, etc..
Those would be the things I might look into after the stability gets worked out.
I can see this project has a bright future! Keep it up!!!
|
|
|
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 11:30 AM.
|