bobgonzalez / spEdit404

spEdit is a tool for modifying and creating binary pattern files for the Roland SP-404SX.
GNU General Public License v3.0
18 stars 3 forks source link

reading / modifying patterns #7

Open rvosa opened 3 years ago

rvosa commented 3 years ago

Hi!

thanks for taking the time to write this tool. I'd really love for it to work but I'm running into some problems. I have an SP404sx for which I want to fix some quantization glitches in patterns I recorded from midi in.

I try to read a pattern (bank B, pad 3). The software seems to think this translates to ./import/PTN0000f.BIN but I'm puzzled why it should think that. Do I need to tell it the root of the SD card? And wouldn't the pattern B3 actually be $ROOT/SP-404SX/ROLAND/SP-404SX/PT/PTN00015.BIN?

Ok, so then I try to fool it into reading the pattern anyway by copying the BIN file to the location the software expects (so, ./import/PTN0000f.BIN under the current working directory), but now it chokes on the pattern data:

$ python3 spEdit.py 
enter length of pattern or enter 'r' to load pattern >r
enter bank > B
enter pad > 3
Traceback (most recent call last):
  File "spEdit.py", line 98, in <module>
    pattern = read_pattern(bank, pad)
  File "/Users/rutger.vos/Documents/local-projects/spEdit404/binary_utilities.py", line 107, in read_pattern
    pattern.add_note(Note(bank=bank, pad=pad, velocity=velocity, length=length_ticks, start_tick=current_time))
  File "/Users/rutger.vos/Documents/local-projects/spEdit404/pattern.py", line 44, in add_note
    raise ValueError('note can not be added to pattern because it overlaps on all tracks')
ValueError: note can not be added to pattern because it overlaps on all tracks

I must be doing something obviously wrong but I can't figure it out. Would you mind pointing me in the right direction? Thanks!

bobgonzalez commented 3 years ago

Hey Rvosa, Thanks for giving the program a go and leaving a detailed issue! The filename bug you found is a simple fix looks hexadecimal representation (0x0f=15). made an issue sould be resolved very soon(https://github.com/bobgonzalez/spEdit404/issues/8). The ./import/ path was more of a design decision. My thought was a local import / export folder to separate reading / writing files. I would hate to read and write to the card directly and risk corrupting someone's work. Lastly the value error you are seeing was an effort to prevent users from creating a pattern with the program that exceeded the SP404SX's ability to play 12 mono samples simultaneously. sounds like you may be getting that error incorrectly though if you created the pattern on the SP404SX. The max number of tracks (12) is specified on line 8 in the pattern.py file you can increase this to pass the check. However I would be very interested in taking a look at the pattern file to see what exactly is occurring. If you don't mind uploading it or sending it to me privately I would really appreciate it.

rvosa commented 3 years ago

Hi Bob,

thanks for getting back to me on this! Yeah, I can see not wanting to try to read/write directly to the SD card so that's really not a bother at all. As for the value error I'm getting: I'm very curious what is actually being recorded from the midi in and how that is represented in the binary patterns.

I've been doing some coding myself to try to reverse engineer what's going on and it seems to be logging a whole bunch of note events that have 0 velocity and 0 length. I don't quite understand whether those function as ticks (because the maximum length between events is 255, i.e. 2^8?) or whether they are glitches or something else?

It might be that what I've been doing is voiding the warranty ;-) because I've been sequencing the SP through its midi in using Ableton and Logic Pro, and then record those sequences. The approach has been to set the BPMs in the sequencer and the SP to the same value, hit record pattern on the SP, and then hit play on the sequencer at just the right moment after the countdown. This goes well enough for a few dozen bars until the clock drift in the two parties (sequencer and SP) has progressed so much I can no longer fix it with quantization.

But maybe those sequencers are sending in more data that the SP is somehow writing?

Anyway, here's the pattern file I've been trying to decode.

rvosa commented 3 years ago

BTW so the larger ambition that I have (whether you, I, or we together write it) is to be able to convert between midi files and SP patterns. It seems to me that this is at least theoretically possible and it would mean being able to compose or edit sequences in proper DAWs, including things such as groove/swing quantization and velocity accents and stuff.

I'm not sure if you are aware of this work here, which might be relevant: https://github.com/TylerOderkirk/ptn2midi/blob/master/ptn2midi.py