On Samstag, 28. August 2021 18:29:21 CEST Kolja Koch wrote: > > Could you please elaborate, i.e. examples of where you would see > > > > > issues by > > > just supplying regex patterns from the command line? > > Sure! > > I don't know in which order the attributes might be. > The regex you implemented uses a fixed order: > > '(Name1)(Name2)(Velocity)(Note_Nr)(Note_Name)' > > Take the following filename: > > 'Name - 64 - Bb3 - articulation.wav' > > A regex-pattern could look like this: > > '(.*) - (\d*) - (.*) - (.*).wav' > > But how would the code know, that '64' is meant to be the velocity? > Or that 'Bb3' is a NoteName and 'articulation' is Name2? > > One would also somehow have to enter the correct order, like > > '(Name1)(Velocity)(Note_Name)(Name2)', > > or am I missing something?
Yes, but that's not how I would have exposed it to the command line interface anyway. See below of what I had in mind ... > By using format specifiers, like in printf, you would simply enter: > > '%n - %v - %a - %m.wav' > (where %n = Name1, %v = velocity, %a = Note_Name, %m = Name2) I understand that you like the printf specifier format, as it looks more simple on first view. But keep in mind both on your easy tag example and printf the actual purpose deals with the other way around: e.g. in the easy tag example the individual components where already gathered (extracted from the MP3 files), and the actual intention was to assemble one string from those individual components, which is really just a string concatenation operation. In case of wav2gig however we need the other way around, i.e. you have one string (file name incl. path) and you need to extract the individual components from that string. Which is a much more delicate task due to the large freedom such kind of input strings can have. So your proposal would be something like this: wav2gig --pattern '%a - %b - %c - %d.wav' you would not be buying much with that compared to e.g.: wav2gig -a '(.*) - \d* - .* - .*.wav" \ -b '.* - (\d*) - .* - .*.wav" \ -c '.* - \d* - (.*) - .*.wav" \ -d '.* - \d* - .* - (.*).wav" which still could be simplified by the user (the patterns I mean), so that's not my point here. The main issue with your solution is that you very easily run into limitations of what it could do. For instance say for some wav files you want the note number to be extracted from a path, and only if that path is not available then extract it from the file name. There is nothing to be invented on our side; regex already supports this e.g. by using the alternate operator: pattern1|pattern2|pattern3 where priority is from left to right. Or you wanted something inside the string to be optional. Likewise, the user would just prepend a question mark. All these things are standardized, well documented, and nothing we have to take care about ourselves. CU Christian _______________________________________________ Linuxsampler-devel mailing list Linuxsampler-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxsampler-devel