aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJP Cimalando <jpcima@users.noreply.github.com>2018-11-04 01:39:36 +0100
committerJP Cimalando <jpcima@users.noreply.github.com>2018-11-04 01:39:36 +0100
commit4c33b5e9573608ce5f7ae845e59a97f087d1aa9d (patch)
treecdcf91e2382c7f19325f1fb6b2a42f936805a0d1
parent699b534eb1dcd3964daf99cc572c6819bdd449a8 (diff)
downloadlibADLMIDI-4c33b5e9573608ce5f7ae845e59a97f087d1aa9d.tar.gz
libADLMIDI-4c33b5e9573608ce5f7ae845e59a97f087d1aa9d.tar.bz2
libADLMIDI-4c33b5e9573608ce5f7ae845e59a97f087d1aa9d.zip
update the WOPL library with fixes
-rw-r--r--src/wopl/wopl_file.c32
-rw-r--r--src/wopl/wopl_file.h14
2 files changed, 29 insertions, 17 deletions
diff --git a/src/wopl/wopl_file.c b/src/wopl/wopl_file.c
index f018cbc..6e9103b 100644
--- a/src/wopl/wopl_file.c
+++ b/src/wopl/wopl_file.c
@@ -77,18 +77,30 @@ static void fromSint16BE(int16_t in, uint8_t *arr)
WOPLFile *WOPL_Init(uint16_t melodic_banks, uint16_t percussive_banks)
{
- WOPLFile *file = NULL;
- if(melodic_banks == 0)
- return NULL;
- if(percussive_banks == 0)
- return NULL;
- file = (WOPLFile*)calloc(1, sizeof(WOPLFile));
+ WOPLFile *file = (WOPLFile*)calloc(1, sizeof(WOPLFile));
if(!file)
return NULL;
- file->banks_count_melodic = melodic_banks;
- file->banks_count_percussion = percussive_banks;
- file->banks_melodic = (WOPLBank*)calloc(1, sizeof(WOPLBank) * melodic_banks );
- file->banks_percussive = (WOPLBank*)calloc(1, sizeof(WOPLBank) * percussive_banks );
+
+ file->banks_count_melodic = (melodic_banks != 0) ? melodic_banks : 1;
+ file->banks_melodic = (WOPLBank*)calloc(file->banks_count_melodic, sizeof(WOPLBank));
+
+ if(melodic_banks == 0)
+ {
+ unsigned i;
+ for(i = 0; i < 128; ++i)
+ file->banks_melodic[0].ins[i].inst_flags = WOPL_Ins_IsBlank;
+ }
+
+ file->banks_count_percussion = (percussive_banks != 0) ? percussive_banks : 1;
+ file->banks_percussive = (WOPLBank*)calloc(file->banks_count_percussion, sizeof(WOPLBank));
+
+ if(percussive_banks == 0)
+ {
+ unsigned i;
+ for(i = 0; i < 128; ++i)
+ file->banks_percussive[0].ins[i].inst_flags = WOPL_Ins_IsBlank;
+ }
+
return file;
}
diff --git a/src/wopl/wopl_file.h b/src/wopl/wopl_file.h
index fa270b6..7461743 100644
--- a/src/wopl/wopl_file.h
+++ b/src/wopl/wopl_file.h
@@ -242,7 +242,7 @@ extern WOPLFile *WOPL_LoadBankFromMem(void *mem, size_t length, int *error);
/**
* @brief Load WOPI instrument file from the memory.
* You must allocate WOPIFile structure by yourself and give the pointer to it.
- * @param file Pointer to destinition WOPIFile structure to fill it with parsed data.
+ * @param file Pointer to destination WOPIFile structure to fill it with parsed data.
* @param mem Pointer to memory block contains raw WOPI instrument file data
* @param length Length of given memory block
* @return 0 if no errors occouped, or an error code of WOPL_ErrorCodes enumeration
@@ -252,7 +252,7 @@ extern int WOPL_LoadInstFromMem(WOPIFile *file, void *mem, size_t length);
/**
* @brief Calculate the size of the output memory block
* @param file Heap-allocated WOPL file data structure
- * @param version Destinition version of the file
+ * @param version Destination version of the file
* @return Size of the raw WOPL file data
*/
extern size_t WOPL_CalculateBankFileSize(WOPLFile *file, uint16_t version);
@@ -260,7 +260,7 @@ extern size_t WOPL_CalculateBankFileSize(WOPLFile *file, uint16_t version);
/**
* @brief Calculate the size of the output memory block
* @param file Pointer to WOPI file data structure
- * @param version Destinition version of the file
+ * @param version Destination version of the file
* @return Size of the raw WOPI file data
*/
extern size_t WOPL_CalculateInstFileSize(WOPIFile *file, uint16_t version);
@@ -268,8 +268,8 @@ extern size_t WOPL_CalculateInstFileSize(WOPIFile *file, uint16_t version);
/**
* @brief Write raw WOPL into given memory block
* @param file Heap-allocated WOPL file data structure
- * @param dest_mem Destinition memory block pointer
- * @param length Length of destinition memory block
+ * @param dest_mem Destination memory block pointer
+ * @param length Length of destination memory block
* @param version Wanted WOPL version
* @param force_gm Force GM set in saved bank file
* @return Error code or 0 on success
@@ -279,8 +279,8 @@ extern int WOPL_SaveBankToMem(WOPLFile *file, void *dest_mem, size_t length, uin
/**
* @brief Write raw WOPI into given memory block
* @param file Pointer to WOPI file data structure
- * @param dest_mem Destinition memory block pointer
- * @param length Length of destinition memory block
+ * @param dest_mem Destination memory block pointer
+ * @param length Length of destination memory block
* @param version Wanted WOPI version
* @return Error code or 0 on success
*/