mirror of
https://github.com/holub/mame
synced 2025-06-07 13:23:50 +03:00
Fix MT4696 - 8-bit sample reading was broken
This commit is contained in:
parent
fe763516ae
commit
8cf5580b11
@ -455,7 +455,6 @@ bool samples_device::read_sample(emu_file &file, loaded_sample &sample)
|
|||||||
|
|
||||||
bool samples_device::read_wav_sample(emu_file &file, loaded_sample &sample)
|
bool samples_device::read_wav_sample(emu_file &file, loaded_sample &sample)
|
||||||
{
|
{
|
||||||
printf("Reading %s as WAV\n", file.filename());
|
|
||||||
// we already read the opening 'WAVE' header
|
// we already read the opening 'WAVE' header
|
||||||
UINT32 offset = 4;
|
UINT32 offset = 4;
|
||||||
|
|
||||||
@ -544,23 +543,24 @@ printf("Reading %s as WAV\n", file.filename());
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// fill in the sample data
|
// fill in the sample data
|
||||||
sample.length = length / 2;
|
|
||||||
sample.frequency = rate;
|
sample.frequency = rate;
|
||||||
|
|
||||||
// read the data in
|
// read the data in
|
||||||
if (bits == 8)
|
if (bits == 8)
|
||||||
{
|
{
|
||||||
|
sample.length = length;
|
||||||
sample.data.resize(length);
|
sample.data.resize(length);
|
||||||
file.read(sample.data, length);
|
file.read(sample.data, length);
|
||||||
|
|
||||||
// convert 8-bit data to signed samples
|
// convert 8-bit data to signed samples
|
||||||
UINT8 *tempptr = reinterpret_cast<UINT8 *>(&sample.data[0]);
|
UINT8 *tempptr = reinterpret_cast<UINT8 *>(&sample.data[0]);
|
||||||
for (UINT32 sindex = length - 1; sindex >= 0; sindex--)
|
for (INT32 sindex = length - 1; sindex >= 0; sindex--)
|
||||||
sample.data[sindex] = INT8(tempptr[sindex] ^ 0x80) * 256;
|
sample.data[sindex] = INT8(tempptr[sindex] ^ 0x80) * 256;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 16-bit data is fine as-is
|
// 16-bit data is fine as-is
|
||||||
|
sample.length = length / 2;
|
||||||
sample.data.resize(length / 2);
|
sample.data.resize(length / 2);
|
||||||
file.read(sample.data, length);
|
file.read(sample.data, length);
|
||||||
|
|
||||||
@ -579,7 +579,6 @@ printf("Reading %s as WAV\n", file.filename());
|
|||||||
|
|
||||||
bool samples_device::read_flac_sample(emu_file &file, loaded_sample &sample)
|
bool samples_device::read_flac_sample(emu_file &file, loaded_sample &sample)
|
||||||
{
|
{
|
||||||
printf("Reading %s as FLAC\n", file.filename());
|
|
||||||
// seek back to the start of the file
|
// seek back to the start of the file
|
||||||
file.seek(0, SEEK_SET);
|
file.seek(0, SEEK_SET);
|
||||||
|
|
||||||
@ -628,7 +627,6 @@ void samples_device::load_samples()
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (const char *samplename = iter.first(); samplename != NULL; index++, samplename = iter.next())
|
for (const char *samplename = iter.first(); samplename != NULL; index++, samplename = iter.next())
|
||||||
{
|
{
|
||||||
printf("Sample %d = %s\n", index, samplename);
|
|
||||||
// attempt to open as FLAC first
|
// attempt to open as FLAC first
|
||||||
emu_file file(machine().options().sample_path(), OPEN_FLAG_READ);
|
emu_file file(machine().options().sample_path(), OPEN_FLAG_READ);
|
||||||
file_error filerr = file.open(basename, PATH_SEPARATOR, samplename, ".flac");
|
file_error filerr = file.open(basename, PATH_SEPARATOR, samplename, ".flac");
|
||||||
|
Loading…
Reference in New Issue
Block a user