Troubleshooting

Need Help to Save and Load Presets of Multiple Objects

Started by tater01 on .

Sign in or create an account to join the conversation.

41 posts

Topic starter
Ok, so I'm trying to build a drum sequencer and be able to store and load presets in a set of pads. I've started with the example given with the Lemur editor where there are two sets of 16 pads, one named store and the other named load. And the pads store and load presets of a multislider. I am using the same example but I want it to control several different stepswitches. So I can store and load presets of the stepswitches. So there are stepswitches named kick, snare, ride, etc. The stepswitches are each 16 buttons long.

So, first there is a container, named container. At the container level I have two expressions and a script:

presets=
presets_state=
init()

This is the script in the init is: if (sizeof(presets_state)<16) presets_state = stretch(0,16);

Then I copied the pads from the preset multislider example, store and load. Both 16 pads each.

The store pad has a script: action(). The script is executed on expression of x and contains this code:
decl index;
decl num = sizeof(x);
for (index=0; index<num; index++)
{if (x[index]){presets_state[index] = 1;presets[index*16] = {Kick.x};}}

The load pad has a script: action(). The script is executed on expression of x and contains this code:
decl index = firstof(x);
if (index>=sizeof(x)) return;
decl i;
for (i=0; i<16; i++)
{Kick.x = presets[index*16+i];}

So, this works for one stepswitch "kick." I need help getting it to control more than one of the stepswitches, Snare, ride, etc. Can anyone help me change these scripts to control more than one stepswitch at a time?

Also, just as an extra, not necessary. If anyone is smart enough to make it play through the presets. Like you can save 16 presets on the pads. It would be cool if when you hit play on the sequencer, it plays through all the presets sequentially!
The summary is to make an array of the switch names, then loop through that array and use findobject() to get each object, then use getexpression()/setexpression() to get and set values as needed.
There's likely more clever ways to use the objects and container directly to get all the names, but I don't have a Lemur or the code you referred to here with me.

I'll try to gen up some code this weekend to show it in detail.
Thanks for your help oldgearguy. I really appreciate it, as I just have very basic programming skills. So thank you!
Here's is the lemur example of how to make presets of a multislider:
Lemur Presets Example.jzml

Here is what I want it to do but with more than one stepswitch. I can get it to work for the first stepswitch "Kick"
Stepswitch Presets.jzml

That seems like an awful lot of code in your example, whew that looks scary compared to what liine did with the multislider!

Thanks again!

**Edit**
I looked yours over, and it's actually kinda of awesome. Instead of having the pads to save presets, you made dedicated save and load buttons! Very cool. I will check it out and post back. Thanks!
I'll pull up what you attached when I have some time later today with the Lemur in front of me.
It's more challenging reading the raw .jzml file and trying to understand the intent - with the Lemur up, it's easier to see what you wanted to have happen.

The main idea I wanted to get across (whether you use separate pads or a single button) is that you can find objects (like pads or step switches) and then adjust their values. That's the findobject()/getexpression()/setexpression() stuff.
Ok, couldn't wait! First off, you are my f-ing hero! Thank you for being so smart and such a kind person to help out complete strangers!!! You are the best!
You're presets work awesome! Thank you very much. I think I semi understand about get object, setexpression stuff. Kinda lose me when you declare so many variables though.
So, again thank you! It works great! I am going to bug you for some more favors though. Since you are so smart and seem up to the challenge!
My new obstacle is that I would like to be able to make it 64 presets but use only the 4x4 pads, just use 4 sets of 4x4 pads to make a total of 64 presets. I kinda set it up using your preset buttons and made four sets of save/load pads. But, the extra sets of pads only mirror the first 16. So how do I make it 64 presets? Change the index to 64? Here is my page I am working on:
Examples.jzml

Sorry for the small resolution, I have an old Galaxy Tab 2!

Also, if you don't mind. I put in a copy and paste pad and was hoping you could make them work for me too! Sorry for being so needy! I'm not that great a programmer, very noob!

Lastly, I know this is probably hard to script so I don't expect you to do it for me. I know it probably takes some time to script. But if you can, make it so that when you hit play it plays through all the presets sequentially. So I could basically program a whole song. Different parts to different presets, then play through them, A1,A2,A3, ....A16,B1,B2,B3,....B16,etc.

Thank you in advance for any and all of your help. You are a great person and very kind to script those buttons for me!

Thanks!!!
I'll take a look when I have some time this weekend.

A couple things -
In the land of Lemur, 256 is a magic number. Strings, arrays, sysex messages, etc cannot be longer than 256. That's why I had each drum part save it's own data. 16 steps x 16 presets = 256 things being stored. If you want 64 presets, you have to jump through additional hoops to make it happen.

I haven't used the StepSwitch objects in a real application yet. I don't know how tight the timing will be switching between patterns while it's running. Probably at lower BPMs it'll be fine, but again - that's something to experiment with and see. Coding it up to efficiently switch will help, but there is a limit as to how quickly the Lemur app can process the information.

