Skip to content

Commit 05e4cf4

Browse files
committed
* Logging: Improved logging output of missing samples. Added ConvertWithMoss version number and source/destination-format to log.
* Sample search: Added support for finding samples with wrong upper/lower case in the extension of the samples name. * Improved processing cancellation. * Kontakt * Fixed: File lists of version 4.2.4 and 5.0.x were not always read correctly.
1 parent 4cd15d9 commit 05e4cf4

14 files changed

Lines changed: 310 additions & 150 deletions

File tree

documentation/CHANGELOG.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Changes
22

3-
## 14.0.1 (unreleased)
3+
## 14.1.0
44

5-
* Logging: Improved logging output of missing samples. Added ConvertWithMoss version number to log.
5+
* Logging: Improved logging output of missing samples. Added ConvertWithMoss version number and source/destination-format to log.
6+
* Sample search: Added support for finding samples with wrong upper/lower case in the extension of the samples name.
7+
* Improved processing cancellation.
68
* DecentSampler
7-
* New: The value for the amplitude velocity sensitivity is now initialised in the template via the new variable %ENV_VELOCITY_SENSITIVITY%.
9+
* New: The value for the amplitude velocity sensitivity is now initialized in the template via the new variable %ENV_VELOCITY_SENSITIVITY%.
810
* New: The delay Mix default value is now set to zero in the template.
911
* Kontakt
1012
* Fixed: Reading of Soundinfo could fail in rare cases with file version 4.2.
13+
* Fixed: File lists of version 4.2.4 and 5.0.x were not always read correctly.
1114
* Yamaha YSFC
12-
* Fixed: Montage files were not written correctly
15+
* Fixed: Montage files were not written correctly.
1316

1417
## 14.0.0
1518

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>de.mossgrabers</groupId>
77
<artifactId>convertwithmoss</artifactId>
8-
<version>14.0.0</version>
8+
<version>14.1.0</version>
99
<packaging>jar</packaging>
1010
<name>ConvertWithMoss</name>
1111
<organization>

src/main/java/de/mossgrabers/convertwithmoss/core/ConverterBackend.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import de.mossgrabers.convertwithmoss.format.music1010.Music1010Detector;
4141
import de.mossgrabers.convertwithmoss.format.ni.kontakt.KontaktCreator;
4242
import de.mossgrabers.convertwithmoss.format.ni.kontakt.KontaktDetector;
43-
import de.mossgrabers.convertwithmoss.format.ni.maschine.MaschineDetector;
4443
import de.mossgrabers.convertwithmoss.format.samplefile.SampleFileDetector;
4544
import de.mossgrabers.convertwithmoss.format.sf2.Sf2Creator;
4645
import de.mossgrabers.convertwithmoss.format.sf2.Sf2Detector;
@@ -105,7 +104,7 @@ public ConverterBackend (final INotifier notifier)
105104
new KontaktDetector (notifier),
106105
new KMPDetector (notifier),
107106
new KorgmultisampleDetector (notifier),
108-
new MaschineDetector (notifier),
107+
// new MaschineDetector (notifier),
109108
new EXS24Detector (notifier),
110109
new SxtDetector (notifier),
111110
new SampleFileDetector (notifier),
@@ -192,7 +191,7 @@ public void detect (final IDetector<?> detector, final ICreator<?> creator, fina
192191
this.collectedPerformanceSources.clear ();
193192

194193
this.notifier.log ("TITLE");
195-
this.notifier.log ("IDS_NOTIFY_DETECTING");
194+
this.notifier.log ("IDS_NOTIFY_DETECTING", detector.getName (), creator.getName ());
196195
this.creator.clearCancelled ();
197196
this.detector.detect (sourceFolder, new MultisampleSourceConsumer (), new PerformanceSourceConsumer (), detectPerformances);
198197
}
@@ -242,6 +241,9 @@ else if (!this.collectedPerformanceSources.isEmpty ())
242241

243242
private void acceptMultisample (final IMultisampleSource multisampleSource)
244243
{
244+
if (this.detector.isCancelled ())
245+
return;
246+
245247
ensureSafeSampleFileNames (multisampleSource);
246248
this.applyRenaming (multisampleSource);
247249
this.applyDefaultEnvelope (multisampleSource);
@@ -280,6 +282,9 @@ private void acceptMultisample (final IMultisampleSource multisampleSource)
280282

281283
private void acceptPerformance (final IPerformanceSource performanceSource)
282284
{
285+
if (this.detector.isCancelled ())
286+
return;
287+
283288
final List<IInstrumentSource> instrumentSources = performanceSource.getInstruments ();
284289
if (instrumentSources.isEmpty ())
285290
return;

src/main/java/de/mossgrabers/convertwithmoss/core/ICoreTask.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,12 @@ public interface ICoreTask<T extends ICoreTaskSettings>
5050
* Cancel the task.
5151
*/
5252
void cancel ();
53+
54+
55+
/**
56+
* Has the task been cancelled?
57+
*
58+
* @return True if cancelled
59+
*/
60+
boolean isCancelled ();
5361
}

src/main/java/de/mossgrabers/convertwithmoss/core/creator/AbstractCreator.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.util.List;
1717
import java.util.Locale;
1818
import java.util.Optional;
19+
import java.util.concurrent.atomic.AtomicBoolean;
1920
import java.util.zip.CRC32;
2021
import java.util.zip.ZipEntry;
2122
import java.util.zip.ZipOutputStream;
@@ -59,7 +60,7 @@ public abstract class AbstractCreator<T extends ICoreTaskSettings> extends Abstr
5960
protected static final String IDS_NOTIFY_ERR_MISSING_SAMPLE_DATA = "IDS_NOTIFY_ERR_MISSING_SAMPLE_DATA";
6061
protected static final String FORWARD_SLASH = "/";
6162

62-
protected boolean isCancelled = false;
63+
private final AtomicBoolean isCancelled = new AtomicBoolean (false);
6364

6465

6566
/**
@@ -128,15 +129,23 @@ public boolean supportsPerformanceLibraries ()
128129
@Override
129130
public void cancel ()
130131
{
131-
this.isCancelled = true;
132+
this.isCancelled.set (true);
133+
}
134+
135+
136+
/** {@inheritDoc} */
137+
@Override
138+
public boolean isCancelled ()
139+
{
140+
return this.isCancelled.get ();
132141
}
133142

134143

135144
/** {@inheritDoc} */
136145
@Override
137146
public void clearCancelled ()
138147
{
139-
this.isCancelled = false;
148+
this.isCancelled.set (false);
140149
}
141150

142151

@@ -389,7 +398,7 @@ protected List<File> writeSamples (final File sampleFolder, final IMultisampleSo
389398
final List<ISampleZone> sampleZones = group.getSampleZones ();
390399
for (int zoneIndex = 0; zoneIndex < sampleZones.size (); zoneIndex++)
391400
{
392-
if (this.isCancelled)
401+
if (this.isCancelled ())
393402
return writtenFiles;
394403

395404
final ISampleZone zone = sampleZones.get (zoneIndex);

src/main/java/de/mossgrabers/convertwithmoss/core/creator/AbstractWavCreator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected List<File> writeSamples (final File sampleFolder, final IMultisampleSo
211211
final List<ISampleZone> sampleZones = group.getSampleZones ();
212212
for (int zoneIndex = 0; zoneIndex < sampleZones.size (); zoneIndex++)
213213
{
214-
if (this.isCancelled)
214+
if (this.isCancelled ())
215215
return writtenFiles;
216216

217217
final ISampleZone zone = sampleZones.get (zoneIndex);

src/main/java/de/mossgrabers/convertwithmoss/core/detector/AbstractDetector.java

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.nio.file.Path;
1212
import java.nio.file.attribute.BasicFileAttributes;
1313
import java.nio.file.attribute.FileTime;
14+
import java.util.ArrayList;
1415
import java.util.Date;
1516
import java.util.HashMap;
1617
import java.util.HashSet;
@@ -60,7 +61,7 @@
6061
* Base class for detector descriptors.
6162
*
6263
* @param <T> The type of the settings
63-
*
64+
*
6465
* @author Jürgen Moßgraber
6566
*/
6667
public abstract class AbstractDetector<T extends ICoreTaskSettings> extends AbstractCoreTask<T> implements IDetector<T>
@@ -120,7 +121,7 @@ public final void detect (final File sourceFolder, final Consumer<IMultisampleSo
120121

121122
/**
122123
* Overwrite in case that file endings need to be set dynamically.
123-
*
124+
*
124125
* @param detectPerformances If true, performances are detected otherwise presets
125126
*/
126127
protected void configureFileEndings (final boolean detectPerformances)
@@ -163,11 +164,8 @@ public boolean supportsPerformances ()
163164
}
164165

165166

166-
/**
167-
* Has the task been cancelled?
168-
*
169-
* @return True if cancelled
170-
*/
167+
/** {@inheritDoc} */
168+
@Override
171169
public boolean isCancelled ()
172170
{
173171
return this.isCancelled.get ();
@@ -221,9 +219,6 @@ private void handlePresetFile (final File file)
221219

222220
this.updateCreationDateTime (multisample.getMetadata (), file);
223221
this.multisampleSourceConsumer.accept (multisample);
224-
225-
if (this.isCancelled ())
226-
return;
227222
}
228223
}
229224
catch (final RuntimeException ex)
@@ -243,6 +238,9 @@ private void handlePerformanceFile (final File file)
243238

244239
for (IPerformanceSource performance: performances)
245240
{
241+
if (this.waitForDelivery ())
242+
break;
243+
246244
this.updateCreationDateTime (performance.getMetadata (), file);
247245
this.performanceSourceConsumer.accept (performance);
248246
}
@@ -313,7 +311,7 @@ protected boolean waitForDelivery ()
313311
return true;
314312
Thread.currentThread ().interrupt ();
315313
}
316-
return false;
314+
return this.isCancelled ();
317315
}
318316

319317

@@ -716,6 +714,63 @@ public static File findSampleFile (final INotifier notifier, final File folder,
716714
* @return The file
717715
*/
718716
public static File findFile (final INotifier notifier, final File folder, final File previousFolder, final String fileName, final int levels, final String fileType)
717+
{
718+
final File localFile = findLocalFile (notifier, folder, previousFolder, fileName, levels, fileType);
719+
if (localFile.exists ())
720+
return localFile;
721+
722+
for (final File variantFile: getCaseVariants (localFile))
723+
{
724+
final File found = findLocalFile (notifier, folder, previousFolder, variantFile.getAbsolutePath (), levels, fileType);
725+
if (found.exists ())
726+
return found;
727+
}
728+
729+
// Triggers the missing file error
730+
return localFile;
731+
}
732+
733+
734+
private static List<File> getCaseVariants (final File file)
735+
{
736+
final String fileName = file.getName ();
737+
final int dotIndex = fileName.lastIndexOf ('.');
738+
739+
final List<File> variants = new ArrayList<> ();
740+
// No extension?
741+
if (dotIndex == -1 || dotIndex == fileName.length () - 1)
742+
return variants;
743+
744+
final String nameWithoutExt = fileName.substring (0, dotIndex);
745+
final String ext = fileName.substring (dotIndex + 1);
746+
747+
final boolean isAllUpper = ext.equals (ext.toUpperCase ());
748+
final boolean isAllLower = ext.equals (ext.toLowerCase ());
749+
750+
final File parentDir = file.getParentFile ();
751+
752+
// Another workaround for a single quote which got replaced by an underscore
753+
final String nameWithoutExtCleaned = nameWithoutExt.replace ('\'', '_');
754+
final boolean addCleaned = !nameWithoutExtCleaned.equals (nameWithoutExt);
755+
756+
if (isAllUpper || !isAllLower)
757+
{
758+
variants.add (new File (parentDir, nameWithoutExt + "." + ext.toLowerCase ()));
759+
if (addCleaned)
760+
variants.add (new File (parentDir, nameWithoutExtCleaned + "." + ext.toLowerCase ()));
761+
}
762+
if (isAllLower || !isAllUpper)
763+
{
764+
variants.add (new File (parentDir, nameWithoutExt + "." + ext.toUpperCase ()));
765+
if (addCleaned)
766+
variants.add (new File (parentDir, nameWithoutExtCleaned + "." + ext.toUpperCase ()));
767+
}
768+
769+
return variants;
770+
}
771+
772+
773+
private static File findLocalFile (final INotifier notifier, final File folder, final File previousFolder, final String fileName, final int levels, final String fileType)
719774
{
720775
final File file = new File (fileName);
721776

@@ -746,7 +801,7 @@ public static File findFile (final INotifier notifier, final File folder, final
746801
if (notifier != null)
747802
notifier.log ("IDS_NOTIFY_SEARCH_FILE_IN", fileType, startDirectory.getAbsolutePath ());
748803
final File found = findFileRecursively (startDirectory, sampleFile.getName ());
749-
// Returning the original file triggers the expected error...
804+
// Returning the original non-existing file triggers the missing file error...
750805
if (found == null)
751806
{
752807
if (notifier != null)

src/main/java/de/mossgrabers/convertwithmoss/format/ni/kontakt/AbstractNKIMetadataFileHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,11 @@ protected File getFileFromEncodedSampleFileName (final String encodedSampleFileN
10981098
}
10991099

11001100
sampleFile = new File (parentFolder, samplePath);
1101+
if (sampleFile.exists () && sampleFile.canRead ())
1102+
return sampleFile;
1103+
// Search all sub-folders - also triggers searching for different extension cases
1104+
// Also go up 1 folder in case this is a library
1105+
sampleFile = AbstractDetector.findSampleFile (this.notifier, parentFolder, null, sampleFile.getAbsolutePath (), 1);
11011106
if (sampleFile.exists () && sampleFile.canRead ())
11021107
return sampleFile;
11031108
this.notifier.logError ("IDS_NKI_SAMPLE_FILE_DOES_NOT_EXIST", sampleFile.getAbsolutePath ());

src/main/java/de/mossgrabers/convertwithmoss/format/ni/kontakt/type/kontakt5/FileList.java

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class FileList
2626

2727

2828
/**
29-
* Parse a file list (or pre 5.1 file list) from a preset chunk.
29+
* Parse a file list from a preset chunk.
3030
*
3131
* @param chunk The chunk to parse
3232
* @throws IOException Could not read the chunk
@@ -40,6 +40,7 @@ public void parse (final KontaktPresetChunk chunk) throws IOException
4040
final byte [] data = chunk.getPublicData ();
4141
final ByteArrayInputStream in = new ByteArrayInputStream (data);
4242

43+
// Since 5.1
4344
if (chunkID == KontaktPresetChunkID.FILENAME_LIST_EX)
4445
{
4546
final int version = StreamUtils.readUnsigned16 (in, false);
@@ -48,26 +49,14 @@ public void parse (final KontaktPresetChunk chunk) throws IOException
4849

4950
if (version == 3)
5051
{
51-
final List<String> files = readFilesV3 (in);
52-
this.specialFiles = files;
53-
this.sampleFiles = files;
52+
this.specialFiles = readFilesV2 (in);
53+
this.sampleFiles = this.specialFiles;
5454
return;
5555
}
56-
57-
this.specialFiles = readFilesV2 (in);
5856
}
59-
else
60-
{
61-
final long version = StreamUtils.readUnsigned32 (in, false);
62-
if (version < 0 || version > 1)
63-
throw new IOException (Functions.getMessage ("IDS_NKI5_UNSUPPORTED_FILELIST_VERSION", Long.toString (version)));
6457

65-
if (version == 1)
66-
// absoluteMonolithSourcePath not used currently
67-
readFile (in);
68-
}
69-
70-
this.sampleFiles = readFilesV2 (in);
58+
this.specialFiles = readFiles (in);
59+
this.sampleFiles = readFiles (in);
7160
this.readMetadata (in, chunkID);
7261
}
7362

@@ -90,7 +79,7 @@ private void readMetadata (final ByteArrayInputStream in, final int chunkID) thr
9079
for (int i = 0; i < numFiles; i++)
9180
StreamUtils.readUnsigned32 (in, false);
9281

93-
this.otherFiles = readFilesV2 (in);
82+
this.otherFiles = readFiles (in);
9483
}
9584
else
9685
// Final padding
@@ -105,7 +94,7 @@ private void readMetadata (final ByteArrayInputStream in, final int chunkID) thr
10594
* @return The read file paths
10695
* @throws IOException Could not read
10796
*/
108-
private static List<String> readFilesV2 (final ByteArrayInputStream in) throws IOException
97+
private static List<String> readFiles (final ByteArrayInputStream in) throws IOException
10998
{
11099
final List<String> files = new ArrayList<> ();
111100
if (in.available () > 0)
@@ -125,7 +114,7 @@ private static List<String> readFilesV2 (final ByteArrayInputStream in) throws I
125114
* @return The read file paths
126115
* @throws IOException Could not read
127116
*/
128-
private static List<String> readFilesV3 (final ByteArrayInputStream in) throws IOException
117+
private static List<String> readFilesV2 (final ByteArrayInputStream in) throws IOException
129118
{
130119
final List<String> files = new ArrayList<> ();
131120
if (in.available () > 0)

src/main/java/de/mossgrabers/convertwithmoss/format/ni/maschine/MaschineDetector.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public class MaschineDetector extends AbstractDetector<MetadataSettingsUI>
2828
{
2929
private static final String [] ENDINGS_ALL =
3030
{
31-
".mxsnd"
31+
".mxsnd",
32+
".mxgrp"
3233
};
3334

3435

@@ -39,7 +40,7 @@ public class MaschineDetector extends AbstractDetector<MetadataSettingsUI>
3940
*/
4041
public MaschineDetector (final INotifier notifier)
4142
{
42-
super ("Maschine (mxsnd)", "Maschine", notifier, new MetadataSettingsUI ("Maschine"));
43+
super ("Maschine (mxgrp, mxsnd)", "Maschine", notifier, new MetadataSettingsUI ("Maschine"));
4344
}
4445

4546

0 commit comments

Comments
 (0)