AUDIO: Soundfont: Added scummvm license headers. Renamed class variables.

This commit is contained in:
Eric Fry 2020-07-28 22:36:39 +10:00 committed by Eugene Sandulenko
parent 2b500c1124
commit 428cadbe6a
21 changed files with 771 additions and 406 deletions

View File

@ -19,6 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
* refer to the included LICENSE.txt file
*/
#ifndef AUDIO_SOUNDFONT_COMMON_H
#define AUDIO_SOUNDFONT_COMMON_H

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -9,55 +30,55 @@
using namespace std;
uint32 Chunk::GetSize() {
return 8 + GetPaddedSize(size);
return 8 + GetPaddedSize(_size);
}
void Chunk::SetData(const void *src, uint32 datasize) {
size = datasize;
_size = datasize;
// set the size and copy from the data source
datasize = GetPaddedSize(size);
if (data != NULL) {
delete[] data;
data = NULL;
datasize = GetPaddedSize(_size);
if (_data != NULL) {
delete[] _data;
_data = NULL;
}
data = new uint8[datasize];
memcpy(data, src, size);
_data = new uint8[datasize];
memcpy(_data, src, _size);
// Add pad byte
uint32 padsize = datasize - size;
uint32 padsize = datasize - _size;
if (padsize != 0) {
memset(data + size, 0, padsize);
memset(_data + _size, 0, padsize);
}
}
void Chunk::Write(uint8 *buffer) {
uint32 padsize = GetPaddedSize(size) - size;
memcpy(buffer, id, 4);
uint32 padsize = GetPaddedSize(_size) - _size;
memcpy(buffer, _id, 4);
*(uint32 * )(buffer + 4) =
size + padsize; // Microsoft says the chunkSize doesn't contain padding size, but many
_size + padsize; // Microsoft says the chunkSize doesn't contain padding size, but many
// software cannot handle the alignment.
memcpy(buffer + 8, data, GetPaddedSize(size));
memcpy(buffer + 8, _data, GetPaddedSize(_size));
}
Chunk *ListTypeChunk::AddChildChunk(Chunk *ck) {
childChunks.push_back(ck);
_childChunks.push_back(ck);
return ck;
}
uint32 ListTypeChunk::GetSize() {
uint32 listChunkSize = 12; // id + size + "LIST"
for (Common::List<Chunk *>::iterator iter = this->childChunks.begin(); iter != childChunks.end(); iter++)
for (Common::List<Chunk *>::iterator iter = this->_childChunks.begin(); iter != _childChunks.end(); iter++)
listChunkSize += (*iter)->GetSize();
return GetPaddedSize(listChunkSize);
}
void ListTypeChunk::Write(uint8 *buffer) {
memcpy(buffer, this->id, 4);
memcpy(buffer + 8, this->type, 4);
memcpy(buffer, this->_id, 4);
memcpy(buffer + 8, this->_type, 4);
uint32 bufOffset = 12;
for (Common::List<Chunk *>::iterator iter = this->childChunks.begin(); iter != childChunks.end(); iter++) {
for (Common::List<Chunk *>::iterator iter = this->_childChunks.begin(); iter != _childChunks.end(); iter++) {
(*iter)->Write(buffer + bufOffset);
bufOffset += (*iter)->GetSize();
}
@ -70,8 +91,8 @@ void ListTypeChunk::Write(uint8 *buffer) {
// Add pad byte
if (padsize != 0) {
memset(data + unpaddedSize, 0, padsize);
memset(_data + unpaddedSize, 0, padsize);
}
}
RiffFile::RiffFile(const Common::String &file_name, const Common::String &form) : RIFFChunk(form), name(file_name) {}
RiffFile::RiffFile(const Common::String &file_name, const Common::String &form) : RIFFChunk(form), _name(file_name) {}

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -18,20 +39,20 @@
//////////////////////////////////////////////
class Chunk {
public:
char id[4]; // A chunk ID identifies the type of data within the chunk.
uint32 size; // The size of the chunk data in bytes, excluding any pad byte.
uint8 *data; // The actual data not including a possible pad byte to word align
char _id[4]; // A chunk ID identifies the type of data within the chunk.
uint32 _size; // The size of the chunk data in bytes, excluding any pad byte.
uint8 *_data; // The actual data not including a possible pad byte to word align
public:
Chunk(Common::String theId) : data(NULL), size(0) {
Chunk(Common::String theId) : _data(NULL), _size(0) {
assert(theId.size() == 4);
memcpy(id, theId.c_str(), 4);
memcpy(_id, theId.c_str(), 4);
}
virtual ~Chunk() {
if (data != NULL) {
delete[] data;
data = NULL;
if (_data != NULL) {
delete[] _data;
_data = NULL;
}
}
@ -50,17 +71,17 @@ protected:
////////////////////////////////////////////////////////////////////////////
class ListTypeChunk : public Chunk {
public:
char type[4]; // 4 byte sig that begins the data field, "LIST" or "sfbk" for ex
Common::List<Chunk *> childChunks;
char _type[4]; // 4 byte sig that begins the data field, "LIST" or "sfbk" for ex
Common::List<Chunk *> _childChunks;
public:
ListTypeChunk(Common::String theId, Common::String theType) : Chunk(theId) {
assert(theType.size() == 4);
memcpy(type, theType.c_str(), 4);
memcpy(_type, theType.c_str(), 4);
}
virtual ~ListTypeChunk() {
childChunks.erase(childChunks.begin(), childChunks.end());
_childChunks.erase(_childChunks.begin(), _childChunks.end());
}
Chunk *AddChildChunk(Chunk *ck);
@ -107,7 +128,7 @@ public:
}
protected:
Common::String name;
Common::String _name;
};
#endif // AUDIO_SOUNDFONT_RIFFFILE_H

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -39,33 +60,33 @@ SF2InfoListChunk::SF2InfoListChunk(Common::String name) : LISTChunk("INFO") {
// SF2File
// *******
SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->_name, "sfbk") {
//***********
// INFO chunk
//***********
AddChildChunk(new SF2InfoListChunk(name));
AddChildChunk(new SF2InfoListChunk(_name));
// sdta chunk and its child smpl chunk containing all samples
LISTChunk *sdtaCk = new LISTChunk("sdta");
Chunk *smplCk = new Chunk("smpl");
// Concatanate all of the samples together and add the result to the smpl chunk data
size_t numWaves = synthfile->vWaves.size();
smplCk->size = 0;
size_t numWaves = synthfile->_vWaves.size();
smplCk->_size = 0;
for (size_t i = 0; i < numWaves; i++) {
SynthWave *wave = synthfile->vWaves[i];
SynthWave *wave = synthfile->_vWaves[i];
wave->ConvertTo16bitSigned();
smplCk->size +=
wave->dataSize + (46 * 2); // plus the 46 padding samples required by sf2 spec
smplCk->_size +=
wave->_dataSize + (46 * 2); // plus the 46 padding samples required by sf2 spec
}
smplCk->data = new uint8[smplCk->size];
smplCk->_data = new uint8[smplCk->_size];
uint32 bufPtr = 0;
for (size_t i = 0; i < numWaves; i++) {
SynthWave *wave = synthfile->vWaves[i];
SynthWave *wave = synthfile->_vWaves[i];
memcpy(smplCk->data + bufPtr, wave->data, wave->dataSize);
memset(smplCk->data + bufPtr + wave->dataSize, 0, 46 * 2);
bufPtr += wave->dataSize + (46 * 2); // plus the 46 padding samples required by sf2 spec
memcpy(smplCk->_data + bufPtr, wave->_data, wave->_dataSize);
memset(smplCk->_data + bufPtr + wave->_dataSize, 0, 46 * 2);
bufPtr += wave->_dataSize + (46 * 2); // plus the 46 padding samples required by sf2 spec
}
sdtaCk->AddChildChunk(smplCk);
@ -81,23 +102,23 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
// phdr chunk
//***********
Chunk *phdrCk = new Chunk("phdr");
size_t numInstrs = synthfile->vInstrs.size();
phdrCk->size = (uint32) ((numInstrs + 1) * sizeof(sfPresetHeader));
phdrCk->data = new uint8[phdrCk->size];
size_t numInstrs = synthfile->_vInstrs.size();
phdrCk->_size = (uint32) ((numInstrs + 1) * sizeof(sfPresetHeader));
phdrCk->_data = new uint8[phdrCk->_size];
for (size_t i = 0; i < numInstrs; i++) {
SynthInstr *instr = synthfile->vInstrs[i];
SynthInstr *instr = synthfile->_vInstrs[i];
sfPresetHeader presetHdr;
memset(&presetHdr, 0, sizeof(sfPresetHeader));
memcpy(presetHdr.achPresetName, instr->name.c_str(),
MIN((unsigned long) instr->name.size(), (unsigned long) 20));
presetHdr.wPreset = (uint16) instr->ulInstrument;
memcpy(presetHdr.achPresetName, instr->_name.c_str(),
MIN((unsigned long) instr->_name.size(), (unsigned long) 20));
presetHdr.wPreset = (uint16) instr->_ulInstrument;
// Despite being a 16-bit value, SF2 only supports banks up to 127. Since
// it's pretty common to have either MSB or LSB be 0, we'll use whatever
// one is not zero, with preference for MSB.
uint16 bank16 = (uint16) instr->ulBank;
uint16 bank16 = (uint16) instr->_ulBank;
if ((bank16 & 0xFF00) == 0) {
presetHdr.wBank = bank16 & 0x7F;
@ -109,13 +130,13 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
presetHdr.dwGenre = 0;
presetHdr.dwMorphology = 0;
memcpy(phdrCk->data + (i * sizeof(sfPresetHeader)), &presetHdr, sizeof(sfPresetHeader));
memcpy(phdrCk->_data + (i * sizeof(sfPresetHeader)), &presetHdr, sizeof(sfPresetHeader));
}
// add terminal sfPresetBag
sfPresetHeader presetHdr;
memset(&presetHdr, 0, sizeof(sfPresetHeader));
presetHdr.wPresetBagNdx = (uint16) numInstrs;
memcpy(phdrCk->data + (numInstrs * sizeof(sfPresetHeader)), &presetHdr, sizeof(sfPresetHeader));
memcpy(phdrCk->_data + (numInstrs * sizeof(sfPresetHeader)), &presetHdr, sizeof(sfPresetHeader));
pdtaCk->AddChildChunk(phdrCk);
//***********
@ -123,21 +144,21 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
//***********
Chunk *pbagCk = new Chunk("pbag");
const size_t ITEMS_IN_PGEN = 2;
pbagCk->size = (uint32) ((numInstrs + 1) * sizeof(sfPresetBag));
pbagCk->data = new uint8[pbagCk->size];
pbagCk->_size = (uint32) ((numInstrs + 1) * sizeof(sfPresetBag));
pbagCk->_data = new uint8[pbagCk->_size];
for (size_t i = 0; i < numInstrs; i++) {
sfPresetBag presetBag;
memset(&presetBag, 0, sizeof(sfPresetBag));
presetBag.wGenNdx = (uint16) (i * ITEMS_IN_PGEN);
presetBag.wModNdx = 0;
memcpy(pbagCk->data + (i * sizeof(sfPresetBag)), &presetBag, sizeof(sfPresetBag));
memcpy(pbagCk->_data + (i * sizeof(sfPresetBag)), &presetBag, sizeof(sfPresetBag));
}
// add terminal sfPresetBag
sfPresetBag presetBag;
memset(&presetBag, 0, sizeof(sfPresetBag));
presetBag.wGenNdx = (uint16) (numInstrs * ITEMS_IN_PGEN);
memcpy(pbagCk->data + (numInstrs * sizeof(sfPresetBag)), &presetBag, sizeof(sfPresetBag));
memcpy(pbagCk->_data + (numInstrs * sizeof(sfPresetBag)), &presetBag, sizeof(sfPresetBag));
pdtaCk->AddChildChunk(pbagCk);
//***********
@ -160,9 +181,9 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
//***********
Chunk *pgenCk = new Chunk("pgen");
// pgenCk->size = (synthfile->vInstrs.size()+1) * sizeof(sfGenList);
pgenCk->size = (uint32) ((synthfile->vInstrs.size() * sizeof(sfGenList) * ITEMS_IN_PGEN) +
sizeof(sfGenList));
pgenCk->data = new uint8[pgenCk->size];
pgenCk->_size = (uint32) ((synthfile->_vInstrs.size() * sizeof(sfGenList) * ITEMS_IN_PGEN) +
sizeof(sfGenList));
pgenCk->_data = new uint8[pgenCk->_size];
uint32 dataPtr = 0;
for (size_t i = 0; i < numInstrs; i++) {
sfGenList genList;
@ -171,18 +192,18 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
// reverbEffectsSend
genList.sfGenOper = reverbEffectsSend;
genList.genAmount.shAmount = 250;
memcpy(pgenCk->data + dataPtr, &genList, sizeof(sfGenList));
memcpy(pgenCk->_data + dataPtr, &genList, sizeof(sfGenList));
dataPtr += sizeof(sfGenList);
genList.sfGenOper = instrument;
genList.genAmount.wAmount = (uint16) i;
memcpy(pgenCk->data + dataPtr, &genList, sizeof(sfGenList));
memcpy(pgenCk->_data + dataPtr, &genList, sizeof(sfGenList));
dataPtr += sizeof(sfGenList);
}
// add terminal sfGenList
sfGenList genList;
memset(&genList, 0, sizeof(sfGenList));
memcpy(pgenCk->data + dataPtr, &genList, sizeof(sfGenList));
memcpy(pgenCk->_data + dataPtr, &genList, sizeof(sfGenList));
pdtaCk->AddChildChunk(pgenCk);
@ -190,26 +211,26 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
// inst chunk
//***********
Chunk *instCk = new Chunk("inst");
instCk->size = (uint32) ((synthfile->vInstrs.size() + 1) * sizeof(sfInst));
instCk->data = new uint8[instCk->size];
instCk->_size = (uint32) ((synthfile->_vInstrs.size() + 1) * sizeof(sfInst));
instCk->_data = new uint8[instCk->_size];
size_t rgnCounter = 0;
for (size_t i = 0; i < numInstrs; i++) {
SynthInstr *instr = synthfile->vInstrs[i];
SynthInstr *instr = synthfile->_vInstrs[i];
sfInst inst;
memset(&inst, 0, sizeof(sfInst));
memcpy(inst.achInstName, instr->name.c_str(),
MIN((unsigned long) instr->name.size(), (unsigned long) 20));
memcpy(inst.achInstName, instr->_name.c_str(),
MIN((unsigned long) instr->_name.size(), (unsigned long) 20));
inst.wInstBagNdx = (uint16) rgnCounter;
rgnCounter += instr->vRgns.size();
rgnCounter += instr->_vRgns.size();
memcpy(instCk->data + (i * sizeof(sfInst)), &inst, sizeof(sfInst));
memcpy(instCk->_data + (i * sizeof(sfInst)), &inst, sizeof(sfInst));
}
// add terminal sfInst
sfInst inst;
memset(&inst, 0, sizeof(sfInst));
inst.wInstBagNdx = (uint16) rgnCounter;
memcpy(instCk->data + (numInstrs * sizeof(sfInst)), &inst, sizeof(sfInst));
memcpy(instCk->_data + (numInstrs * sizeof(sfInst)), &inst, sizeof(sfInst));
pdtaCk->AddChildChunk(instCk);
//***********
@ -219,17 +240,17 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
size_t totalNumRgns = 0;
for (size_t i = 0; i < numInstrs; i++)
totalNumRgns += synthfile->vInstrs[i]->vRgns.size();
totalNumRgns += synthfile->_vInstrs[i]->_vRgns.size();
ibagCk->size = (uint32) ((totalNumRgns + 1) * sizeof(sfInstBag));
ibagCk->data = new uint8[ibagCk->size];
ibagCk->_size = (uint32) ((totalNumRgns + 1) * sizeof(sfInstBag));
ibagCk->_data = new uint8[ibagCk->_size];
rgnCounter = 0;
int instGenCounter = 0;
for (size_t i = 0; i < numInstrs; i++) {
SynthInstr *instr = synthfile->vInstrs[i];
SynthInstr *instr = synthfile->_vInstrs[i];
size_t numRgns = instr->vRgns.size();
size_t numRgns = instr->_vRgns.size();
for (size_t j = 0; j < numRgns; j++) {
sfInstBag instBag;
memset(&instBag, 0, sizeof(sfInstBag));
@ -237,7 +258,7 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
instGenCounter += 11;
instBag.wInstModNdx = 0;
memcpy(ibagCk->data + (rgnCounter++ * sizeof(sfInstBag)), &instBag, sizeof(sfInstBag));
memcpy(ibagCk->_data + (rgnCounter++ * sizeof(sfInstBag)), &instBag, sizeof(sfInstBag));
}
}
// add terminal sfInstBag
@ -245,7 +266,7 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
memset(&instBag, 0, sizeof(sfInstBag));
instBag.wInstGenNdx = instGenCounter;
instBag.wInstModNdx = 0;
memcpy(ibagCk->data + (rgnCounter * sizeof(sfInstBag)), &instBag, sizeof(sfInstBag));
memcpy(ibagCk->_data + (rgnCounter * sizeof(sfInstBag)), &instBag, sizeof(sfInstBag));
pdtaCk->AddChildChunk(ibagCk);
//***********
@ -261,91 +282,91 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
// igen chunk
//***********
Chunk *igenCk = new Chunk("igen");
igenCk->size = (uint32) ((totalNumRgns * sizeof(sfInstGenList) * 11) + sizeof(sfInstGenList));
igenCk->data = new uint8[igenCk->size];
igenCk->_size = (uint32) ((totalNumRgns * sizeof(sfInstGenList) * 11) + sizeof(sfInstGenList));
igenCk->_data = new uint8[igenCk->_size];
dataPtr = 0;
for (size_t i = 0; i < numInstrs; i++) {
SynthInstr *instr = synthfile->vInstrs[i];
SynthInstr *instr = synthfile->_vInstrs[i];
size_t numRgns = instr->vRgns.size();
size_t numRgns = instr->_vRgns.size();
for (size_t j = 0; j < numRgns; j++) {
SynthRgn *rgn = instr->vRgns[j];
SynthRgn *rgn = instr->_vRgns[j];
sfInstGenList instGenList;
// Key range - (if exists) this must be the first chunk
instGenList.sfGenOper = keyRange;
instGenList.genAmount.ranges.byLo = (uint8) rgn->usKeyLow;
instGenList.genAmount.ranges.byHi = (uint8) rgn->usKeyHigh;
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
instGenList.genAmount.ranges.byLo = (uint8) rgn->_usKeyLow;
instGenList.genAmount.ranges.byHi = (uint8) rgn->_usKeyHigh;
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
if (rgn->usVelHigh) // 0 means 'not set', fixes TriAce instruments
if (rgn->_usVelHigh) // 0 means 'not set', fixes TriAce instruments
{
// Velocity range (if exists) this must be the next chunk
instGenList.sfGenOper = velRange;
instGenList.genAmount.ranges.byLo = (uint8) rgn->usVelLow;
instGenList.genAmount.ranges.byHi = (uint8) rgn->usVelHigh;
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
instGenList.genAmount.ranges.byLo = (uint8) rgn->_usVelLow;
instGenList.genAmount.ranges.byHi = (uint8) rgn->_usVelHigh;
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
}
// initialAttenuation
instGenList.sfGenOper = initialAttenuation;
instGenList.genAmount.shAmount = (int16) (rgn->sampinfo->attenuation * 10);
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
instGenList.genAmount.shAmount = (int16) (rgn->_sampinfo->_attenuation * 10);
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// pan
instGenList.sfGenOper = pan;
instGenList.genAmount.shAmount =
(int16) ConvertPercentPanTo10thPercentUnits(rgn->art->pan);
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
(int16) ConvertPercentPanTo10thPercentUnits(rgn->_art->_pan);
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// sampleModes
instGenList.sfGenOper = sampleModes;
instGenList.genAmount.wAmount = rgn->sampinfo->cSampleLoops;
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
instGenList.genAmount.wAmount = rgn->_sampinfo->_cSampleLoops;
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// overridingRootKey
instGenList.sfGenOper = overridingRootKey;
instGenList.genAmount.wAmount = rgn->sampinfo->usUnityNote;
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
instGenList.genAmount.wAmount = rgn->_sampinfo->_usUnityNote;
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// attackVolEnv
instGenList.sfGenOper = attackVolEnv;
instGenList.genAmount.shAmount =
(rgn->art->attack_time == 0)
(rgn->_art->_attack_time == 0)
? -32768
: round(SecondsToTimecents(rgn->art->attack_time));
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
: round(SecondsToTimecents(rgn->_art->_attack_time));
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// decayVolEnv
instGenList.sfGenOper = decayVolEnv;
instGenList.genAmount.shAmount =
(rgn->art->decay_time == 0) ? -32768
: round(SecondsToTimecents(rgn->art->decay_time));
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
(rgn->_art->_decay_time == 0) ? -32768
: round(SecondsToTimecents(rgn->_art->_decay_time));
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// sustainVolEnv
instGenList.sfGenOper = sustainVolEnv;
if (rgn->art->sustain_lev > 100.0)
rgn->art->sustain_lev = 100.0;
instGenList.genAmount.shAmount = (int16) (rgn->art->sustain_lev * 10);
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
if (rgn->_art->_sustain_lev > 100.0)
rgn->_art->_sustain_lev = 100.0;
instGenList.genAmount.shAmount = (int16) (rgn->_art->_sustain_lev * 10);
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// releaseVolEnv
instGenList.sfGenOper = releaseVolEnv;
instGenList.genAmount.shAmount =
(rgn->art->release_time == 0)
(rgn->_art->_release_time == 0)
? -32768
: round(SecondsToTimecents(rgn->art->release_time));
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
: round(SecondsToTimecents(rgn->_art->_release_time));
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// reverbEffectsSend
@ -356,8 +377,8 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
// sampleID - this is the terminal chunk
instGenList.sfGenOper = sampleID;
instGenList.genAmount.wAmount = (uint16) (rgn->tableIndex);
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
instGenList.genAmount.wAmount = (uint16) (rgn->_tableIndex);
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
dataPtr += sizeof(sfInstGenList);
// int numConnBlocks = rgn->art->vConnBlocks.size();
@ -371,7 +392,7 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
// add terminal sfInstBag
sfInstGenList instGenList;
memset(&instGenList, 0, sizeof(sfInstGenList));
memcpy(igenCk->data + dataPtr, &instGenList, sizeof(sfInstGenList));
memcpy(igenCk->_data + dataPtr, &instGenList, sizeof(sfInstGenList));
// memset(ibagCk->data + (totalNumRgns*sizeof(sfInstBag)), 0, sizeof(sfInstBag));
// igenCk->SetData(&genList, sizeof(sfGenList));
pdtaCk->AddChildChunk(igenCk);
@ -381,32 +402,32 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
//***********
Chunk *shdrCk = new Chunk("shdr");
size_t numSamps = synthfile->vWaves.size();
shdrCk->size = (uint32) ((numSamps + 1) * sizeof(sfSample));
shdrCk->data = new uint8[shdrCk->size];
size_t numSamps = synthfile->_vWaves.size();
shdrCk->_size = (uint32) ((numSamps + 1) * sizeof(sfSample));
shdrCk->_data = new uint8[shdrCk->_size];
uint32 sampOffset = 0;
for (size_t i = 0; i < numSamps; i++) {
SynthWave *wave = synthfile->vWaves[i];
SynthWave *wave = synthfile->_vWaves[i];
sfSample samp;
memset(&samp, 0, sizeof(sfSample));
memcpy(samp.achSampleName, wave->name.c_str(),
MIN((unsigned long) wave->name.size(), (unsigned long) 20));
memcpy(samp.achSampleName, wave->_name.c_str(),
MIN((unsigned long) wave->_name.size(), (unsigned long) 20));
samp.dwStart = sampOffset;
samp.dwEnd = samp.dwStart + (wave->dataSize / sizeof(uint16));
samp.dwEnd = samp.dwStart + (wave->_dataSize / sizeof(uint16));
sampOffset = samp.dwEnd + 46; // plus the 46 padding samples required by sf2 spec
// Search through all regions for an associated sampInfo structure with this sample
SynthSampInfo *sampInfo = NULL;
for (size_t j = 0; j < numInstrs; j++) {
SynthInstr *instr = synthfile->vInstrs[j];
SynthInstr *instr = synthfile->_vInstrs[j];
size_t numRgns = instr->vRgns.size();
size_t numRgns = instr->_vRgns.size();
for (size_t k = 0; k < numRgns; k++) {
SynthRgn *rgn = instr->vRgns[k];
if (rgn->tableIndex == i && rgn->sampinfo != NULL) {
sampInfo = rgn->sampinfo;
SynthRgn *rgn = instr->_vRgns[k];
if (rgn->_tableIndex == i && rgn->_sampinfo != NULL) {
sampInfo = rgn->_sampinfo;
break;
}
}
@ -415,22 +436,22 @@ SF2File::SF2File(SynthFile *synthfile) : RiffFile(synthfile->name, "sfbk") {
}
// If we didn't find a rgn association, then it should be in the SynthWave structure.
if (sampInfo == NULL)
sampInfo = wave->sampinfo;
sampInfo = wave->_sampinfo;
assert(sampInfo != NULL);
samp.dwStartloop = samp.dwStart + sampInfo->ulLoopStart;
samp.dwEndloop = samp.dwStartloop + sampInfo->ulLoopLength;
samp.dwSampleRate = wave->dwSamplesPerSec;
samp.byOriginalKey = (uint8) (sampInfo->usUnityNote);
samp.chCorrection = (char) (sampInfo->sFineTune);
samp.dwStartloop = samp.dwStart + sampInfo->_ulLoopStart;
samp.dwEndloop = samp.dwStartloop + sampInfo->_ulLoopLength;
samp.dwSampleRate = wave->_dwSamplesPerSec;
samp.byOriginalKey = (uint8) (sampInfo->_usUnityNote);
samp.chCorrection = (char) (sampInfo->_sFineTune);
samp.wSampleLink = 0;
samp.sfSampleType = monoSample;
memcpy(shdrCk->data + (i * sizeof(sfSample)), &samp, sizeof(sfSample));
memcpy(shdrCk->_data + (i * sizeof(sfSample)), &samp, sizeof(sfSample));
}
// add terminal sfSample
memset(shdrCk->data + (numSamps * sizeof(sfSample)), 0, sizeof(sfSample));
memset(shdrCk->_data + (numSamps * sizeof(sfSample)), 0, sizeof(sfSample));
pdtaCk->AddChildChunk(shdrCk);
this->AddChildChunk(pdtaCk);

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -15,71 +36,44 @@ using namespace std;
//DLS.
// **********************************************************************************
SynthFile::SynthFile(Common::String synth_name) : name(synth_name) {}
SynthFile::SynthFile(Common::String synth_name) : _name(synth_name) {}
SynthFile::~SynthFile() {
DeleteVect(vInstrs);
DeleteVect(vWaves);
DeleteVect(_vInstrs);
DeleteVect(_vWaves);
}
SynthInstr *SynthFile::AddInstr(uint32 bank, uint32 instrNum) {
Common::String str = Common::String::format("Instr bnk%d num%d", bank, instrNum);
vInstrs.insert(vInstrs.end(), new SynthInstr(bank, instrNum, str));
return vInstrs.back();
_vInstrs.insert(_vInstrs.end(), new SynthInstr(bank, instrNum, str));
return _vInstrs.back();
}
SynthInstr *SynthFile::AddInstr(uint32 bank, uint32 instrNum, Common::String instrName) {
vInstrs.insert(vInstrs.end(), new SynthInstr(bank, instrNum, instrName));
return vInstrs.back();
}
void SynthFile::DeleteInstr(uint32 bank, uint32 instrNum) {}
SynthWave *SynthFile::AddWave(uint16 formatTag, uint16 channels, int samplesPerSec,
int aveBytesPerSec, uint16 blockAlign, uint16 bitsPerSample,
uint32 waveDataSize, unsigned char *waveData, Common::String WaveName) {
vWaves.insert(vWaves.end(),
new SynthWave(formatTag, channels, samplesPerSec, aveBytesPerSec, blockAlign,
_vWaves.insert(_vWaves.end(),
new SynthWave(formatTag, channels, samplesPerSec, aveBytesPerSec, blockAlign,
bitsPerSample, waveDataSize, waveData, WaveName));
return vWaves.back();
return _vWaves.back();
}
// **********
// SynthInstr
// **********
SynthInstr::SynthInstr(uint32 bank, uint32 instrument)
: ulBank(bank), ulInstrument(instrument) {
name = Common::String::format("Instr bnk %d num %d", bank, instrument);
// RiffFile::AlignName(name);
}
SynthInstr::SynthInstr(uint32 bank, uint32 instrument, Common::String instrName)
: ulBank(bank), ulInstrument(instrument), name(instrName) {
: _ulBank(bank), _ulInstrument(instrument), _name(instrName) {
// RiffFile::AlignName(name);
}
SynthInstr::SynthInstr(uint32 bank, uint32 instrument, Common::String instrName,
Common::Array<SynthRgn *> listRgns)
: ulBank(bank), ulInstrument(instrument), name(instrName) {
// RiffFile::AlignName(name);
vRgns = listRgns;
}
SynthInstr::~SynthInstr() {
DeleteVect(vRgns);
DeleteVect(_vRgns);
}
SynthRgn *SynthInstr::AddRgn(void) {
vRgns.insert(vRgns.end(), new SynthRgn());
return vRgns.back();
}
SynthRgn *SynthInstr::AddRgn(SynthRgn rgn) {
SynthRgn *newRgn = new SynthRgn();
*newRgn = rgn;
vRgns.insert(vRgns.end(), newRgn);
return vRgns.back();
_vRgns.insert(_vRgns.end(), new SynthRgn());
return _vRgns.back();
}
// ********
@ -87,35 +81,35 @@ SynthRgn *SynthInstr::AddRgn(SynthRgn rgn) {
// ********
SynthRgn::~SynthRgn(void) {
if (sampinfo)
delete sampinfo;
if (art)
delete art;
if (_sampinfo)
delete _sampinfo;
if (_art)
delete _art;
}
SynthArt *SynthRgn::AddArt(void) {
art = new SynthArt();
return art;
_art = new SynthArt();
return _art;
}
SynthSampInfo *SynthRgn::AddSampInfo(void) {
sampinfo = new SynthSampInfo();
return sampinfo;
_sampinfo = new SynthSampInfo();
return _sampinfo;
}
void SynthRgn::SetRanges(uint16 keyLow, uint16 keyHigh, uint16 velLow, uint16 velHigh) {
usKeyLow = keyLow;
usKeyHigh = keyHigh;
usVelLow = velLow;
usVelHigh = velHigh;
_usKeyLow = keyLow;
_usKeyHigh = keyHigh;
_usVelLow = velLow;
_usVelHigh = velHigh;
}
void SynthRgn::SetWaveLinkInfo(uint16 options, uint16 phaseGroup, uint32 theChannel,
uint32 theTableIndex) {
fusOptions = options;
usPhaseGroup = phaseGroup;
channel = theChannel;
tableIndex = theTableIndex;
_fusOptions = options;
_usPhaseGroup = phaseGroup;
_channel = theChannel;
_tableIndex = theTableIndex;
}
// ********
@ -127,17 +121,17 @@ SynthArt::~SynthArt() {
void SynthArt::AddADSR(double attack, Transform atk_transform, double decay, double sustain_level,
double sustain, double release, Transform rls_transform) {
this->attack_time = attack;
this->attack_transform = atk_transform;
this->decay_time = decay;
this->sustain_lev = sustain_level;
this->sustain_time = sustain;
this->release_time = release;
this->release_transform = rls_transform;
this->_attack_time = attack;
this->_attack_transform = atk_transform;
this->_decay_time = decay;
this->_sustain_lev = sustain_level;
this->_sustain_time = sustain;
this->_release_time = release;
this->_release_transform = rls_transform;
}
void SynthArt::AddPan(double thePan) {
this->pan = thePan;
this->_pan = thePan;
}
// *************
@ -145,28 +139,28 @@ void SynthArt::AddPan(double thePan) {
// *************
void SynthSampInfo::SetLoopInfo(Loop &loop, VGMSamp *samp) {
const int origFormatBytesPerSamp = samp->bps / 8;
const int origFormatBytesPerSamp = samp->_bps / 8;
double compressionRatio = samp->GetCompressionRatio();
// If the sample loops, but the loop length is 0, then assume the length should
// extend to the end of the sample.
if (loop.loopStatus && loop.loopLength == 0)
loop.loopLength = samp->dataLength - loop.loopStart;
loop.loopLength = samp->_dataLength - loop.loopStart;
cSampleLoops = loop.loopStatus;
ulLoopType = loop.loopType;
ulLoopStart = (loop.loopStartMeasure == LM_BYTES)
_cSampleLoops = loop.loopStatus;
_ulLoopType = loop.loopType;
_ulLoopStart = (loop.loopStartMeasure == LM_BYTES)
? (uint32) ((loop.loopStart * compressionRatio) / origFormatBytesPerSamp)
: loop.loopStart;
ulLoopLength = (loop.loopLengthMeasure == LM_BYTES)
_ulLoopLength = (loop.loopLengthMeasure == LM_BYTES)
? (uint32) ((loop.loopLength * compressionRatio) / origFormatBytesPerSamp)
: loop.loopLength;
}
void SynthSampInfo::SetPitchInfo(uint16 unityNote, short fineTune, double atten) {
usUnityNote = unityNote;
sFineTune = fineTune;
attenuation = atten;
_usUnityNote = unityNote;
_sFineTune = fineTune;
_attenuation = atten;
}
// *********
@ -174,26 +168,26 @@ void SynthSampInfo::SetPitchInfo(uint16 unityNote, short fineTune, double atten)
// *********
void SynthWave::ConvertTo16bitSigned() {
if (wBitsPerSample == 8) {
this->wBitsPerSample = 16;
this->wBlockAlign = 16 / 8 * this->wChannels;
this->dwAveBytesPerSec *= 2;
if (_wBitsPerSample == 8) {
this->_wBitsPerSample = 16;
this->_wBlockAlign = 16 / 8 * this->_wChannels;
this->_dwAveBytesPerSec *= 2;
int16 *newData = new int16[this->dataSize];
for (unsigned int i = 0; i < this->dataSize; i++)
newData[i] = ((int16) this->data[i] - 128) << 8;
delete[] this->data;
this->data = (uint8 *) newData;
this->dataSize *= 2;
int16 *newData = new int16[this->_dataSize];
for (unsigned int i = 0; i < this->_dataSize; i++)
newData[i] = ((int16) this->_data[i] - 128) << 8;
delete[] this->_data;
this->_data = (uint8 *) newData;
this->_dataSize *= 2;
}
}
SynthWave::~SynthWave() {
delete sampinfo;
delete[] data;
delete _sampinfo;
delete[] _data;
}
SynthSampInfo *SynthWave::AddSampInfo(void) {
sampinfo = new SynthSampInfo();
return sampinfo;
_sampinfo = new SynthSampInfo();
return _sampinfo;
}

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -18,7 +39,6 @@ class VGMSamp;
class SynthInstr;
class SynthRgn;
class SynthArt;
class SynthConnectionBlock;
class SynthSampInfo;
class SynthWave;
@ -33,81 +53,67 @@ public:
~SynthFile();
SynthInstr *AddInstr(uint32 bank, uint32 instrNum);
SynthInstr *AddInstr(uint32 bank, uint32 instrNum, Common::String Name);
void DeleteInstr(uint32 bank, uint32 instrNum);
SynthWave *AddWave(uint16 formatTag, uint16 channels, int samplesPerSec, int aveBytesPerSec,
uint16 blockAlign, uint16 bitsPerSample, uint32 waveDataSize,
uint8 *waveData, Common::String name = "Unnamed Wave");
void SetName(Common::String synth_name);
// int WriteDLSToBuffer(Common::Array<uint8> &buf);
// bool SaveDLSFile(const char* filepath);
public:
Common::Array<SynthInstr *> vInstrs;
Common::Array<SynthWave *> vWaves;
Common::String name;
Common::Array<SynthInstr *> _vInstrs;
Common::Array<SynthWave *> _vWaves;
Common::String _name;
};
class SynthInstr {
public:
SynthInstr(void);
SynthInstr(uint32 bank, uint32 instrument);
SynthInstr(uint32 bank, uint32 instrument, Common::String instrName);
SynthInstr(uint32 bank, uint32 instrument, Common::String instrName,
Common::Array<SynthRgn *> listRgns);
~SynthInstr(void);
void AddRgnList(Common::Array<SynthRgn> &RgnList);
SynthRgn *AddRgn(void);
SynthRgn *AddRgn(SynthRgn rgn);
public:
uint32 ulBank;
uint32 ulInstrument;
uint32 _ulBank;
uint32 _ulInstrument;
Common::Array<SynthRgn *> vRgns;
Common::String name;
Common::Array<SynthRgn *> _vRgns;
Common::String _name;
};
class SynthRgn {
public:
SynthRgn()
: usKeyLow(0),
usKeyHigh(0),
usVelLow(0),
usVelHigh(0),
sampinfo(NULL),
art(NULL),
fusOptions(0),
usPhaseGroup(0),
channel(0),
tableIndex(0) {}
: _usKeyLow(0),
_usKeyHigh(0),
_usVelLow(0),
_usVelHigh(0),
_sampinfo(NULL),
_art(NULL),
_fusOptions(0),
_usPhaseGroup(0),
_channel(0),
_tableIndex(0) {}
~SynthRgn();
SynthArt *AddArt(void);
SynthArt *AddArt(Common::Array<SynthConnectionBlock *> connBlocks);
SynthSampInfo *AddSampInfo(void);
SynthSampInfo *AddSampInfo(SynthSampInfo wsmp);
void SetRanges(uint16 keyLow = 0, uint16 keyHigh = 0x7F, uint16 velLow = 0,
uint16 velHigh = 0x7F);
void SetWaveLinkInfo(uint16 options, uint16 phaseGroup, uint32 theChannel,
uint32 theTableIndex);
public:
uint16 usKeyLow;
uint16 usKeyHigh;
uint16 usVelLow;
uint16 usVelHigh;
uint16 _usKeyLow;
uint16 _usKeyHigh;
uint16 _usVelLow;
uint16 _usVelHigh;
uint16 fusOptions;
uint16 usPhaseGroup;
uint32 channel;
uint32 tableIndex;
uint16 _fusOptions;
uint16 _usPhaseGroup;
uint32 _channel;
uint32 _tableIndex;
SynthSampInfo *sampinfo;
SynthArt *art;
SynthSampInfo *_sampinfo;
SynthArt *_art;
};
class SynthArt {
@ -119,18 +125,18 @@ public:
double sustain_time, double release_time, Transform rls_transform);
void AddPan(double pan);
double pan; // -100% = left channel 100% = right channel 0 = 50/50
double _pan; // -100% = left channel 100% = right channel 0 = 50/50
double attack_time; // rate expressed as seconds from 0 to 100% level
double decay_time; // rate expressed as seconds from 100% to 0% level, even though the sustain
double _attack_time; // rate expressed as seconds from 0 to 100% level
double _decay_time; // rate expressed as seconds from 100% to 0% level, even though the sustain
// level isn't necessarily 0%
double sustain_lev; // db of attenuation at sustain level
double sustain_time; // this is part of the PSX envelope (and can actually be positive), but is
double _sustain_lev; // db of attenuation at sustain level
double _sustain_time; // this is part of the PSX envelope (and can actually be positive), but is
// not in DLS or SF2. from 100 to 0, like release
double release_time; // rate expressed as seconds from 100% to 0% level, even though the
double _release_time; // rate expressed as seconds from 100% to 0% level, even though the
// sustain level may not be 100%
Transform attack_transform;
Transform release_transform;
Transform _attack_transform;
Transform _release_transform;
private:
};
@ -138,76 +144,63 @@ private:
class SynthSampInfo {
public:
SynthSampInfo() {}
SynthSampInfo(uint16 unityNote, int16 fineTune, double atten, int8 sampleLoops,
uint32 loopType, uint32 loopStart, uint32 loopLength)
: usUnityNote(unityNote),
sFineTune(fineTune),
attenuation(atten),
cSampleLoops(sampleLoops),
ulLoopType(loopType),
ulLoopStart(loopStart),
ulLoopLength(loopLength) {}
~SynthSampInfo() {}
void SetLoopInfo(Loop &loop, VGMSamp *samp);
// void SetPitchInfo(uint16 unityNote, int16 fineTune, double attenuation);
void SetPitchInfo(uint16 unityNote, int16 fineTune, double attenuation);
public:
uint16 usUnityNote;
int16 sFineTune;
double attenuation; // in decibels.
int8 cSampleLoops;
uint16 _usUnityNote;
int16 _sFineTune;
double _attenuation; // in decibels.
int8 _cSampleLoops;
uint32 ulLoopType;
uint32 ulLoopStart;
uint32 ulLoopLength;
uint32 _ulLoopType;
uint32 _ulLoopStart;
uint32 _ulLoopLength;
};
class SynthWave {
public:
SynthWave(void) : sampinfo(NULL), data(NULL), name("Untitled Wave") {
RiffFile::AlignName(name);
SynthWave(void) : _sampinfo(NULL), _data(NULL), _name("Untitled Wave") {
RiffFile::AlignName(_name);
}
SynthWave(uint16 formatTag, uint16 channels, int samplesPerSec, int aveBytesPerSec,
uint16 blockAlign, uint16 bitsPerSample, uint32 waveDataSize, uint8 *waveData,
Common::String waveName = "Untitled Wave")
: wFormatTag(formatTag),
wChannels(channels),
dwSamplesPerSec(samplesPerSec),
dwAveBytesPerSec(aveBytesPerSec),
wBlockAlign(blockAlign),
wBitsPerSample(bitsPerSample),
dataSize(waveDataSize),
data(waveData),
sampinfo(NULL),
name(waveName) {
RiffFile::AlignName(name);
: _wFormatTag(formatTag),
_wChannels(channels),
_dwSamplesPerSec(samplesPerSec),
_dwAveBytesPerSec(aveBytesPerSec),
_wBlockAlign(blockAlign),
_wBitsPerSample(bitsPerSample),
_dataSize(waveDataSize),
_data(waveData),
_sampinfo(NULL),
_name(waveName) {
RiffFile::AlignName(_name);
}
~SynthWave(void);
SynthSampInfo *AddSampInfo(void);
void ConvertTo16bitSigned();
public:
SynthSampInfo *sampinfo;
SynthSampInfo *_sampinfo;
uint16 wFormatTag;
uint16 wChannels;
uint32 dwSamplesPerSec;
uint32 dwAveBytesPerSec;
uint16 wBlockAlign;
uint16 wBitsPerSample;
uint16 _wFormatTag;
uint16 _wChannels;
uint32 _dwSamplesPerSec;
uint32 _dwAveBytesPerSec;
uint16 _wBlockAlign;
uint16 _wBitsPerSample;
uint32 dataSize;
uint8 *data;
uint32 _dataSize;
uint8 *_data;
Common::String name;
Common::String _name;
};
#endif // AUDIO_SOUNDFONT_SYNTHFILE_H

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -160,8 +181,8 @@ bool PSXSampColl::GetSampleInfo() {
PSXSamp *samp = new PSXSamp(this, beginOffset, i - beginOffset, beginOffset,
i - beginOffset - extraGunkLength, 1, 16, 44100,
Common::String::format("Sample %d", samples.size()));
samples.push_back(samp);
Common::String::format("Sample %d", _samples.size()));
_samples.push_back(samp);
} else {
break;
}
@ -190,7 +211,7 @@ bool PSXSampColl::GetSampleInfo() {
PSXSamp *samp = new PSXSamp(this, _dwOffset + it->offset, it->size,
_dwOffset + it->offset, offSampEnd - offSampStart, 1, 16,
44100, Common::String::format("Sample %d", sampleIndex));
samples.push_back(samp);
_samples.push_back(samp);
sampleIndex++;
}
}
@ -206,7 +227,7 @@ PSXSamp::PSXSamp(VGMSampColl *sampColl, uint32 offset, uint32 length, uint32 dat
Common::String name, bool bSetloopOnConversion)
: VGMSamp(sampColl, offset, length, dataOffset, dataLen, nChannels, theBPS, theRate, name),
_setLoopOnConversion(bSetloopOnConversion) {
bPSXLoopInfoPrioritizing = true;
_bPSXLoopInfoPrioritizing = true;
}
double PSXSamp::GetCompressionRatio() {
@ -223,7 +244,7 @@ void PSXSamp::ConvertToStdWave(uint8 *buf) {
SetLoopStatus(0); // loopStatus is initiated to -1. We should default it now to not loop
bool addrOutOfVirtFile = false;
for (uint32 k = 0; k < dataLength; k += 0x10) // for every adpcm chunk
for (uint32 k = 0; k < _dataLength; k += 0x10) // for every adpcm chunk
{
if (_dwOffset + k + 16 > _vgmfile->GetEndOffset()) {
debug("Unexpected EOF (%s)", _name.c_str());
@ -243,7 +264,7 @@ void PSXSamp::ConvertToStdWave(uint8 *buf) {
if (this->_setLoopOnConversion) {
if (theBlock.flag.loop) {
this->SetLoopOffset(k);
this->SetLoopLength(dataLength - k);
this->SetLoopLength(_dataLength - k);
}
if (theBlock.flag.end && theBlock.flag.looping) {
SetLoopStatus(1);

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -31,44 +52,44 @@ void VGMColl::UnpackSampColl(SynthFile &synthfile, VGMSampColl *sampColl,
Common::Array<VGMSamp *> &finalSamps) {
assert(sampColl != nullptr);
size_t nSamples = sampColl->samples.size();
size_t nSamples = sampColl->_samples.size();
for (size_t i = 0; i < nSamples; i++) {
VGMSamp *samp = sampColl->samples[i];
VGMSamp *samp = sampColl->_samples[i];
uint32 bufSize;
if (samp->ulUncompressedSize)
bufSize = samp->ulUncompressedSize;
if (samp->_ulUncompressedSize)
bufSize = samp->_ulUncompressedSize;
else
bufSize = (uint32) ceil((double) samp->dataLength * samp->GetCompressionRatio());
bufSize = (uint32) ceil((double) samp->_dataLength * samp->GetCompressionRatio());
uint8 *uncompSampBuf =
new uint8[bufSize]; // create a new memory space for the uncompressed wave
samp->ConvertToStdWave(uncompSampBuf); // and uncompress into that space
uint16 blockAlign = samp->bps / 8 * samp->channels;
uint16 blockAlign = samp->_bps / 8 * samp->_channels;
SynthWave *wave =
synthfile.AddWave(1, samp->channels, samp->rate, samp->rate * blockAlign, blockAlign,
samp->bps, bufSize, uncompSampBuf, (samp->_name));
synthfile.AddWave(1, samp->_channels, samp->_rate, samp->_rate * blockAlign, blockAlign,
samp->_bps, bufSize, uncompSampBuf, (samp->_name));
finalSamps.push_back(samp);
// If we don't have any loop information, then don't create a sampInfo structure for the
// Wave
if (samp->loop.loopStatus == -1) {
if (samp->_loop.loopStatus == -1) {
debug("No loop information for %s - some parameters might be incorrect",
samp->sampName.c_str());
samp->_sampName.c_str());
return;
}
SynthSampInfo *sampInfo = wave->AddSampInfo();
if (samp->bPSXLoopInfoPrioritizing) {
if (samp->loop.loopStart != 0 || samp->loop.loopLength != 0)
sampInfo->SetLoopInfo(samp->loop, samp);
if (samp->_bPSXLoopInfoPrioritizing) {
if (samp->_loop.loopStart != 0 || samp->_loop.loopLength != 0)
sampInfo->SetLoopInfo(samp->_loop, samp);
} else
sampInfo->SetLoopInfo(samp->loop, samp);
sampInfo->SetLoopInfo(samp->_loop, samp);
double attenuation = (samp->volume != -1) ? ConvertLogScaleValToAtten(samp->volume) : 0;
uint8 unityKey = (samp->unityKey != -1) ? samp->unityKey : 0x3C;
short fineTune = samp->fineTune;
double attenuation = (samp->_volume != -1) ? ConvertLogScaleValToAtten(samp->_volume) : 0;
uint8 unityKey = (samp->_unityKey != -1) ? samp->_unityKey : 0x3C;
short fineTune = samp->_fineTune;
sampInfo->SetPitchInfo(unityKey, fineTune, attenuation);
}
}
@ -156,7 +177,7 @@ SynthFile *VGMColl::CreateSynthFile(VGMInstrSet *theInstrSet) {
// now we add the number of samples from the preceding SampColls to the value to
// get the real sampNum in the final DLS file.
for (uint32 k = 0; k < sampCollNum; k++)
realSampNum += finalSampColls[k]->samples.size();
realSampNum += finalSampColls[k]->_samples.size();
SynthRgn *newRgn = newInstr->AddRgn();
newRgn->SetRanges(rgn->_keyLow, rgn->_keyHigh, rgn->_velLow, rgn->_velHigh);
@ -176,34 +197,32 @@ SynthFile *VGMColl::CreateSynthFile(VGMInstrSet *theInstrSet) {
// loopStatus to determine if a loop occurs. If it does, see if the sample provides
// loop info (gathered during ADPCM > PCM conversion. If the sample doesn't provide
// loop offset info, then use the region's loop info.
if (samp->bPSXLoopInfoPrioritizing) {
if (samp->loop.loopStatus != -1) {
if (samp->loop.loopStart != 0 || samp->loop.loopLength != 0)
sampInfo->SetLoopInfo(samp->loop, samp);
if (samp->_bPSXLoopInfoPrioritizing) {
if (samp->_loop.loopStatus != -1) {
if (samp->_loop.loopStart != 0 || samp->_loop.loopLength != 0)
sampInfo->SetLoopInfo(samp->_loop, samp);
else {
rgn->_loop.loopStatus = samp->loop.loopStatus;
rgn->_loop.loopStatus = samp->_loop.loopStatus;
sampInfo->SetLoopInfo(rgn->_loop, samp);
}
} else {
delete synthfile;
error("argh"); //TODO
error("_bPSXLoopInfoPrioritizing: Invalid sample loop status");
}
}
// The normal method: First, we check if the rgn has loop info defined.
// If it doesn't, then use the sample's loop info.
else if (rgn->_loop.loopStatus == -1) {
if (samp->loop.loopStatus != -1)
sampInfo->SetLoopInfo(samp->loop, samp);
if (samp->_loop.loopStatus != -1)
sampInfo->SetLoopInfo(samp->_loop, samp);
else {
delete synthfile;
error("argh2"); //TODO
error("Invalid sample loop status");
}
} else
sampInfo->SetLoopInfo(rgn->_loop, samp);
int8 realUnityKey = -1;
if (rgn->_unityKey == -1)
realUnityKey = samp->unityKey;
realUnityKey = samp->_unityKey;
else
realUnityKey = rgn->_unityKey;
if (realUnityKey == -1)
@ -211,15 +230,15 @@ SynthFile *VGMColl::CreateSynthFile(VGMInstrSet *theInstrSet) {
short realFineTune;
if (rgn->_fineTune == 0)
realFineTune = samp->fineTune;
realFineTune = samp->_fineTune;
else
realFineTune = rgn->_fineTune;
double attenuation;
if (rgn->_volume != -1)
attenuation = ConvertLogScaleValToAtten(rgn->_volume);
else if (samp->volume != -1)
attenuation = ConvertLogScaleValToAtten(samp->volume);
else if (samp->_volume != -1)
attenuation = ConvertLogScaleValToAtten(samp->_volume);
else
attenuation = 0;

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -13,22 +34,21 @@
VGMSamp::VGMSamp(VGMSampColl *sampColl, uint32 offset, uint32 length, uint32 dataOffset,
uint32 dataLen, uint8 nChannels, uint16 theBPS, uint32 theRate,
Common::String theName)
: parSampColl(sampColl),
sampName(theName),
: _parSampColl(sampColl),
_sampName(theName),
VGMItem(sampColl->_vgmfile, offset, length),
dataOff(dataOffset),
dataLength(dataLen),
bps(theBPS),
rate(theRate),
ulUncompressedSize(0),
channels(nChannels),
pan(0),
unityKey(-1),
fineTune(0),
volume(-1),
waveType(WT_UNDEFINED),
bPSXLoopInfoPrioritizing(false) {
_name = sampName; // I would do this in the initialization list, but VGMItem()
_dataOff(dataOffset),
_dataLength(dataLen),
_bps(theBPS),
_rate(theRate),
_ulUncompressedSize(0),
_channels(nChannels),
_unityKey(-1),
_fineTune(0),
_volume(-1),
_waveType(WT_UNDEFINED),
_bPSXLoopInfoPrioritizing(false) {
_name = _sampName; // I would do this in the initialization list, but VGMItem()
// constructor is called before sampName is initialized,
// so data() ends up returning a bad pointer
}
@ -46,38 +66,38 @@ double VGMSamp::GetCompressionRatio() {
VGMSampColl::VGMSampColl(RawFile *rawfile, uint32 offset, uint32 length,
Common::String theName)
: VGMFile(rawfile, offset, length, theName),
parInstrSet(NULL),
bLoaded(false),
sampDataOffset(0) {
AddContainer<VGMSamp>(samples);
_parInstrSet(NULL),
_bLoaded(false),
_sampDataOffset(0) {
AddContainer<VGMSamp>(_samples);
}
VGMSampColl::VGMSampColl(RawFile *rawfile, VGMInstrSet *instrset,
uint32 offset, uint32 length, Common::String theName)
: VGMFile(rawfile, offset, length, theName),
parInstrSet(instrset),
bLoaded(false),
sampDataOffset(0) {
AddContainer<VGMSamp>(samples);
_parInstrSet(instrset),
_bLoaded(false),
_sampDataOffset(0) {
AddContainer<VGMSamp>(_samples);
}
VGMSampColl::~VGMSampColl(void) {
DeleteVect<VGMSamp>(samples);
DeleteVect<VGMSamp>(_samples);
}
bool VGMSampColl::Load() {
if (bLoaded)
if (_bLoaded)
return true;
if (!GetHeaderInfo())
return false;
if (!GetSampleInfo())
return false;
if (samples.size() == 0)
if (_samples.size() == 0)
return false;
if (_unLength == 0) {
for (Common::Array<VGMSamp *>::iterator itr = samples.begin(); itr != samples.end(); ++itr) {
for (Common::Array<VGMSamp *>::iterator itr = _samples.begin(); itr != _samples.end(); ++itr) {
VGMSamp *samp = (*itr);
// Some formats can have negative sample offset
@ -97,6 +117,6 @@ bool VGMSampColl::Load() {
}
}
bLoaded = true;
_bLoaded = true;
return true;
}

View File

@ -1,3 +1,24 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/*
* VGMTrans (c) 2002-2019
* Licensed under the zlib license,
@ -30,30 +51,28 @@ public:
// used to calculate both uncompressed sample size and loopOff after conversion
virtual void ConvertToStdWave(uint8 *buf) {};
inline void SetLoopStatus(int loopStat) { loop.loopStatus = loopStat; }
inline void SetLoopOffset(uint32 loopStart) { loop.loopStart = loopStart; }
inline void SetLoopLength(uint32 theLoopLength) { loop.loopLength = theLoopLength; }
inline void SetLoopStatus(int loopStat) { _loop.loopStatus = loopStat; }
inline void SetLoopOffset(uint32 loopStart) { _loop.loopStart = loopStart; }
inline void SetLoopLength(uint32 theLoopLength) { _loop.loopLength = theLoopLength; }
public:
WAVE_TYPE waveType;
uint32 dataOff; // offset of original sample data
uint32 dataLength;
uint16 bps; // bits per sample
uint32 rate; // sample rate in herz (samples per second)
uint8 channels; // mono or stereo?
uint32 ulUncompressedSize;
WAVE_TYPE _waveType;
uint32 _dataOff; // offset of original sample data
uint32 _dataLength;
uint16 _bps; // bits per sample
uint32 _rate; // sample rate in herz (samples per second)
uint8 _channels; // mono or stereo?
uint32 _ulUncompressedSize;
bool bPSXLoopInfoPrioritizing;
Loop loop;
bool _bPSXLoopInfoPrioritizing;
Loop _loop;
int8 unityKey;
short fineTune;
double volume; // as percent of full volume. This will be converted to attenuation for SynthFile
int8 _unityKey;
short _fineTune;
double _volume; // as percent of full volume. This will be converted to attenuation for SynthFile
long pan;
VGMSampColl *parSampColl;
Common::String sampName;
VGMSampColl *_parSampColl;
Common::String _sampName;
};
class VGMSampColl : public VGMFile {
@ -71,12 +90,12 @@ public:
protected:
public:
bool bLoaded;
bool _bLoaded;
uint32 sampDataOffset; // offset of the beginning of the sample data. Used for
uint32 _sampDataOffset; // offset of the beginning of the sample data. Used for
// rgn->sampOffset matching
VGMInstrSet *parInstrSet;
Common::Array<VGMSamp *> samples;
VGMInstrSet *_parInstrSet;
Common::Array<VGMSamp *> _samples;
};
#endif // AUDIO_SOUNDFONT_VGMSAMP_H