2022-02-15 03:12:20 +00:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
|
|
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2021-12-15 19:15:44 +00:00
|
|
|
#include "../ta-utils.h"
|
|
|
|
|
2021-05-11 20:08:08 +00:00
|
|
|
struct DivSample {
|
|
|
|
String name;
|
2022-02-24 08:57:45 +00:00
|
|
|
int rate, centerRate, loopStart, loopOffP;
|
2022-02-03 04:17:16 +00:00
|
|
|
// valid values are:
|
2022-02-24 03:00:12 +00:00
|
|
|
// - 0: ZX Spectrum overlay drum (1-bit)
|
|
|
|
// - 1: 1-bit NES DPCM (1-bit)
|
2022-02-24 08:57:45 +00:00
|
|
|
// - 4: QSound ADPCM
|
2022-02-24 03:00:12 +00:00
|
|
|
// - 5: ADPCM-A
|
|
|
|
// - 6: ADPCM-B
|
|
|
|
// - 7: X68000 ADPCM
|
2022-02-03 04:17:16 +00:00
|
|
|
// - 8: 8-bit PCM
|
2022-02-24 03:00:12 +00:00
|
|
|
// - 9: BRR (SNES)
|
|
|
|
// - 10: VOX
|
2022-02-03 04:17:16 +00:00
|
|
|
// - 16: 16-bit PCM
|
2021-05-11 20:26:38 +00:00
|
|
|
unsigned char depth;
|
2022-02-24 03:00:12 +00:00
|
|
|
|
|
|
|
// these are the new data structures.
|
2022-02-24 08:57:45 +00:00
|
|
|
signed char* data8; // 8
|
|
|
|
short* data16; // 16
|
|
|
|
unsigned char* data1; // 0
|
|
|
|
unsigned char* dataDPCM; // 1
|
|
|
|
unsigned char* dataQSoundA; // 4
|
|
|
|
unsigned char* dataA; // 5
|
|
|
|
unsigned char* dataB; // 6
|
|
|
|
unsigned char* dataX68; // 7
|
|
|
|
unsigned char* dataBRR; // 9
|
|
|
|
unsigned char* dataVOX; // 10
|
2022-02-24 03:00:12 +00:00
|
|
|
|
2022-02-24 08:57:45 +00:00
|
|
|
unsigned int length8, length16, length1, lengthDPCM, lengthQSoundA, lengthA, lengthB, lengthX68, lengthBRR, lengthVOX;
|
|
|
|
unsigned int off8, off16, off1, offDPCM, offQSoundA, offA, offB, offX68, offBRR, offVOX;
|
2022-03-06 17:31:03 +00:00
|
|
|
unsigned int offSegaPCM, offQSound, offX1_010;
|
2022-02-24 03:00:12 +00:00
|
|
|
|
2022-02-24 08:57:45 +00:00
|
|
|
unsigned int samples;
|
2021-05-13 07:39:26 +00:00
|
|
|
|
2022-03-16 03:05:55 +00:00
|
|
|
/**
|
|
|
|
* save this sample to a file.
|
|
|
|
* @param path a path.
|
|
|
|
* @return whether saving succeeded or not.
|
|
|
|
*/
|
2021-12-18 06:03:59 +00:00
|
|
|
bool save(const char* path);
|
2022-03-16 03:05:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @warning DO NOT USE - internal function
|
|
|
|
* initialize sample data.
|
|
|
|
* @param d sample type.
|
|
|
|
* @param count number of samples.
|
|
|
|
* @return whether it was successful.
|
|
|
|
*/
|
2022-02-24 08:57:45 +00:00
|
|
|
bool initInternal(unsigned char d, int count);
|
2022-03-16 03:05:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* initialize sample data. make sure you have set `depth` before doing so.
|
|
|
|
* @param count number of samples.
|
|
|
|
* @return whether it was successful.
|
|
|
|
*/
|
2022-02-24 08:57:45 +00:00
|
|
|
bool init(unsigned int count);
|
2022-03-16 03:05:55 +00:00
|
|
|
|
2022-03-19 08:42:44 +00:00
|
|
|
/**
|
|
|
|
* resize sample data. make sure the sample has been initialized before doing so.
|
|
|
|
* @warning do not attempt to resize a sample outside of a synchronized block!
|
|
|
|
* @param count number of samples.
|
|
|
|
* @return whether it was successful.
|
|
|
|
*/
|
|
|
|
bool resize(unsigned int count);
|
|
|
|
|
2022-03-16 03:05:55 +00:00
|
|
|
/**
|
|
|
|
* initialize the rest of sample formats for this sample.
|
|
|
|
*/
|
2022-02-24 08:57:45 +00:00
|
|
|
void render();
|
2022-03-16 03:05:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the sample data for the current depth.
|
|
|
|
* @return the sample data, or NULL if not created.
|
|
|
|
*/
|
2022-02-24 08:57:45 +00:00
|
|
|
void* getCurBuf();
|
2022-03-16 03:05:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get the sample data length for the current depth.
|
|
|
|
* @return the sample data length.
|
|
|
|
*/
|
2022-02-24 08:57:45 +00:00
|
|
|
unsigned int getCurBufLen();
|
2021-05-13 07:39:26 +00:00
|
|
|
DivSample():
|
|
|
|
name(""),
|
2021-12-23 23:04:44 +00:00
|
|
|
rate(32000),
|
2022-01-27 21:52:06 +00:00
|
|
|
centerRate(8363),
|
2022-01-15 22:54:21 +00:00
|
|
|
loopStart(-1),
|
2022-01-24 22:13:47 +00:00
|
|
|
loopOffP(0),
|
2021-05-13 07:39:26 +00:00
|
|
|
depth(16),
|
2022-02-24 08:57:45 +00:00
|
|
|
data8(NULL),
|
|
|
|
data16(NULL),
|
|
|
|
data1(NULL),
|
|
|
|
dataDPCM(NULL),
|
|
|
|
dataQSoundA(NULL),
|
|
|
|
dataA(NULL),
|
|
|
|
dataB(NULL),
|
|
|
|
dataX68(NULL),
|
|
|
|
dataBRR(NULL),
|
|
|
|
dataVOX(NULL),
|
|
|
|
length8(0),
|
|
|
|
length16(0),
|
|
|
|
length1(0),
|
|
|
|
lengthDPCM(0),
|
|
|
|
lengthQSoundA(0),
|
|
|
|
lengthA(0),
|
|
|
|
lengthB(0),
|
|
|
|
lengthX68(0),
|
|
|
|
lengthBRR(0),
|
|
|
|
lengthVOX(0),
|
|
|
|
off8(0),
|
|
|
|
off16(0),
|
|
|
|
off1(0),
|
|
|
|
offDPCM(0),
|
|
|
|
offQSoundA(0),
|
|
|
|
offA(0),
|
|
|
|
offB(0),
|
|
|
|
offX68(0),
|
|
|
|
offBRR(0),
|
|
|
|
offVOX(0),
|
|
|
|
offSegaPCM(0),
|
|
|
|
offQSound(0),
|
|
|
|
samples(0) {}
|
2021-12-15 19:15:44 +00:00
|
|
|
~DivSample();
|
2021-05-11 20:08:08 +00:00
|
|
|
};
|