Skip to content

Commit

Permalink
Added support for legacy AdLib Timbre Bank Format
Browse files Browse the repository at this point in the history
This format was before introducing of new BNK format
  • Loading branch information
Wohlstand committed Jul 23, 2017
1 parent 232da19 commit 21b5a0f
Show file tree
Hide file tree
Showing 16 changed files with 339 additions and 19 deletions.
Binary file added Bank_Examples/tim.snd
Binary file not shown.
Binary file added Bank_Examples/tim.tim
Binary file not shown.
10 changes: 6 additions & 4 deletions FMBankEdit.pro
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ SOURCES += \
src/controlls.cpp \
src/FileFormats/ffmt_base.cpp \
src/FileFormats/ffmt_factory.cpp \
src/FileFormats/format_adlibbnk.cpp \
src/FileFormats/format_ail2_gtl.cpp \
src/FileFormats/format_apogeetmb.cpp \
src/FileFormats/format_bisqwit.cpp \
Expand All @@ -80,7 +79,9 @@ SOURCES += \
src/main.cpp \
src/opl/generator.cpp \
src/opl/nukedopl3.c \
src/piano.cpp
src/piano.cpp \
src/FileFormats/format_adlib_bnk.cpp \
src/FileFormats/format_adlib_tim.cpp

HEADERS += \
src/bank_editor.h \
Expand All @@ -89,7 +90,6 @@ HEADERS += \
src/FileFormats/ffmt_base.h \
src/FileFormats/ffmt_enums.h \
src/FileFormats/ffmt_factory.h \
src/FileFormats/format_adlibbnk.h \
src/FileFormats/format_ail2_gtl.h \
src/FileFormats/format_apogeetmb.h \
src/FileFormats/format_bisqwit.h \
Expand All @@ -104,7 +104,9 @@ HEADERS += \
src/opl/generator.h \
src/opl/nukedopl3.h \
src/piano.h \
src/version.h
src/version.h \
src/FileFormats/format_adlib_tim.h \
src/FileFormats/format_adlib_bnk.h

