Hi Mangus ,can you please help me to modify the script that loads different patches “ peak new patches “ please !
The original script pics patches from the folder called “ All “ ( picture A,B ) and i guess it taking patches from the subfolder By category ( picture C ) . What I want it to change the factory folder, with one of my own ( picture D, E ) . Let say I have that folder full with patches containing all the subcategory patches , but all in one folder. So instead of looking in the subcategory folders, I want Microtonic to look in only One folder that contain all of the categories, my own folder G01. The way I did it it's not working because Microtonic it's trying to look in the subcategory folders and i got error [-43] and it dosen't load anything.
The second thing is that when no matches were found Microtonic doesn't do anything (see picture F). Well in my folder, I have patches that doesn't contain the subcategory prefix and I want this line to be changed like this : When no prefix matches found, make Microtonic choose a Random patch that doesn't contain the prefix ! With other words, when no prefix found choose random patches with no prefix. For example : if the patch I tried to change it's called Focus_02 (this it a file with no prefix) let Microtonic to chose patches with no prefix.
Can you Please modify the original script with this changes ? Thank you
Hey, a script hacker, I like it!
It actually looks like it is searching in the "All" folder only and switching it to G01 should work for you.
I'll try to break down the script and explain the different parts of it. I didn't write it, but hopefully, I understand it correctly. 😊
if (!exists(@::PickNewPatches.inited)) {
print('Building ::PickNewPatches');
dir(drumDir, >{
if (wildmatch($0, '*.mtdrum'))
append(@::PickNewPatches.drums, $0);
if (wildmatch($0, '??~~ {??~~~~~~} ?*.mtdrum', @category))
append(@::PickNewPatches.drumsByCategory[upper(category)], $0);
});
::PickNewPatches.inited = true;
};
This part initializes the script by listing all files in the drumDir
folder and then populating two arrays.
The PickNewPatches.drums
array contains the name of each patch.
The wildmatch($0, '??~~ {??~~~~~~} ?*.mtdrum', @category)
line is where the category "magic" happens. With our patch naming conventions like KM Clap Rombi.mtdrum
it skips the first 2-4 characters and then captures the next 2-8 characters into the category
variable. So in this case the category will be Clap
. You can read more about how wildmatch works here.
getElement('preset', @p);
pickedCount = 0;
for (ch = 1; ch <= CHANNEL_COUNT; ++ch) {
if (p.Mute[ch] < 0.5) {
dp = @p.drumPatches[ch];
if (pick('??~~ {??~~~~~~} ?*') || pick('{??~~~~~~} ?*'))
++pickedCount;
}
};
Here it gets the current preset and loops through all drum channels. For each channel that is not muted, it tries to pick an alternative drum channel using the pick
function. Please note here that it calls pick
twice, because it does support if you have creator prefix in your current drum patch names or not. Like FL SD Fat
or SD Snappy
.
pick => {
if (wildmatch([dp].name, $0, @category)
&& exists(@[a = @::PickNewPatches.drumsByCategory[upper(category)]].n)) {
Here you can see that the pick
function uses the input variable $0
as the match pattern to figure out the category of your currently loaded patch. It assigns the category array to a
and checks that it exists.
i = randomInt() % [a].n;
path = drumDir # [a][i];
s = load(path);
[a].n
here will be the length of the category array, so we use random to pick one and then load it in.
origOutput = [dp].Output;
origChoke = [dp].Choke;
unmarshal('drumPatch', s, @[dp]);
[dp].name = chop([a][i], 7);
[dp].path = path;
[dp].Output = origOutput;
[dp].Choke = origChoke;
Copies the current Output and Choke settings and applies them to the newly loaded patch.
So if I understand you correctly, what you want to do is pick any random drum if you cannot match a category. You could do that by modifying the pick function, but the easiest way would be to just copy it. Something like this:
pickRandom => {
a = @::PickNewPatches.drums;
i = randomInt() % [a].n;
path = drumDir # [a][i];
s = load(path);
assert(> isMarshaledFormat('drumPatch', s));
origOutput = [dp].Output;
origChoke = [dp].Choke;
unmarshal('drumPatch', s, @[dp]);
[dp].name = chop([a][i], 7);
[dp].path = path;
[dp].Output = origOutput;
[dp].Choke = origChoke;
( true )
};
and then add it to the picking process like
if (pick('??~~ {??~~~~~~} ?*') || pick('{??~~~~~~} ?*') || pickRandom())
++pickedCount;
Disclaimer, I have not tested it, so I might have made a mistake somewhere. 😁
Ah, I see now that you want it to only match patterns with no prefix if there is no prefix in the current patch? That makes it a bit harder, but it would go something like identifying the drum patches without a category in the init script and adding it to a non-category, like.
if (wildmatch($0, '??~~ {??~~~~~~} ?*.mtdrum', @category)) {
append(@::PickNewPatches.drumsByCategory[upper(category)], $0);
} else {
append(@::PickNewPatches.drumsByCategory["unknown"], $0);
}
and then randomize from the ::PickNewPatches.drumsByCategory["unknown"]
category only when there is no category detected in the current patch name.
Hi thank you for this complex answer but first let me tell you something :
Now, take it one by one :
1 it not working and i got this error :
it this script
Pick New Patches3.pika(2.79kB, 519 downloads)
I don't know that 'n' letter came from :)))
The second script that they made it working, but it's too random and I don't think it follows the drum category protocol, which is kind of important I guess :))) I mean I want him to change patches randomly but when he find the prefix I want him to change drum patches with the same prefix. it this script
And again if the patcher are from a different folder , it got the Not founding patches error .
Pick New Patches4.pika(2.38kB, 531 downloads)
At the end I will say again what I'm trying to achieve:
a script that understand first two letters as a category ( because of the export script language),
a script that understand patches with no category,
a script that randomly choose patches with the same category and randomly choose patches with no category,
a script that understand the folder that has been give it to him from where to choose patches,
I hope you will find my answer funny and interesting... :))))) thank you for your help
UPDATE:
I realise that when I'm changing patches with the original script with folder 'All', I have to quit and restart Microtonic to be able to use the second script which contains patches in the 'G01' folder. The script understand the folder that exists in the script you trying to use, And if you change the script that has different folder, he needs to be restarted, I don't know why . In this test I was using the Original script 'Pick New Patches' with folder 'All' and my new created the script called 'Pick New Patches4.pika' with folder 'G01'
You need to be signed in to post a reply