Welcome to %s forums

BrainModular Users Forum

Login Register

Text extraction

I need help on a Patch
Post Reply
ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 07 Sep 2016, 13:02

Hello,
I ve got audio files with a name starting by a number (tempo), then a space, then the rest of the name. I'd like to "extract" this number which can besides have 2 or 3 signs. ( from 10 to 300..). Is there some kind of script that could cut a comma text file, or "read" just a part of it ?

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 07 Sep 2016, 17:42

once your script has discard non-numerical characters, you will be left with a string that represent a number.

then use SetValue(Output,round(StrToFloat(GetStringValue(input))));
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 07 Sep 2016, 18:25

Sorry, but i don't understand how i could in the first step discard any non-numerical text.
Is there a subpatch or script for that ?

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 07 Sep 2016, 20:54

yes, I meant in your script.

the incoming string is like an array of characters

first you get the size of the string
then you use a FOR loop from 0 to size-1
inside this FOR loop, you check each character, if it's a numerical char (ie between '0' and '9') append it in another empty string
then convert the string to a int

I'm too busy right now to code it, but I reckon that it could be useful in the futur to have a module that does just that.
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 07 Sep 2016, 21:28

update :

File uploaded: http://www.sensomusic.com/forums/upload ... 0value.pat

I found a workaround, just always use 3 digits in the begining of the filename ie : 035 very slow song.wav

sometime ago I made some attempts at using metadata files, here's the idea :
say you have a wave file called groovy.wav
you load it into a special patch that will play the file, get its tempo and write, in the same directory, another file, actually a textfile with the value of the tempo writen into it. this file will be automatically named groovy.tpo
(I actually made something like this for markers and called the file groovy.mkr)



I definitly need to search my archive for tis patch...done :
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 07 Sep 2016, 22:00

http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 08 Sep 2016, 20:18

Ok, thanks for all your answers.
I've tried a lot of things, ..and it seems that nothing works.
I can't open your first patch, and the second one is freezed.
I've tried to use strings to integer, but hh says it's not a valid float number..
Comma text to array gives nothing..or rather an ununderstanding array, which besides does'nt change when i'm changing from file
.get comma text element index,.nothing.
I'm wondering if i could have a problem with my version (1.02.011d) to read some scripts
manipulating text.
Is that kind of issue known ?

ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 08 Sep 2016, 20:24

And by the way, i think there's a misunderstanding : i'm not scripting myself anything.
I'm just a little patch builder, and can't even imagine how you guys could talk to the machine with words..i've tried, but ..too complicated.
So, that's why a part of your answer was chinese for me.

User avatar
oli_lab
Member
Posts: 1261
Location: Brittany, France
Contact:

Unread post by oli_lab » 08 Sep 2016, 20:32

if there is non-numerical characters in the string, you'll get an error
for the first patch : you have to change the path of the file lister according to your file structure and make sure all your files have 3 digit at the begining of their name.

for the second one, I must admit it is quite farfetched !
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 09 Sep 2016, 12:07

Ok, to be precise, only your metadatas patch can open. I've changed the path in the filelister as indicated, but hh consider all directory i've tried as invalid , and still keep on trying to load your own files. But anyway,..
My patch is close to the end and i'd like to finish it.
The last step is to make hh able to read the tempo indicated at the beginning of the selected file..but of course, and that's the probleme, all my file's name are a mix of number and letters, but always in the same order (tempo- then any name). The comma text to array could be a solution . But i can't figure out how to use it, and any other solution is welcome.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 09 Sep 2016, 18:11

I was too lasy to script as well^^ but here is a quite simple patch solution.

Image

Consider text in usine is Array of char = array of numbers that represents ascii char value. the ascci nuber for space is 32,
so we look if it's in there (via A=32 that will return 1 if there 0 otherwise for each element of the array)
and for the position of it (via max array position of this result, the array being filled with 0 and 1 only where space appears, the max return pos will be first space pos in the array)
then we extract the sub part of global array from start till the position of first space we got from previously,
all we have to do finally is convert this string to integer and we get numerical value of tempo.

ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 09 Sep 2016, 22:11

thanks a lot. no use of any script, this smart little patch do perfectly the job. i didn't thought we could directly wire the out of a text in an array..i was trying with the script comma text to array, which doesn't work as i've said if there is letters in the text. so i'm a bit confused. does comma text means only the numerical part of a text ? otherwise, what the use of this script ?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 09 Sep 2016, 22:26

Comma text in usine means a string list of words separated by a comma ','
for exemple when you type: ""my file 1" ," my file 2"" ect, modules such as listbox or combobox know how they have to split 'elements' of a single big sentence to a list using found commas as separator markers, to get as a displayed result:

my file 1
my file 2
...

i don't know this script but i suppose it converts a commatext made of strings representing numbers to array of numbers, so it internally has a string to integer command that won't like non numeric characters but have to check.

edit: so found and checked the script and it's what it does, pick the comma text list, split to element, and tries to convert to value, so in you case it gets for exemple an item like
: 89 drumloop. it's not able to convert this whole thing string to a number.

if it had such commatext as input for exemple: "89,92,120,150" then it would work and output a numeric then array in the form of
89
92
120
150

ringmodulator
Member
Posts: 35
Contact:

Unread post by ringmodulator » 10 Sep 2016, 17:00

Ok, thanks for your explanations. This appears much more clear now. And for the ASCII language, i'll try to get some translation tab, it may be usefull.

Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests