From f45d937bce3e3cff3add3bebba321b5ab53e14fa Mon Sep 17 00:00:00 2001 From: martincameron Date: Thu, 10 Mar 2022 20:28:31 +0000 Subject: [PATCH] Initialize unused instruments. --- ModPlay3.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ModPlay3.java b/ModPlay3.java index e43084e..100fd00 100644 --- a/ModPlay3.java +++ b/ModPlay3.java @@ -124,6 +124,12 @@ public ModPlay3( java.io.InputStream moduleData, boolean soundtracker ) throws j sampleLoopStart[ idx ] = loopStart * FIXED_POINT_ONE; sampleLoopLength[ idx ] = loopLength * FIXED_POINT_ONE; } + for( int idx = numSamples; idx < MAX_SAMPLES; idx++ ) + { + instrumentNames[ idx ] = ""; + sampleVolume[ idx ] = 64; + sampleData[ idx ] = new byte[ 0 ]; + } songLength = moduleData.read() & 0x7F; if( songLength < 1 ) { @@ -192,7 +198,6 @@ else if( effect == 2 ) patternData[ idx + 2 ] = ( byte ) effect; patternData[ idx + 3 ] = ( byte ) ( ( param1 << 4 ) | ( param2 & 0xF ) ); } - for( int idx = 1; idx < numSamples; idx++ ) { sampleData[ idx ] = readBytes( moduleData, sampleLengths[ idx ] );