Also, I will document the code with comments to hopefully provide more explanation as to why some things were done a certain way. The goal is for you to understand what is happening and give you the ability to extend/modify it as needed.

If you don't really need a separate container for the pads I might delete that and move the contents up into the main container. Nesting objects like that, especially with the same name, can make it confusing to read through.


Finally - I have been fooling around with an updated version that allows you to dynamically set the number of steps for each drum row and I added a Start/Stop button and BPM knob. I am attaching it just to give you things to think about. The row length is not saved with the preset in this version. Once you start playing with it, more questions come up like if you have variable length rows, when do you switch to the next preset - after 16 steps always, follow the kick, or something else? There's the issues of starting from a preset other than 0 and how do you set the marker to indicate the last preset to play before looping back to the beginning? What do you do with empty presets - skip them or play them? (you might want a bar of rests)

Basically, you're (re)designing a step sequencer, so it can get as complicated as you want.

For your example, I might want to get everything else working (playing through each saved preset, copy/paste, etc) then figure out the expansion to 64 presets.

StepSwitchesPlus.jzml
Thanks again for all your help oldgearguy. Really appreciate you giving me the gift of knowledge. Ok, so playing through the presets would be very cool if you could do that. I thought about it and I think there should be a button to change play mode. Just like an on/off. On it plays only the current preset repeated. Off it plays all the presets chronologically. Then when you hit pause or stop, I would rather have a play/pause button for space, it stops or pauses on the current preset. I totally understand if you don't want to code that for me. Playing through the presets is not crucial. It would just make workflow better. I've used the stepswitches and they do make a pretty good drum seq. As far as switching the patterns/presets on the fly, not sure how good that would work. But as is, I've used it to record drum beats to the pc and it works good. So, it is totally possible to just make the sequences and record the midi to pc one by one. But having the ability to make it play through the presets would make it so I could send/record the midi of the whole song at once. So Its not totally important if you don't feel like coding it for me. No biggie. Would just be kinda bad ass!!!

Same for the 64 presets, it's not crucial. I just feel like I'm using you as I would have no idea how to figure it out and haven't really found anyone else' examples of this on the internet to learn from. So if you feel like I'm using you, I understand totally. 16 presets is probably more than enough to make little songs, I was just trying to make this as cool as I could (you could).

Copy and paste does seem kind of important though. To just copy a song part/seq to a different preset for song repeats. But, if you don't want to code the play through presets option. Then this really isn't very important either. If I can only play/send/record one sequence at a time to the pc, then I can just copy and paste the parts in my DAW. There would not really be a need to copy and paste in Lemur then.

I posted in the last post my jzml of what I've got so far. I think I "might" be able to get copy and paste working as there is examples of that on the net.
Again I thank you for all your help, I don't deserve it. Thanks!
Here is a version that chains the saved presets. Look atthe chain script in the transport section. I also modified the start/reset scripts. Note that the chain() script is tied to clock 1. I see you have some code that uses a variable for the clock number, but there's no easy way to tie that to an on clock script, so if you ever change the clock number used, you'll have to change the chain() script.

Still just focusing on "A" block of 16 since a lot more code needs to be added to get B/C/D working as well.

ExamplesNew.jzml
First things first, you are bad ass!
Infinite thanks!
Ok, so that is really cool how you made it play through the presets. Very cool! I thought about it some more and copy and paste is not needed. You can already copy and paste from the store and load pads. Load pad 3, store it to pad 2. etc. But, there is an issue with the play through presets. I figured since I already used you this much, I might as well go for broke! When playing through the presets, only the presets on bank A play. It never goes to bank B. So, bank B,C, and D are pretty much useless since the play/step cursor won't go to them.
So, if you feel like making it play through all 64 presets (all the Banks), that is up to you! If not, I think I could just figure out how to delete the copy and paste buttons, and also delete the B,C, and D banks. And it should work fine and be more than sufficient.

I thank you for all your coding skills! Really appreciate it!

***edit***
I was excited and didn't read all your post where you said you still needed to get B,C, and D working! Sorry for bugging!
Also, what DAW do you use? You are making this stepsequencer as part of a giant layout for Reaper. Maybe if you like Reaper I can upload you the whole template and/or maybe we can sell it for like $2 on the Reaper forum? Just an idea!
Couple things before I talk about the update.

First - I don't actually really use a DAW. Sequencing done via hardware (Cirklon and Notron), multi-track recording (when I do) is via Alesis HD24XR. I run Tracktion on a Mac Mini as a 2 track audio recording tool only.
Next - is the current layout of this sequencer template all the space you have available? It's really tight and there's not a whole lot of room to fit some 'nice to haves'.
Finally - selling the templates is a hard thing no matter the price. Since there's no way to 'compile' it or apply any sort of copy protection, anyone is free to modify the source and distribute it however they want. I chose to put a note in my help/configuration screen for my templates asking for donations if they feel it's been useful. So far, I've received exactly $0.00 in donations, so it makes it difficult to stir up motivation to create new stuff or add significant features to the existing ones.