FORMS += \
src/bank_editor.ui \
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ A small cross-platform editor of the OPL3 FM banks of different formats
[![Build status](https://ci.appveyor.com/api/projects/status/llbyd0blk0i7amih?svg=true)](https://ci.appveyor.com/project/Wohlstand/opl3bankeditor)

## Currently supported bank formats
* Own bank format (.WOPL)
* Own bank format (.WOPL) (Specification in the **WOPL-and-OPLI-Specification.txt** file)
* Junglevision patch (.OP3)
* DMX OPL-2 (.OP2)
* Apogee Sound System timbre formats (.TMB)
* SoundBlaster IBK files (.IBK)
* AdLib/HMI BNK files (.BNK) ([Specification](http://www.shikadi.net/moddingwiki/AdLib_Instrument_Bank_Format))
* AdLib Timbe bank files (.SND, .TIM) ([Specification](http://www.shikadi.net/moddingwiki/AdLib_Timbre_Bank_Format))
* Global Timbre Library files for Audio Interface Library (.AD, .OPL) ([Specification](http://www.shikadi.net/moddingwiki/Global_Timbre_Library))
* SB and O3 bank formats (a set of the concoctated SBI files) used with Linux drivers
* Bisqwit's ADLMIDI bank (.ADLRAW)

## Currently supported instrument formats
* Own 2/4-operator instrument format (.OPLI)
* Own 2/4-operator instrument format (.OPLI) (Specification in the **WOPL-and-OPLI-Specification.txt** file)
* 2-operator Sound Blaster instruments for DOS and UNIX (.SBI) ([Specification](http://www.shikadi.net/moddingwiki/SBI_Format))
* 4-operator Sound Blaster instruments for UNIX (.SBI)
* Legacy AdLib instruments (.INS) ([Specification](http://www.shikadi.net/moddingwiki/AdLib_Instrument_Bank_Format))
Expand Down
4 changes: 2 additions & 2 deletions _Misc/bytecmp_silly.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

int main()
{
FILE* f1 = fopen("std.o3", "rb");
FILE* f2 = fopen("std-2.o3", "rb");
FILE* f1 = fopen("tim.snd", "rb");
FILE* f2 = fopen("tim.tim", "rb");

unsigned char byte1=0, byte2=0;
int count=0;
Expand Down
63 changes: 63 additions & 0 deletions _Misc/bytecmp_tim.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <stdio.h>

int main()
{
FILE* f1 = fopen("tim.snd", "rb");
FILE* f2 = fopen("tim.tim", "rb");

unsigned char byte1=0, byte2=0;
int count=0;
int insCount=0;
int dataPos = 4;
int valid1 = 1;
int valid2 = 1;
int drumMode = 0;
unsigned short ins_count = 0;
fseek(f1, 2, SEEK_SET);
fread(&ins_count, 2, 1, f1);
fseek(f1, 0, SEEK_SET);
dataPos = (ins_count * 9) + 6;
while( valid1 && valid2 )
{
valid1 = (fread(&byte1, 1, 1, f1)!=0);
valid2 = (fread(&byte2, 1, 1, f2)!=0);

if(!valid1 && !valid2)
break;

if(count==0)
{
printf("Header\n");
}

if(count==6)
{
printf("Header END\n");
}

if( (count >= 6) && (count < dataPos))
{
int relPos = (count - 6) % 9;
if(relPos == 0)
printf("Title\n");
}

if(count >= dataPos)
{
int relPos = (count - dataPos) % 56;
if(relPos == 0 )
printf("INSTRUMENT!!! %d\nModulator\n", insCount++);
if(relPos == 26 )
printf("Carrier\n");

if((relPos == 4)||(relPos == (26+4)))
printf("---feedback\n");

if(relPos == 26 * 2 )
printf("WaveForms\n");
}

printf("%03X: {0x%02x == 0x%02x}%s\n", count, byte1, byte2, (byte1==byte2)?"":" <- NOT SAME!!!");
count++;
}
}
2 changes: 2 additions & 0 deletions _Misc/compare_banks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ DoSome ibk3
DoSome bnk
DoSome silly
DoSome adlraw
DoSome tim

Binary file added _Misc/tim.snd
Binary file not shown.
Binary file added _Misc/tim.tim
Binary file not shown.
7 changes: 4 additions & 3 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ Version 1.3.1-beta
- Added writing support for UNIX SB/OP banks (with ability to choose percussion or melodic to export)
- Fixed instruments filter
- Added instrument export into 60-kylobite 4-operator SBI file
- Added experimental support for 80-byte AdLib INS file (because of difference in specification and generated by SBANK utility)
- Added support for 80-byte AdLib INS file
- Added experimental support for instrument import from CMF music files (without percussion detection)
- Added support for Bisqwit's ADLMIDI bank
- Added own bank format to have ability save all parameters supported by editor
- Added support for Bisqwit's ADLMIDI bank (.adlraw)
- Added own bank format to have ability keep all parameters supported by editor
- Added support for AdLib Timbre Bank Format (.snd and .tim)

Version 1.3.0-beta
- Fixed support for AIL banks
Expand Down
13 changes: 13 additions & 0 deletions formats_info.htm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ <h1>Bank file format comparison</h1>
<td style="text-align: center;">NO</td>
<td style="text-align: center;">NO</td>
</tr>
<tr><td style="font-weight: bold;">AdLib timbre bank (SND/TIM)</td>
<td style="text-align: center;">65536</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">NO</td>
<td style="text-align: center;">NO</td>
<td style="text-align: center;">NO</td>
<td style="text-align: center;">NO</td>
<td style="text-align: center;">NO</td>
<td style="text-align: center;">NO</td>
</tr>
<tr><td style="font-weight: bold;">Human Machine Interface AdLib bank (BNK)</td>
<td style="text-align: center;">128</td>
<td style="text-align: center;">128 **</td>
Expand Down Expand Up @@ -134,6 +145,7 @@ <h1>Bank file format comparison</h1>
<td style="text-align: center;">YES</td>
<td style="text-align: center;">NO</td>
</tr>
<!-- Template row
<tr><td style="font-weight: bold;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
Expand All @@ -145,6 +157,7 @@ <h1>Bank file format comparison</h1>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
</tr>
-->
</tbody></table><br>
* <strong>MIXED</strong> means that percussion instruments are in same list together with melodic, but has a flag which tells is this instrument melodic or percussion<br>
** HMI requires separated banks for melodic and percusive<br>
Expand Down
1 change: 1 addition & 0 deletions src/FileFormats/ffmt_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ enum class BankFormats
FORMAT_ADLIB_BKN1,
FORMAT_ADLIB_BKNHMI,
FORMAT_ADLIB_BKNHMI_DRUMS,
FORMAT_ADLIB_TIM,
FORMAT_AIL2,
FORMAT_APOGEE,
FORMAT_BISQWIT,
Expand Down
6 changes: 5 additions & 1 deletion src/FileFormats/ffmt_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

#include "ffmt_factory.h"

#include "format_adlibbnk.h"
#include "format_adlib_bnk.h"
#include "format_adlib_tim.h"
#include "format_ail2_gtl.h"
#include "format_apogeetmb.h"
#include "format_bisqwit.h"
Expand Down Expand Up @@ -87,6 +88,9 @@ void FmBankFormatFactory::registerAllFormats()
registerBankFormat(new AdLibBnk_writer());
registerBankFormat(new HmiBnk_writer());

//Legacy AdLib Timbre format
registerBankFormat(new AdLibTimbre());

//Bisqwit
registerBankFormat(new BisqwitBank());

Expand Down
14 changes: 7 additions & 7 deletions src/FileFormats/format_adlib_bnk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "format_adlibbnk.h"
#include "format_adlib_bnk.h"
#include "../common.h"
#include <QMap>
#include <QFileInfo>
Expand Down Expand Up @@ -575,7 +575,7 @@ bool AdLibAndHmiBnk_reader::detectInst(const QString &filePath, char *)
* @param idata Input raw data
* @return true if data valid, false if data contains broken or invalid data
*/
static bool insRawToOp(FmBank::Instrument &inst, const int opType, const uint8_t *idata)
bool adlib_ins_insRawToOp(FmBank::Instrument &inst, const int opType, const uint8_t *idata)
{
inst.OP[opType].ksl = idata[0] & 0x03;
inst.OP[opType].fmult = idata[2] & 0x0F;
Expand All @@ -601,7 +601,7 @@ static bool insRawToOp(FmBank::Instrument &inst, const int opType, const uint8_t
* @param opType Operator type (Modulator or carrier)
* @param odata Destinition output memory block to write
*/
static void opToRawIns(const FmBank::Instrument &inst, const int opType, uint8_t *odata)
void adlib_ins_opToRawIns(const FmBank::Instrument &inst, const int opType, uint8_t *odata)
{
odata[0] = inst.OP[opType].ksl;
odata[2] = inst.OP[opType].fmult;
Expand Down Expand Up @@ -639,13 +639,13 @@ FfmtErrCode AdLibAndHmiBnk_reader::loadFileInst(QString filePath, FmBank::Instru
if((idata[0] != 0) || (idata[1] != 0))
return FfmtErrCode::ERR_BADFORMAT;

if(!insRawToOp(inst, MODULATOR1, idata + 2))
if(!adlib_ins_insRawToOp(inst, MODULATOR1, idata + 2))
{
memset(&inst, 0, sizeof(FmBank::Instrument));
return FfmtErrCode::ERR_BADFORMAT;
}

if(!insRawToOp(inst, CARRIER1, idata + 28))
if(!adlib_ins_insRawToOp(inst, CARRIER1, idata + 28))
{
memset(&inst, 0, sizeof(FmBank::Instrument));
return FfmtErrCode::ERR_BADFORMAT;
Expand Down Expand Up @@ -692,8 +692,8 @@ FfmtErrCode AdLibAndHmiBnk_reader::saveFileInst(QString filePath, FmBank::Instru
uint8_t odata[80];
memset(&odata, 0, 80);

opToRawIns(inst, MODULATOR1, odata + 2);
opToRawIns(inst, CARRIER1, odata + 28);
adlib_ins_opToRawIns(inst, MODULATOR1, odata + 2);
adlib_ins_opToRawIns(inst, CARRIER1, odata + 28);

//By this specification: http://www.shikadi.net/moddingwiki/AdLib_Instrument_Format
#if 0
Expand Down
Loading

0 comments on commit 21b5a0f

Please sign in to comment.