Now - onto this thing. Attached is a version that steps through all 64 presets in the 4 banks. It's a bit rough. I tested it briefly to verify it moves through each bank and wraps around back to preset 0 of Bank A. However, I don't guarantee that it's been fully tested and debugged. I did want you to play with it because I think there's a couple things you really need in there.

Right now, it's set to always start from preset 0 in Bank A and play through preset 15 in Bank D. That's fine in some cases, but I think it would be nice to be able to set up arbitrary start and end loop points so you could work on sections at a time. The Start/Stop and reset buttons would work "in the loop" that is set by the 2 points.

Speaking of reset - I uncovered the reset button since copy/paste is gone. Ideally, the reset function would be either a pop-up dialog (tricky to do in Lemur, but I've done it), or a drop-down menu giving you the choice of clearing 'nothing', 'current pattern', 'bank A/B/C/D', or 'everything'. Of course you can clear the current pattern by selecting a blank preset to load, but it would be cleaner having the clear/reset all together. Careful - this reset button currently clears out all presets in all banks, so use with caution.

Code is still uncommented, but you can see that I chose not to duplicate the Save/Load sections multiple times but rather to extend the storage arrays in each sequence and then use the bank number to create the unique names. Cleaning up the code to remove some hardcoded values and make it easier to set arbitrary start/loop points and adding the reset options should get you 99% towards a completed tool that can be fairly useful.

ExamplesBanks.jzml
Very nice, you are awesome. I'm so glad I ran into you and you have no problems helping out noobs like me! I do have a college degree for computers, but not programming. Networking was my degree. I know very little about programming and basically just copied everyone else' stuff on the net. I wrote some programs on my old TI-81 calculator! LOL! And we did some basic cpu commands from a small Motorola processor to print and use telnet in college. That is the extent of my programming skill. So thanks again oldgearguy. It would have taken me a really long time to figure this out and it is the last piece of my layout I am working on! Thanks for helping me finish it. Yes that is all the space I have on old Galaxy Tab 2! If you want to make some room we could make the offset and swing in a hidden container? Or just make their sliders smaller? Or change them to smaller +/- buttons? Let me know, I can definitely do that bit by myself (change size of offset/swing or make them hidden). If you want to change the layout however you want, I am totally ok with that and trust your judgement! Would love to see what you mean when you say it needs some must haves!


Thanks again!

P.S. Where can I find some of your other layouts you've designed? I would love to check them out!
tater01 wrote:Very nice, you are awesome. I'm so glad I ran into you and you have no problems helping out noobs like me! I do have a college degree for computers, but not programming. Networking was my degree. I know very little about programming and basically just copied everyone else' stuff on the net. I wrote some programs on my old TI-81 calculator! LOL! And we did some basic cpu commands from a small Motorola processor to print and use telnet in college. That is the extent of my programming skill. So thanks again oldgearguy. It would have taken me a really long time to figure this out and it is the last piece of my layout I am working on! Thanks for helping me finish it. Yes that is all the space I have on old Galaxy Tab 2! If you want to make some room we could make the offset and swing in a hidden container? Or just make their sliders smaller? Or change them to smaller +/- buttons? Let me know, I can definitely do that bit by myself (change size of offset/swing or make them hidden). If you want to change the layout however you want, I am totally ok with that and trust your judgement! Would love to see what you mean when you say it needs some must haves!


Thanks again!

P.S. Where can I find some of your other layouts you've designed? I would love to check them out!
You're welcome. I write code all day, so normally outside work, I prefer messing around with actual hardware, but sometimes I need some custom software, so the Lemur platform seemed like a reasonable compromise.

If that's the space you have, then that's what we'll use. I can make Reset to be a menu (and change the name to Clear) which temporarily drops down over the pads to allow you to select something to clear.
Once you play with this for a while, finding space for a way to set start and end loop points (and to label/mark them in some way so you remember) would be a good thing, but if there's no space, then looping across all 64 is what it will do. I've created pop-up sliders that might be useful in the constrained space... I'll take a look at that.

I promised commented code and I'll certainly comment my sections and try to work out what the other sections do and add comments there as well. The combination of being able to see and modify stuff quickly combined with comments should help give you a better understanding of what's going on under the hood.


I created a template for the Roland RSS-10 and for the Yamaha TX-802. They're up in the user library section of the site and may have been posted in the Projects Section of the forum.
Hello again! Ok, I have a lil update. Made room for more buttons by making the swing and offset sliders hidden. But I messed up the offset slider in the process! I had to move it outside the transport container and now i can't figure out how to get the offset slider update script to work. They are hidden on the template I'm uploading now. Have to open Lemur and hit the buttons to view them. So with all your hard work can you fix the offset slider update script for me? How do you reference the clock in another container? Also, still can't wait to see what must haves you were talking about?

NewExamples.jzml

Thanks again!