diff --git a/src/emu/audit.c b/src/emu/audit.c index d1a07aea607..dfe9e7a0500 100644 --- a/src/emu/audit.c +++ b/src/emu/audit.c @@ -236,54 +236,40 @@ media_auditor::summary media_auditor::audit_samples() samples_device_iterator iter(m_enumerator.config().root_device()); for (samples_device *device = iter.first(); device != NULL; device = iter.next()) { - const samples_interface *intf = reinterpret_cast(device->static_config()); - if (intf->samplenames != NULL) + // by default we just search using the driver name + astring searchpath(m_enumerator.driver().name); + + // add the alternate path if present + samples_iterator iter(*device); + if (iter.altbasename() != NULL) + searchpath.cat(";").cat(iter.altbasename()); + + // iterate over samples in this entry + for (const char *samplename = iter.first(); samplename != NULL; samplename = iter.next()) { - // by default we just search using the driver name - astring searchpath(m_enumerator.driver().name); + required++; - // iterate over samples in this entry - for (int sampnum = 0; intf->samplenames[sampnum] != NULL; sampnum++) + // create a new record + audit_record &record = m_record_list.append(*global_alloc(audit_record(samplename, audit_record::MEDIA_SAMPLE))); + + // look for the files + emu_file file(m_enumerator.options().sample_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD); + path_iterator path(searchpath); + astring curpath; + while (path.next(curpath, samplename)) { - // starred entries indicate an additional searchpath - if (intf->samplenames[sampnum][0] == '*') + // attempt to access the file (.flac) or (.wav) + file_error filerr = file.open(curpath, ".flac"); + if (filerr != FILERR_NONE) + filerr = file.open(curpath, ".wav"); + + if (filerr == FILERR_NONE) { - searchpath.cat(";").cat(&intf->samplenames[sampnum][1]); - continue; - } - - required++; - - // create a new record - audit_record &record = m_record_list.append(*global_alloc(audit_record(intf->samplenames[sampnum], audit_record::MEDIA_SAMPLE))); - - // look for the files - emu_file file(m_enumerator.options().sample_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD); - path_iterator path(searchpath); - astring curpath; - while (path.next(curpath, intf->samplenames[sampnum])) - { - astring wholepath; - wholepath = curpath + ".flac"; - - // attempt to access the file (.flac) - file_error filerr = file.open(wholepath); - - if (filerr != FILERR_NONE) - { - wholepath = curpath + ".wav"; - // try again with .wav - filerr = file.open(wholepath); - } - - if (filerr == FILERR_NONE) - { - record.set_status(audit_record::STATUS_GOOD, audit_record::SUBSTATUS_GOOD); - found++; - } - else - record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND); + record.set_status(audit_record::STATUS_GOOD, audit_record::SUBSTATUS_GOOD); + found++; } + else + record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND); } } } diff --git a/src/emu/clifront.c b/src/emu/clifront.c index 2e6b784d11f..3d080c6945f 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -567,15 +567,12 @@ void cli_frontend::listsamples(const char *gamename) first = false; mame_printf_info("Samples required for driver \"%s\".\n", drivlist.driver().name); - // iterate over samples devices + // iterate over samples devices and print the samples from each one for (samples_device *device = iter.first(); device != NULL; device = iter.next()) { - // if the list is legit, walk it and print the sample info - const char *const *samplenames = reinterpret_cast(device->static_config())->samplenames; - if (samplenames != NULL) - for (int sampnum = 0; samplenames[sampnum] != NULL; sampnum++) - if (samplenames[sampnum][0] != '*') - mame_printf_info("%s\n", samplenames[sampnum]); + samples_iterator sampiter(*device); + for (const char *samplename = sampiter.first(); samplename != NULL; samplename = sampiter.next()) + mame_printf_info("%s\n", samplename); } } } diff --git a/src/emu/emu.h b/src/emu/emu.h index 1d9335dc374..1ff548835d4 100644 --- a/src/emu/emu.h +++ b/src/emu/emu.h @@ -67,7 +67,6 @@ #include "hash.h" #include "fileio.h" // remove me once NVRAM is implemented as device #include "delegate.h" -//#include "cothread.h" // memory and address spaces #include "memory.h" diff --git a/src/emu/info.c b/src/emu/info.c index 462dc594c0c..a35474f1e52 100644 --- a/src/emu/info.c +++ b/src/emu/info.c @@ -410,20 +410,14 @@ void info_xml_creator::output_sampleof() samples_device_iterator iter(m_drivlist.config().root_device()); for (samples_device *device = iter.first(); device != NULL; device = iter.next()) { - const char *const *samplenames = ((const samples_interface *)device->static_config())->samplenames; - if (samplenames != NULL) + samples_iterator sampiter(*device); + if (sampiter.altbasename() != NULL) + { + fprintf(m_output, " sampleof=\"%s\"", xml_normalize_string(sampiter.altbasename())); - // iterate over sample names - for (int sampnum = 0; samplenames[sampnum] != NULL; sampnum++) - { - // only output sampleof if different from the game name - const char *cursampname = samplenames[sampnum]; - if (cursampname[0] == '*' && strcmp(cursampname + 1, m_drivlist.driver().name) != 0) - fprintf(m_output, " sampleof=\"%s\"", xml_normalize_string(cursampname + 1)); - - // must stop here, as there can only be one attribute of the same name - return; - } + // must stop here, as there can only be one attribute of the same name + return; + } } } @@ -563,30 +557,19 @@ void info_xml_creator::output_sample() { // iterate over sample devices samples_device_iterator iter(m_drivlist.config().root_device()); - for (const device_t *device = iter.first(); device != NULL; device = iter.next()) + for (samples_device *device = iter.first(); device != NULL; device = iter.next()) { - const char *const *samplenames = ((const samples_interface *)device->static_config())->samplenames; - if (samplenames != NULL) + samples_iterator sampiter(*device); + tagmap_t already_printed; + for (const char *samplename = sampiter.first(); samplename != NULL; samplename = sampiter.next()) + { + // filter out duplicates + if (already_printed.add(samplename, 1) == TMERR_DUPLICATE) + continue; - // iterate over sample names - for (int sampnum = 0; samplenames[sampnum] != NULL; sampnum++) - { - // ignore the special '*' samplename - const char *cursampname = samplenames[sampnum]; - if (sampnum == 0 && cursampname[0] == '*') - continue; - - // filter m_output duplicates - int dupnum; - for (dupnum = 0; dupnum < sampnum; dupnum++) - if (strcmp(samplenames[dupnum], cursampname) == 0) - break; - if (dupnum < sampnum) - continue; - - // output the sample name - fprintf(m_output, "\t\t\n", xml_normalize_string(cursampname)); - } + // output the sample name + fprintf(m_output, "\t\t\n", xml_normalize_string(samplename)); + } } } diff --git a/src/emu/sound/samples.c b/src/emu/sound/samples.c index 63f67cdbffa..c5aeffaf518 100644 --- a/src/emu/sound/samples.c +++ b/src/emu/sound/samples.c @@ -1,755 +1,650 @@ -/* samples.c +/*************************************************************************** - Playback of pre-recorded samples. Used for high-level simulation of discrete sound circuits - where proper low-level simulation isn't available. Also used for tape loops and similar. + samples.c - Current limitations - - Only supports single channel samples! + Sound device for sample playback. - Considerations - - Maybe this should be part of the presentation layer (artwork etc.) with samples specified - in .lay files instead of in drivers? +**************************************************************************** -*/ + Playback of pre-recorded samples. Used for high-level simulation of + discrete sound circuits where proper low-level simulation isn't + available. Also used for tape loops and similar. + Current limitations + - Only supports single channel samples! + + Considerations + - Maybe this should be part of the presentation layer + (artwork etc.) with samples specified in .lay files instead of + in drivers? + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ #include "emu.h" #include "emuopts.h" #include "samples.h" -#include "../../lib/libflac/include/flac/all.h" +#include "flac.h" -typedef struct _sample_channel sample_channel; -struct _sample_channel + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// device type definition +const device_type SAMPLES = &device_creator; + + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// samples_device - constructors +//------------------------------------------------- + +samples_device::samples_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, SAMPLES, "Samples", tag, owner, clock), + device_sound_interface(mconfig, *this) { - sound_stream *stream; - const INT16 *source; - INT32 source_length; - INT32 source_num; - UINT32 pos; - UINT32 frac; - UINT32 step; - UINT32 basefreq; - UINT8 loop; - UINT8 paused; -}; +} - -typedef struct _samples_info samples_info; -struct _samples_info +samples_device::samples_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) + : device_t(mconfig, type, name, tag, owner, clock), + device_sound_interface(mconfig, *this) { - device_t *device; - int numchannels; /* how many channels */ - sample_channel *channel;/* array of channels */ - loaded_samples *samples;/* array of samples */ -}; +} -INLINE samples_info *get_safe_token(device_t *device) +//------------------------------------------------- +// static_set_interface - configuration helper +// to set the interface +//------------------------------------------------- + +void samples_device::static_set_interface(device_t &device, const samples_interface &interface) { - assert(device != NULL); - assert(device->type() == SAMPLES); - return (samples_info *)downcast(device)->token(); + samples_device &samples = downcast(device); + static_cast(samples) = interface; } -#define FRAC_BITS 24 -#define FRAC_ONE (1 << FRAC_BITS) -#define FRAC_MASK (FRAC_ONE - 1) -#define MAX_CHANNELS 100 +//************************************************************************** +// PUBLIC INTERFACE +//************************************************************************** -struct flac_reader +//------------------------------------------------- +// start - start playing a loaded sample +//------------------------------------------------- + +void samples_device::start(UINT8 channel, UINT32 samplenum, bool loop) { - UINT8* rawdata; - INT16* write_data; - int position; - int length; - int decoded_size; - int sample_rate; - int channels; - int bits_per_sample; - int total_samples; - int write_position; -} flacread; - -static flac_reader* flacreadptr; - -void my_error_callback(const FLAC__StreamDecoder * decoder, FLAC__StreamDecoderErrorStatus status, void * client_data) -{ - fatalerror("FLAC error Callback\n"); -} - -void my_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) -{ - - flac_reader* flacrd = ((flac_reader*)client_data); - - if (metadata->type==0) - { - const FLAC__StreamMetadata_StreamInfo *streaminfo = &(metadata->data.stream_info); - - flacrd->sample_rate = streaminfo->sample_rate; - flacrd->channels = streaminfo->channels; - flacrd->bits_per_sample = streaminfo->bits_per_sample; - flacrd->total_samples = streaminfo->total_samples; - } -} - - - - -FLAC__StreamDecoderReadStatus my_read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) -{ - flac_reader* flacrd = ((flac_reader*)client_data); - - if(*bytes > 0) - { - if (*bytes <= flacrd->length) - { - memcpy(buffer, flacrd->rawdata+flacrd->position, *bytes); - flacrd->position+=*bytes; - flacrd->length-=*bytes; - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - else - { - memcpy(buffer, flacrd->rawdata+flacrd->position, flacrd->length); - flacrd->position+= flacrd->length; - flacrd->length = 0; - - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - } - else - { - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - - if ( flacrd->length==0) - { - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } - - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - -} - -FLAC__StreamDecoderWriteStatus my_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 *const buffer[], void *client_data) -{ - flac_reader* flacrd = ((flac_reader*)client_data); - - flacrd->decoded_size += frame->header.blocksize; - - for (int i=0;iheader.blocksize;i++) - { - flacrd->write_data[i+flacrd->write_position] = buffer[0][i]; - } - - flacrd->write_position += frame->header.blocksize; - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - - - - - - -/*------------------------------------------------- - read_wav_sample - read a WAV file as a sample --------------------------------------------------*/ - -static int read_wav_sample(running_machine &machine, emu_file &file, loaded_sample *sample, char* filename) -{ - unsigned long offset = 0; - UINT32 length, rate, filesize; - UINT16 bits, temp16; - char buf[32]; - UINT32 sindex; - int type = 0; - - /* read the core header and make sure it's a WAVE file */ - offset += file.read(buf, 4); - if (offset < 4) - { - mame_printf_warning("unable to read %s, 0-byte file?\n", filename); - return 0; - } - if (memcmp(&buf[0], "RIFF", 4) == 0) - type = 1; - else if (memcmp(&buf[0], "fLaC", 4) == 0) - type = 2; - else - { - mame_printf_warning("unable to read %s, corrupt file?\n", filename); - return 0; - } - - if (type==1) - { - /* get the total size */ - offset += file.read(&filesize, 4); - if (offset < 8) - return 0; - filesize = LITTLE_ENDIANIZE_INT32(filesize); - - /* read the RIFF file type and make sure it's a WAVE file */ - offset += file.read(buf, 4); - if (offset < 12) - return 0; - if (memcmp(&buf[0], "WAVE", 4) != 0) - return 0; - - /* seek until we find a format tag */ - while (1) - { - offset += file.read(buf, 4); - offset += file.read(&length, 4); - length = LITTLE_ENDIANIZE_INT32(length); - if (memcmp(&buf[0], "fmt ", 4) == 0) - break; - - /* seek to the next block */ - file.seek(length, SEEK_CUR); - offset += length; - if (offset >= filesize) - return 0; - } - - /* read the format -- make sure it is PCM */ - offset += file.read(&temp16, 2); - temp16 = LITTLE_ENDIANIZE_INT16(temp16); - if (temp16 != 1) - return 0; - - /* number of channels -- only mono is supported */ - offset += file.read(&temp16, 2); - temp16 = LITTLE_ENDIANIZE_INT16(temp16); - if (temp16 != 1) - return 0; - - /* sample rate */ - offset += file.read(&rate, 4); - rate = LITTLE_ENDIANIZE_INT32(rate); - - /* bytes/second and block alignment are ignored */ - offset += file.read(buf, 6); - - /* bits/sample */ - offset += file.read(&bits, 2); - bits = LITTLE_ENDIANIZE_INT16(bits); - if (bits != 8 && bits != 16) - return 0; - - /* seek past any extra data */ - file.seek(length - 16, SEEK_CUR); - offset += length - 16; - - /* seek until we find a data tag */ - while (1) - { - offset += file.read(buf, 4); - offset += file.read(&length, 4); - length = LITTLE_ENDIANIZE_INT32(length); - if (memcmp(&buf[0], "data", 4) == 0) - break; - - /* seek to the next block */ - file.seek(length, SEEK_CUR); - offset += length; - if (offset >= filesize) - return 0; - } - - /* if there was a 0 length data block, we're done */ - if (length == 0) - return 0; - - /* fill in the sample data */ - sample->length = length; - sample->frequency = rate; - - /* read the data in */ - if (bits == 8) - { - unsigned char *tempptr; - int sindex; - - sample->data = auto_alloc_array(machine, INT16, length); - file.read(sample->data, length); - - /* convert 8-bit data to signed samples */ - tempptr = (unsigned char *)sample->data; - for (sindex = length - 1; sindex >= 0; sindex--) - sample->data[sindex] = (INT8)(tempptr[sindex] ^ 0x80) * 256; - - } - else - { - /* 16-bit data is fine as-is */ - sample->data = auto_alloc_array(machine, INT16, length/2); - file.read(sample->data, length); - - sample->length /= 2; - if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE) - for (sindex = 0; sindex < sample->length; sindex++) - sample->data[sindex] = LITTLE_ENDIANIZE_INT16(sample->data[sindex]); - } - } - else - { - int length; - - file.seek(0, SEEK_END); - length = file.tell(); - file.seek(0, 0); - - flacread.rawdata = auto_alloc_array(machine, UINT8, length); - flacread.length = length; - flacread.position = 0; - flacread.decoded_size = 0; - - flacreadptr = &flacread; - - file.read(flacread.rawdata, length); - - FLAC__StreamDecoder *decoder = FLAC__stream_decoder_new(); - - if (!decoder) - fatalerror("Fail FLAC__stream_decoder_new\n"); - - if(FLAC__stream_decoder_init_stream( - decoder, - my_read_callback, - NULL, //my_seek_callback, // or NULL - NULL, //my_tell_callback, // or NULL - NULL, //my_length_callback, // or NULL - NULL, //my_eof_callback, // or NULL - my_write_callback, - my_metadata_callback, //my_metadata_callback, // or NULL - my_error_callback, - (void*)flacreadptr /*my_client_data*/ ) != FLAC__STREAM_DECODER_INIT_STATUS_OK) - fatalerror("Fail FLAC__stream_decoder_init_stream\n"); - - if (FLAC__stream_decoder_process_until_end_of_metadata(decoder) != FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM) - fatalerror("Fail FLAC__stream_decoder_process_until_end_of_metadata\n"); - - if (flacread.channels != 1) // only Mono supported - fatalerror("Only MONO samples are supported\n"); - - - sample->data = auto_alloc_array(machine, INT16, flacread.total_samples*2); - flacread.write_position = 0; - flacread.write_data = sample->data; - - if (FLAC__stream_decoder_process_until_end_of_stream (decoder) != FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM) - { - fatalerror("Fail FLAC__stream_decoder_process_until_end_of_stream\n"); - } - - if (FLAC__stream_decoder_finish (decoder) != true) - fatalerror("Fail FLAC__stream_decoder_finish\n"); - - FLAC__stream_decoder_delete(decoder); - - /* fill in the sample data */ - - sample->frequency = flacread.sample_rate; - sample->length = flacread.total_samples * (flacread.bits_per_sample/8); - - if (flacread.bits_per_sample == 8) - { - for (sindex = 0; sindex <= sample->length; sindex++) - sample->data[sindex] = ((sample->data[sindex])&0xff)*256; - } - else // don't need to process 16-bit samples? - { - sample->length = sample->length /2; //?? - } - } - - return 1; -} - - -/*------------------------------------------------- - readsamples - load all samples --------------------------------------------------*/ - -loaded_samples *readsamples(running_machine &machine, const char *const *samplenames, const char *basename) -{ - loaded_samples *samples; - int skipfirst = 0; - int i; - - /* if the user doesn't want to use samples, bail */ - if (!machine.options().samples()) - return NULL; - if (samplenames == 0 || samplenames[0] == 0) - return NULL; - - /* if a name begins with '*', we will also look under that as an alternate basename */ - if (samplenames[0][0] == '*') - skipfirst = 1; - - /* count the samples */ - for (i = 0; samplenames[i+skipfirst] != 0; i++) ; - if (i == 0) - return NULL; - - /* allocate the array */ - samples = (loaded_samples *)auto_alloc_array_clear(machine, UINT8, sizeof(loaded_samples) + (i-1) * sizeof(loaded_sample)); - samples->total = i; - - /* load the samples */ - for (i = 0; i < samples->total; i++) - if (samplenames[i+skipfirst][0]) - { - emu_file file(machine.options().sample_path(), OPEN_FLAG_READ); - file_error filerr = FILERR_NOT_FOUND; - - char filename[512]; - - if (filerr != FILERR_NONE) - { - // first try opening samples as .flac - sprintf(filename, "%s.flac", samplenames[i+skipfirst]); - - filerr = file.open(basename, PATH_SEPARATOR, filename); - // try parent sample set - if (filerr != FILERR_NONE && skipfirst) - filerr = file.open(samplenames[0] + 1, PATH_SEPARATOR, filename); - } - - if (filerr != FILERR_NONE) - { - // .wav fallback - sprintf(filename, "%s.wav", samplenames[i+skipfirst]); - - filerr = file.open(basename, PATH_SEPARATOR, filename); - // try parent sample set - if (filerr != FILERR_NONE && skipfirst) - filerr = file.open(samplenames[0] + 1, PATH_SEPARATOR, filename); - } - - - if (filerr == FILERR_NONE) - read_wav_sample(machine, file, &samples->sample[i], filename); - - if (filerr == FILERR_NOT_FOUND) - mame_printf_warning("sample '%s' NOT FOUND\n", samplenames[i+skipfirst]); - - } - - return samples; -} - - - - -/* Start one of the samples loaded from disk. Note: channel must be in the range */ -/* 0 .. Samplesinterface->channels-1. It is NOT the discrete channel to pass to */ -/* mixer_play_sample() */ -void sample_start(device_t *device,int channel,int samplenum,int loop) -{ - samples_info *info = get_safe_token(device); - sample_channel *chan; - loaded_sample *sample; - - /* if samples are disabled, just return quietly */ - if (info->samples == NULL) + // if samples are disabled, just return quietly + if (m_sample.count() == 0) return; - assert( samplenum < info->samples->total ); - assert( channel < info->numchannels ); + assert(samplenum < m_sample.count()); + assert(channel < m_channels); - chan = &info->channel[channel]; + // force an update before we start + channel_t &chan = m_channel[channel]; + chan.stream->update(); - /* force an update before we start */ - chan->stream->update(); - - /* update the parameters */ - sample = &info->samples->sample[samplenum]; - chan->source = sample->data; - chan->source_length = sample->length; - chan->source_num = sample->data ? samplenum : -1; - chan->pos = 0; - chan->frac = 0; - chan->basefreq = sample->frequency; - chan->step = ((INT64)chan->basefreq << FRAC_BITS) / info->device->machine().sample_rate(); - chan->loop = loop; + // update the parameters + loaded_sample &sample = m_sample[samplenum]; + chan.source = sample.data; + chan.source_length = sample.length; + chan.source_num = (sample.data.count() > 0) ? samplenum : -1; + chan.pos = 0; + chan.frac = 0; + chan.basefreq = sample.frequency; + chan.step = (INT64(chan.basefreq) << FRAC_BITS) / machine().sample_rate(); + chan.loop = loop; } -void sample_start_raw(device_t *device,int channel,const INT16 *sampledata,int samples,int frequency,int loop) +//------------------------------------------------- +// start_raw - start playing an externally +// provided sample +//------------------------------------------------- + +void samples_device::start_raw(UINT8 channel, const INT16 *sampledata, UINT32 samples, UINT32 frequency, bool loop) { - samples_info *info = get_safe_token(device); - sample_channel *chan; + assert(channel < m_channels); - assert( channel < info->numchannels ); + // force an update before we start + channel_t &chan = m_channel[channel]; + chan.stream->update(); - chan = &info->channel[channel]; - - /* force an update before we start */ - chan->stream->update(); - - /* update the parameters */ - chan->source = sampledata; - chan->source_length = samples; - chan->source_num = -1; - chan->pos = 0; - chan->frac = 0; - chan->basefreq = frequency; - chan->step = ((INT64)chan->basefreq << FRAC_BITS) / info->device->machine().sample_rate(); - chan->loop = loop; + // update the parameters + chan.source = sampledata; + chan.source_length = samples; + chan.source_num = -1; + chan.pos = 0; + chan.frac = 0; + chan.basefreq = frequency; + chan.step = (INT64(chan.basefreq) << FRAC_BITS) / machine().sample_rate(); + chan.loop = loop; } -void sample_set_freq(device_t *device,int channel,int freq) +//------------------------------------------------- +// set_frequency - set the playback frequency of +// a sample +//------------------------------------------------- + +void samples_device::set_frequency(UINT8 channel, UINT32 freq) { - samples_info *info = get_safe_token(device); - sample_channel *chan; + assert(channel < m_channels); - assert( channel < info->numchannels ); - - chan = &info->channel[channel]; - - /* force an update before we start */ - chan->stream->update(); - - chan->step = ((INT64)freq << FRAC_BITS) / info->device->machine().sample_rate(); + // force an update before we start + channel_t &chan = m_channel[channel]; + chan.stream->update(); + chan.step = (INT64(freq) << FRAC_BITS) / machine().sample_rate(); } -void sample_set_volume(device_t *device,int channel,float volume) +//------------------------------------------------- +// set_volume - set the playback volume of a +// sample +//------------------------------------------------- + +void samples_device::set_volume(UINT8 channel, float volume) { - samples_info *info = get_safe_token(device); - sample_channel *chan; + assert(channel < m_channels); - assert( channel < info->numchannels ); - - chan = &info->channel[channel]; - - chan->stream->set_output_gain(0, volume); + // force an update before we start + channel_t &chan = m_channel[channel]; + chan.stream->set_output_gain(0, volume); } -void sample_set_pause(device_t *device,int channel,int pause) +//------------------------------------------------- +// pause - pause playback on a channel +//------------------------------------------------- + +void samples_device::pause(UINT8 channel, bool pause) { - samples_info *info = get_safe_token(device); - sample_channel *chan; + assert(channel < m_channels); - assert( channel < info->numchannels ); - - chan = &info->channel[channel]; - - /* force an update before we start */ - chan->stream->update(); - - chan->paused = pause; + // force an update before we start + channel_t &chan = m_channel[channel]; + chan.paused = pause; } -void sample_stop(device_t *device,int channel) +//------------------------------------------------- +// stop - stop playback on a channel +//------------------------------------------------- + +void samples_device::stop(UINT8 channel) { - samples_info *info = get_safe_token(device); - sample_channel *chan; + assert(channel < m_channels); - assert( channel < info->numchannels ); - - chan = &info->channel[channel]; - - /* force an update before we start */ - chan->stream->update(); - chan->source = NULL; - chan->source_num = -1; + // force an update before we start + channel_t &chan = m_channel[channel]; + chan.source = NULL; + chan.source_num = -1; } -int sample_get_base_freq(device_t *device,int channel) +//------------------------------------------------- +// stop_all - stop playback on all channels +//------------------------------------------------- + +void samples_device::stop_all() { - samples_info *info = get_safe_token(device); - sample_channel *chan; - - assert( channel < info->numchannels ); - - chan = &info->channel[channel]; - - /* force an update before we start */ - chan->stream->update(); - return chan->basefreq; + // just iterate over channels and stop them + for (UINT8 channel = 0; channel < m_channels; channel++) + stop(channel); } -int sample_playing(device_t *device,int channel) +//------------------------------------------------- +// base_frequency - return the base frequency of +// a channel being played +//------------------------------------------------- + +UINT32 samples_device::base_frequency(UINT8 channel) const { - samples_info *info = get_safe_token(device); - sample_channel *chan; + assert(channel < m_channels); - assert( channel < info->numchannels ); - - chan = &info->channel[channel]; - - /* force an update before we start */ - chan->stream->update(); - return (chan->source != NULL); + // force an update before we start + const channel_t &chan = m_channel[channel]; + chan.stream->update(); + return chan.basefreq; } -static STREAM_UPDATE( sample_update_sound ) -{ - sample_channel *chan = (sample_channel *)param; - stream_sample_t *buffer = outputs[0]; +//------------------------------------------------- +// playing - return true if a sample is still +// playing on the given channel +//------------------------------------------------- - if (chan->source && !chan->paused) +bool samples_device::playing(UINT8 channel) const +{ + assert(channel < m_channels); + + // force an update before we start + const channel_t &chan = m_channel[channel]; + chan.stream->update(); + return (chan.source != NULL); +} + + + +//************************************************************************** +// DEVICE INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_start - handle device startup +//------------------------------------------------- + +void samples_device::device_start() +{ + // read audio samples + load_samples(); + + // allocate channels + m_channel.resize(m_channels); + for (int channel = 0; channel < m_channels; channel++) { - /* load some info locally */ - UINT32 pos = chan->pos; - UINT32 frac = chan->frac; - UINT32 step = chan->step; - const INT16 *sample = chan->source; - UINT32 sample_length = chan->source_length; + // initialize channel + channel_t &chan = m_channel[channel]; + chan.stream = stream_alloc(0, 1, machine().sample_rate()); + chan.source = NULL; + chan.source_num = -1; + chan.step = 0; + chan.loop = 0; + chan.paused = 0; - while (samples--) - { - /* do a linear interp on the sample */ - INT32 sample1 = sample[pos]; - INT32 sample2 = sample[(pos + 1) % sample_length]; - INT32 fracmult = frac >> (FRAC_BITS - 14); - *buffer++ = ((0x4000 - fracmult) * sample1 + fracmult * sample2) >> 14; - - /* advance */ - frac += step; - pos += frac >> FRAC_BITS; - frac = frac & ((1 << FRAC_BITS) - 1); - - /* handle looping/ending */ - if (pos >= sample_length) - { - if (chan->loop) - pos %= sample_length; - else - { - chan->source = NULL; - chan->source_num = -1; - if (samples > 0) - memset(buffer, 0, samples * sizeof(*buffer)); - break; - } - } - } - - /* push position back out */ - chan->pos = pos; - chan->frac = frac; + // register with the save state system + save_item(NAME(chan.source_length), channel); + save_item(NAME(chan.source_num), channel); + save_item(NAME(chan.pos), channel); + save_item(NAME(chan.frac), channel); + save_item(NAME(chan.step), channel); + save_item(NAME(chan.loop), channel); + save_item(NAME(chan.paused), channel); } - else - memset(buffer, 0, samples * sizeof(*buffer)); + + // initialize any custom handlers + if (m_start != NULL) + (*m_start)(*this); } -static void samples_postload(samples_info *info) +//------------------------------------------------- +// device_reset - handle device reset +//------------------------------------------------- + +void samples_device::device_reset() { - int i; + stop_all(); +} - /* loop over channels */ - for (i = 0; i < info->numchannels; i++) + +//------------------------------------------------- +// device_post_load - handle updating after a +// restore +//------------------------------------------------- + +void samples_device::device_post_load() +{ + // loop over channels + for (int channel = 0; channel < m_channels; channel++) { - sample_channel *chan = &info->channel[i]; - - /* attach any samples that were loaded and playing */ - if (chan->source_num >= 0 && chan->source_num < info->samples->total) + // attach any samples that were loaded and playing + channel_t &chan = m_channel[channel]; + if (chan.source_num >= 0 && chan.source_num < m_sample.count()) { - loaded_sample *sample = &info->samples->sample[chan->source_num]; - chan->source = sample->data; - chan->source_length = sample->length; - if (!sample->data) - chan->source_num = -1; + loaded_sample &sample = m_sample[chan.source_num]; + chan.source = sample.data; + chan.source_length = sample.length; + if (sample.data == NULL) + chan.source_num = -1; } - /* validate the position against the length in case the sample is smaller */ - if (chan->source && chan->pos >= chan->source_length) + // validate the position against the length in case the sample is smaller + if (chan.source != NULL && chan.pos >= chan.source_length) { - if (chan->loop) - chan->pos %= chan->source_length; + if (chan.loop) + chan.pos %= chan.source_length; else { - chan->source = NULL; - chan->source_num = -1; + chan.source = NULL; + chan.source_num = -1; } } } } -static DEVICE_START( samples ) +//------------------------------------------------- +// sound_stream_update - update a sound stream +//------------------------------------------------- + +void samples_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) { - int i; - const samples_interface *intf = (const samples_interface *)device->static_config(); - samples_info *info = get_safe_token(device); + // find the channel with this stream + for (int channel = 0; channel < m_channels; channel++) + if (&stream == m_channel[channel].stream) + { + channel_t &chan = m_channel[channel]; + stream_sample_t *buffer = outputs[0]; - info->device = device; + // process if we still have a source and we're not paused + if (chan.source != NULL && !chan.paused) + { + // load some info locally + UINT32 pos = chan.pos; + UINT32 frac = chan.frac; + UINT32 step = chan.step; + const INT16 *sample = chan.source; + UINT32 sample_length = chan.source_length; - /* read audio samples */ - if (intf->samplenames) - info->samples = readsamples(device->machine(), intf->samplenames,device->machine().system().name); + while (samples--) + { + // do a linear interp on the sample + INT32 sample1 = sample[pos]; + INT32 sample2 = sample[(pos + 1) % sample_length]; + INT32 fracmult = frac >> (FRAC_BITS - 14); + *buffer++ = ((0x4000 - fracmult) * sample1 + fracmult * sample2) >> 14; - /* allocate channels */ - info->numchannels = intf->channels; - assert(info->numchannels < MAX_CHANNELS); - info->channel = auto_alloc_array(device->machine(), sample_channel, info->numchannels); - for (i = 0; i < info->numchannels; i++) - { - info->channel[i].stream = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), &info->channel[i], sample_update_sound); + // advance + frac += step; + pos += frac >> FRAC_BITS; + frac = frac & ((1 << FRAC_BITS) - 1); - info->channel[i].source = NULL; - info->channel[i].source_num = -1; - info->channel[i].step = 0; - info->channel[i].loop = 0; - info->channel[i].paused = 0; + // handle looping/ending + if (pos >= sample_length) + { + if (chan.loop) + pos %= sample_length; + else + { + chan.source = NULL; + chan.source_num = -1; + if (samples > 0) + memset(buffer, 0, samples * sizeof(*buffer)); + samples = 0; + break; + } + } + } - /* register with the save state system */ - device->save_item(NAME(info->channel[i].source_length), i); - device->save_item(NAME(info->channel[i].source_num), i); - device->save_item(NAME(info->channel[i].pos), i); - device->save_item(NAME(info->channel[i].frac), i); - device->save_item(NAME(info->channel[i].step), i); - device->save_item(NAME(info->channel[i].loop), i); - device->save_item(NAME(info->channel[i].paused), i); - } - device->machine().save().register_postload(save_prepost_delegate(FUNC(samples_postload), info)); - - /* initialize any custom handlers */ - if (intf->start) - (*intf->start)(device); + // push position back out + chan.pos = pos; + chan.frac = frac; + } + else + memset(buffer, 0, samples * sizeof(*buffer)); + break; + } } -/************************************************************************** - * Generic get_info - **************************************************************************/ +//************************************************************************** +// INTERNAL HELPERS +//************************************************************************** -DEVICE_GET_INFO( samples ) +//------------------------------------------------- +// read_sample - read a WAV or FLAC file as a +// sample +//------------------------------------------------- + +bool samples_device::read_sample(emu_file &file, loaded_sample &sample) { - switch (state) + // read the core header and make sure it's a proper file + UINT8 buf[4]; + UINT32 offset = file.read(buf, 4); + if (offset < 4) { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(samples_info); break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( samples ); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: /* Nothing */ break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Samples"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Big Hack"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.1"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; + mame_printf_warning("Unable to read %s, 0-byte file?\n", file.filename()); + return false; } + + // look for the appropriate RIFF tag + if (memcmp(&buf[0], "RIFF", 4) == 0) + return read_wav_sample(file, sample); + else if (memcmp(&buf[0], "fLaC", 4) == 0) + return read_flac_sample(file, sample); + + // if nothing appropriate, emit a warning + mame_printf_warning("Unable to read %s, corrupt file?\n", file.filename()); + return false; } -DEFINE_LEGACY_SOUND_DEVICE(SAMPLES, samples); +//------------------------------------------------- +// read_wav_sample - read a WAV file as a 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 + UINT32 offset = 4; + + // get the total size + UINT32 filesize; + offset += file.read(&filesize, 4); + if (offset < 8) + return false; + filesize = LITTLE_ENDIANIZE_INT32(filesize); + + // read the RIFF file type and make sure it's a WAVE file + char buf[32]; + offset += file.read(buf, 4); + if (offset < 12) + return false; + if (memcmp(&buf[0], "WAVE", 4) != 0) + return false; + + // seek until we find a format tag + UINT32 length; + while (1) + { + offset += file.read(buf, 4); + offset += file.read(&length, 4); + length = LITTLE_ENDIANIZE_INT32(length); + if (memcmp(&buf[0], "fmt ", 4) == 0) + break; + + // seek to the next block + file.seek(length, SEEK_CUR); + offset += length; + if (offset >= filesize) + return false; + } + + // read the format -- make sure it is PCM + UINT16 temp16; + offset += file.read(&temp16, 2); + temp16 = LITTLE_ENDIANIZE_INT16(temp16); + if (temp16 != 1) + return false; + + // number of channels -- only mono is supported + offset += file.read(&temp16, 2); + temp16 = LITTLE_ENDIANIZE_INT16(temp16); + if (temp16 != 1) + return false; + + // sample rate + UINT32 rate; + offset += file.read(&rate, 4); + rate = LITTLE_ENDIANIZE_INT32(rate); + + // bytes/second and block alignment are ignored + offset += file.read(buf, 6); + + // bits/sample + UINT16 bits; + offset += file.read(&bits, 2); + bits = LITTLE_ENDIANIZE_INT16(bits); + if (bits != 8 && bits != 16) + return false; + + // seek past any extra data + file.seek(length - 16, SEEK_CUR); + offset += length - 16; + + // seek until we find a data tag + while (1) + { + offset += file.read(buf, 4); + offset += file.read(&length, 4); + length = LITTLE_ENDIANIZE_INT32(length); + if (memcmp(&buf[0], "data", 4) == 0) + break; + + // seek to the next block + file.seek(length, SEEK_CUR); + offset += length; + if (offset >= filesize) + return false; + } + + // if there was a 0 length data block, we're done + if (length == 0) + return false; + + // fill in the sample data + sample.length = length / 2; + sample.frequency = rate; + + // read the data in + if (bits == 8) + { + sample.data.resize(length); + file.read(sample.data, length); + + // convert 8-bit data to signed samples + UINT8 *tempptr = reinterpret_cast(&sample.data[0]); + for (UINT32 sindex = length - 1; sindex >= 0; sindex--) + sample.data[sindex] = INT8(tempptr[sindex] ^ 0x80) * 256; + } + else + { + // 16-bit data is fine as-is + sample.data.resize(length / 2); + file.read(sample.data, length); + + // swap high/low on big-endian systems + if (ENDIANNESS_NATIVE != ENDIANNESS_LITTLE) + for (UINT32 sindex = 0; sindex < sample.length; sindex++) + sample.data[sindex] = LITTLE_ENDIANIZE_INT16(sample.data[sindex]); + } + return true; +} + + +//------------------------------------------------- +// read_flac_sample - read a FLAC file as a 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 + file.seek(0, SEEK_SET); + + // create the FLAC decoder and fill in the sample data + flac_decoder decoder(file); + sample.length = decoder.total_samples(); + sample.frequency = decoder.sample_rate(); + + // error if more than 1 channel or not 16bpp + if (decoder.channels() != 1) + return false; + if (decoder.bits_per_sample() != 16) + return false; + + // resize the array and read + sample.data.resize(sample.length); + if (!decoder.decode_interleaved(sample.data, sample.length)) + return false; + + // finish up and clean up + decoder.finish(); + return true; +} + + +//------------------------------------------------- +// load_samples - load all the samples in our +// attached interface +//------------------------------------------------- + +void samples_device::load_samples() +{ + // if the user doesn't want to use samples, bail + if (!machine().options().samples()) + return; + + // iterate over ourself + const char *basename = machine().basename(); + samples_iterator iter(*this); + const char *altbasename = iter.altbasename(); + + // pre-size the array + m_sample.resize(iter.count()); + + // load the samples + int index = 0; + 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 + emu_file file(machine().options().sample_path(), OPEN_FLAG_READ); + file_error filerr = file.open(basename, PATH_SEPARATOR, samplename, ".flac"); + if (filerr != FILERR_NONE && altbasename != NULL) + filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".flac"); + + // if not, try as WAV + if (filerr != FILERR_NONE) + filerr = file.open(basename, PATH_SEPARATOR, samplename, ".wav"); + if (filerr != FILERR_NONE && altbasename != NULL) + filerr = file.open(altbasename, PATH_SEPARATOR, samplename, ".wav"); + + // if opened, read it + if (filerr == FILERR_NONE) + read_sample(file, m_sample[index]); + else if (filerr == FILERR_NOT_FOUND) + mame_printf_warning("Sample '%s' NOT FOUND\n", samplename); + } +} diff --git a/src/emu/sound/samples.h b/src/emu/sound/samples.h index b3abd505b04..8aee978a86a 100644 --- a/src/emu/sound/samples.h +++ b/src/emu/sound/samples.h @@ -1,51 +1,224 @@ +/*************************************************************************** + + samples.h + + Sound device for sample playback. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + #pragma once #ifndef __SAMPLES_H__ #define __SAMPLES_H__ -#include "devlegcy.h" -typedef struct _loaded_sample loaded_sample; -struct _loaded_sample +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_SAMPLES_ADD(_tag, _interface) \ + MCFG_DEVICE_ADD(_tag, SAMPLES, 0) \ + samples_device::static_set_interface(*device, _interface); + +#define MCFG_SAMPLES_REPLACE(_tag, _interface) \ + MCFG_DEVICE_REPLACE(_tag, SAMPLES, 0) \ + samples_device::static_set_interface(*device, _interface); + + +#define SAMPLES_START(name) void name(samples_device &device) + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +class samples_device; + + +// ======================> samples_interface sample + +struct samples_interface { - int length; /* length in samples */ - int frequency; /* frequency of the sample */ - INT16 * data; /* 16-bit signed data */ + UINT8 m_channels; // number of discrete audio channels needed + const char *const *m_names; // array of sample names + void (*m_start)(samples_device &device); // optional callback }; -typedef struct _loaded_samples loaded_samples; -struct _loaded_samples + +// ======================> samples_device + +class samples_device : public device_t, + public device_sound_interface, + public samples_interface { - int total; /* number of samples */ - loaded_sample sample[1]; /* array of samples */ +public: + // construction/destruction + samples_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // static configuration helpers + static void static_set_interface(device_t &device, const samples_interface &interface); + + // getters + bool playing(UINT8 channel) const; + UINT32 base_frequency(UINT8 channel) const; + + // start/stop helpers + void start(UINT8 channel, UINT32 samplenum, bool loop = false); + void start_raw(UINT8 channel, const INT16 *sampledata, UINT32 samples, UINT32 frequency, bool loop = false); + void pause(UINT8 channel, bool pause = true); + void stop(UINT8 channel); + void stop_all(); + + // dynamic control + void set_frequency(UINT8 channel, UINT32 frequency); + void set_volume(UINT8 channel, float volume); + +protected: + // subclasses can do it this way + samples_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); + + // device-level overrides + virtual void device_start(); + virtual void device_reset(); + virtual void device_post_load(); + + // device_sound_interface overrides + virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples); + +private: + // internal classes + struct loaded_sample + { + // shouldn't need a copy, but in case it happens, catch it here + loaded_sample &operator=(const loaded_sample &rhs) { assert(false); return *this; } + + UINT32 length; // length in samples + UINT32 frequency; // frequency of the sample + dynamic_array data; // 16-bit signed data + }; + + struct channel_t + { + sound_stream * stream; + const INT16 * source; + INT32 source_length; + INT32 source_num; + UINT32 pos; + UINT32 frac; + UINT32 step; + UINT32 basefreq; + bool loop; + bool paused; + }; + + // internal helpers + bool read_sample(emu_file &file, loaded_sample &sample); + bool read_wav_sample(emu_file &file, loaded_sample &sample); + bool read_flac_sample(emu_file &file, loaded_sample &sample); + void load_samples(); + + // internal state + dynamic_array m_channel; + dynamic_array m_sample; + + // internal constants + static const UINT8 FRAC_BITS = 24; + static const UINT32 FRAC_ONE = 1 << FRAC_BITS; + static const UINT32 FRAC_MASK = FRAC_ONE - 1; }; -typedef struct _samples_interface samples_interface; -struct _samples_interface +// iterator, since lots of people are interested in these devices +typedef device_type_iterator<&device_creator, samples_device> samples_device_iterator; + + +// ======================> samples_iterator + +class samples_iterator { - int channels; /* number of discrete audio channels needed */ - const char *const *samplenames; - void (*start)(device_t *device); +public: + // construction/destruction + samples_iterator(samples_interface &intf) + : m_intf(intf), + m_current(-1) { } + + // getters + const char *altbasename() const { return (m_intf.m_names != NULL && m_intf.m_names[0] != NULL && m_intf.m_names[0][0] == '*') ? &m_intf.m_names[0][1] : NULL; } + + // iteration + const char *first() + { + if (m_intf.m_names == NULL || m_intf.m_names[0] == NULL) + return NULL; + m_current = 0; + if (m_intf.m_names[0][0] == '*') + m_current++; + return m_intf.m_names[m_current++]; + } + + const char *next() + { + if (m_current == -1 || m_intf.m_names[m_current] == NULL) + return NULL; + return m_intf.m_names[m_current++]; + } + + // counting + int count() + { + int save = m_current; + int result = 0; + for (const char *scan = first(); scan != NULL; scan = next()) + result++; + m_current = save; + return result; + } + +private: + // internal state + samples_interface & m_intf; + int m_current; }; -#define SAMPLES_START(name) void name(device_t *device) -void sample_start(device_t *device,int channel,int samplenum,int loop); -void sample_start_raw(device_t *device,int channel,const INT16 *sampledata,int samples,int frequency,int loop); -void sample_set_freq(device_t *device,int channel,int freq); -void sample_set_volume(device_t *device,int channel,float volume); -void sample_set_pause(device_t *device,int channel,int pause); -void sample_stop(device_t *device,int channel); -int sample_get_base_freq(device_t *device,int channel); -int sample_playing(device_t *device,int channel); +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** -/* helper function that reads samples from disk - this can be used by other */ -/* drivers as well (e.g. a sound chip emulator needing drum samples) */ -loaded_samples *readsamples(running_machine &machine, const char *const *samplenames, const char *name); +// device type definition +extern const device_type SAMPLES; -DECLARE_LEGACY_SOUND_DEVICE(SAMPLES, samples); -typedef device_type_iterator<&legacy_device_creator, samples_device> samples_device_iterator; - -#endif /* __SAMPLES_H__ */ +#endif diff --git a/src/emu/sound/votrax.c b/src/emu/sound/votrax.c index 176d7cf537f..f4d0abb0a8c 100644 --- a/src/emu/sound/votrax.c +++ b/src/emu/sound/votrax.c @@ -1,187 +1,163 @@ -/************************************************************************** +/*************************************************************************** - Votrax SC-01 Emulator + votrax.c - Mike@Dissfulfils.co.uk + Hacked up votrax simulator that maps to samples, until a real one + is written. -************************************************************************** +**************************************************************************** -DEVICE_START(votrax)- Start emulation, load samples from Votrax subdirectory -votrax_w - Write data to votrax port -votrax_status_r - Return busy status (-1 = busy) + Copyright Aaron Giles + All rights reserved. -If you need to alter the base frequency (i.e. Qbert) then just alter -the variable VotraxBaseFrequency, this is defaulted to 8000 + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: -**************************************************************************/ + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ #include "emu.h" -#include "samples.h" #include "votrax.h" -typedef struct _votrax_state votrax_state; -struct _votrax_state + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// device type definition +const device_type VOTRAX = &device_creator; + +const char *const votrax_device::s_phoneme_table[64] = { - device_t *device; - int stream; - int frequency; /* Some games (Qbert) change this */ - int volume; - sound_stream * channel; - - loaded_sample *sample; - UINT32 pos; - UINT32 frac; - UINT32 step; - - loaded_samples *samples; + "EH3", "EH2", "EH1", " "/*PA0*/"DT", "A1", "A2", "ZH", + "AH2", "I3", "I2", "I1", "M", "N", "B", "V", + "CH", "SH", "Z", "AW1", "NG", "AH1", "OO1", "OO", + "L", "K", "J", "H", "G", "F", "D", "S", + "A", "AY", "Y1", "UH3", "AH", "P", "O", "I", + "U", "Y", "T", "R", "E", "W", "AE", "AE1", + "AW2", "UH2", "UH1", "UH", "O2", "O1", "IU", "U1", + "THV", "TH", "ER", "EH", "E1", "AW", " "/*PA1*/, "."/*STOP*/ }; -INLINE votrax_state *get_safe_token(device_t *device) + + +//************************************************************************** +// LIVE DEVICE +//************************************************************************** + +//------------------------------------------------- +// votrax_device - constructor +//------------------------------------------------- + +votrax_device::votrax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) + : samples_device(mconfig, VOTRAX, "VOTRAX SC-01", tag, owner, clock) { - assert(device != NULL); - assert(device->type() == VOTRAX); - return (votrax_state *)downcast(device)->token(); } -#define FRAC_BITS 24 -#define FRAC_ONE (1 << FRAC_BITS) -#define FRAC_MASK (FRAC_ONE - 1) +//------------------------------------------------- +// static_set_interface - configuration helper +// to set the interface +//------------------------------------------------- -/**************************************************************************** - * 64 Phonemes - currently 1 sample per phoneme, will be combined sometime! - ****************************************************************************/ - -static const char *const VotraxTable[65] = +void votrax_device::static_set_interface(device_t &device, const votrax_interface &interface) { - "EH3","EH2","EH1","PA0","DT" ,"A1" ,"A2" ,"ZH", - "AH2","I3" ,"I2" ,"I1" ,"M" ,"N" ,"B" ,"V", - "CH" ,"SH" ,"Z" ,"AW1","NG" ,"AH1","OO1","OO", - "L" ,"K" ,"J" ,"H" ,"G" ,"F" ,"D" ,"S", - "A" ,"AY" ,"Y1" ,"UH3","AH" ,"P" ,"O" ,"I", - "U" ,"Y" ,"T" ,"R" ,"E" ,"W" ,"AE" ,"AE1", - "AW2","UH2","UH1","UH" ,"O2" ,"O1" ,"IU" ,"U1", - "THV","TH" ,"ER" ,"EH" ,"E1" ,"AW" ,"PA1","STOP", - 0 -}; + votrax_device &samples = downcast(device); + static_cast(samples) = interface; +} -static STREAM_UPDATE( votrax_update_sound ) + + +//************************************************************************** +// READ/WRITE HANDLERS +//************************************************************************** + +//------------------------------------------------- +// write - handle a write to the control register +//------------------------------------------------- + +WRITE8_MEMBER( votrax_device::write ) { - votrax_state *info = (votrax_state*) param; - stream_sample_t *buffer = outputs[0]; - - if (info->sample) - { - /* load some info locally */ - UINT32 pos = info->pos; - UINT32 frac = info->frac; - UINT32 step = info->step; - UINT32 length = info->sample->length; - INT16 *sample = info->sample->data; - - while (length--) + // append to the current string + m_current.cat(s_phoneme_table[data & 0x3f]); + + // look for a match in our sample table + for (int index = 0; m_votrax_map[index].phoneme != NULL; index++) + if (m_current.find(m_votrax_map[index].phoneme) != -1) { - /* do a linear interp on the sample */ - INT32 sample1 = sample[pos]; - INT32 sample2 = sample[(pos + 1) % length]; - INT32 fracmult = frac >> (FRAC_BITS - 14); - *buffer++ = ((0x4000 - fracmult) * sample1 + fracmult * sample2) >> 14; - - /* advance */ - frac += step; - pos += frac >> FRAC_BITS; - frac = frac & ((1 << FRAC_BITS) - 1); - - /* handle looping/ending */ - if (pos >= length) - { - info->sample = NULL; - break; - } + // if we found it, play the corresponding sample and flush the buffer + start(0, index); + m_current.replace(m_votrax_map[index].phoneme, ""); + m_current.trimspace(); + if (m_current.len() > 0) + mame_printf_warning("Votrax missed partial match: %s\n", m_current.cstr()); + m_current.reset(); + return; } - - /* push position back out */ - info->pos = pos; - info->frac = frac; - } -} - - -static DEVICE_START( votrax ) -{ - votrax_state *votrax = get_safe_token(device); - - votrax->device = device; - votrax->samples = readsamples(device->machine(),VotraxTable,"votrax"); - votrax->frequency = 8000; - votrax->volume = 230; - - votrax->channel = device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), votrax, votrax_update_sound); - - votrax->sample = NULL; - votrax->step = 0; -} - - -WRITE8_DEVICE_HANDLER( votrax_w ) -{ - votrax_state *info = get_safe_token(device); - int Phoneme,Intonation; - - info->channel->update(); - - Phoneme = data & 0x3F; - Intonation = data >> 6; - - logerror("Speech : %s at intonation %d\n",VotraxTable[Phoneme],Intonation); - - if(Phoneme==63) - info->sample = NULL; - - if(info->samples->sample[Phoneme].data) + + // if we got a stop and didn't find a match, print it + if ((data & 0x3f) == 0x3f) { - info->sample = &info->samples->sample[Phoneme]; - info->pos = 0; - info->frac = 0; - info->step = ((INT64)(info->sample->frequency + (256*Intonation)) << FRAC_BITS) / info->device->machine().sample_rate(); - info->channel->set_output_gain(0, (info->volume + (8*Intonation)*100/255) / 100.0); - } -} - -int votrax_status_r(device_t *device) -{ - votrax_state *info = get_safe_token(device); - info->channel->update(); - return (info->sample != NULL); -} - - - -/************************************************************************** - * Generic get_info - **************************************************************************/ - -DEVICE_GET_INFO( votrax ) -{ - switch (state) - { - /* --- the following bits of info are returned as 64-bit signed integers --- */ - case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(votrax_state); break; - - /* --- the following bits of info are returned as pointers to data or functions --- */ - case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( votrax ); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: /* Nothing */ break; - - /* --- the following bits of info are returned as NULL-terminated strings --- */ - case DEVINFO_STR_NAME: strcpy(info->s, "Votrax SC-01"); break; - case DEVINFO_STR_FAMILY: strcpy(info->s, "Votrax speech"); break; - case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; - case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; - case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; + mame_printf_warning("Votrax missed match: %s\n", m_current.cstr()); + m_current.reset(); } } -DEFINE_LEGACY_SOUND_DEVICE(VOTRAX, votrax); +//------------------------------------------------- +// status - read the status line +//------------------------------------------------- + +READ_LINE_MEMBER( votrax_device::status ) +{ + // is this correct, or is it really a ready line and should be inverted? + return (m_current.len() > 0 || playing(0)) ? ASSERT_LINE : CLEAR_LINE; +} + + + +//************************************************************************** +// DEVICE INTERFACE +//************************************************************************** + +//------------------------------------------------- +// device_start - handle device startup +//------------------------------------------------- + +void votrax_device::device_start() +{ + // build up a samples list + for (const votrax_map *curmap = m_votrax_map; curmap->phoneme != NULL; curmap++) + m_sample_list.append((curmap->samplename != NULL) ? curmap->samplename : ""); + + // create the samples interface + m_channels = 1; + m_names = m_sample_list; + m_start = NULL; + + // let the samples device do the rest + samples_device::device_start(); +} diff --git a/src/emu/sound/votrax.h b/src/emu/sound/votrax.h index 29e7e2dedb7..fb549ca6ee4 100644 --- a/src/emu/sound/votrax.h +++ b/src/emu/sound/votrax.h @@ -1,13 +1,115 @@ +/*************************************************************************** + + votrax.h + + Hacked up votrax simulator that maps to samples, until a real one + is written. + +**************************************************************************** + + Copyright Aaron Giles + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + * Neither the name 'MAME' nor the names of its contributors may be + used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +***************************************************************************/ + #pragma once #ifndef __VOTRAX_H__ #define __VOTRAX_H__ -#include "devlegcy.h" +#include "sound/samples.h" -WRITE8_DEVICE_HANDLER( votrax_w ); -int votrax_status_r(device_t *device); -DECLARE_LEGACY_SOUND_DEVICE(VOTRAX, votrax); +//************************************************************************** +// INTERFACE CONFIGURATION MACROS +//************************************************************************** + +#define MCFG_VOTRAX_ADD(_tag, _clock, _interface) \ + MCFG_DEVICE_ADD(_tag, VOTRAX, 0) \ + votrax_device::static_set_interface(*device, _interface); + + + +//************************************************************************** +// TYPE DEFINITIONS +//************************************************************************** + +// ======================> votrax_interface sample + +struct votrax_map +{ + const char *phoneme; + const char *samplename; +}; + +struct votrax_interface +{ + votrax_map const *m_votrax_map; // array of map entries +}; + + +// ======================> votrax_device + +class votrax_device : public samples_device, + public votrax_interface +{ +public: + // construction/destruction + votrax_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + // static configuration helpers + static void static_set_interface(device_t &device, const votrax_interface &interface); + + // writers + DECLARE_WRITE8_MEMBER( write ); + DECLARE_READ_LINE_MEMBER( status ); + +protected: + // device-level overrides + virtual void device_start(); + +private: + // internal state + astring m_current; + dynamic_array m_sample_list; + + static const char *const s_phoneme_table[64]; +}; + + + +//************************************************************************** +// GLOBAL VARIABLES +//************************************************************************** + +// device type definition +extern const device_type VOTRAX; + #endif /* __VOTRAX_H__ */ diff --git a/src/lib/util/flac.c b/src/lib/util/flac.c index 360d8eb2304..99c73a11ff5 100644 --- a/src/lib/util/flac.c +++ b/src/lib/util/flac.c @@ -367,7 +367,15 @@ flac_decoder::~flac_decoder() bool flac_decoder::reset() { m_compressed_offset = 0; - if (FLAC__stream_decoder_init_stream(m_decoder, &flac_decoder::read_callback_static, NULL, &flac_decoder::tell_callback_static, NULL, NULL, &flac_decoder::write_callback_static, NULL, &flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK) + if (FLAC__stream_decoder_init_stream(m_decoder, + &flac_decoder::read_callback_static, + NULL, + &flac_decoder::tell_callback_static, + NULL, + NULL, + &flac_decoder::write_callback_static, + &flac_decoder::metadata_callback_static, + &flac_decoder::error_callback_static, this) != FLAC__STREAM_DECODER_INIT_STATUS_OK) return false; return FLAC__stream_decoder_process_until_end_of_metadata(m_decoder); } @@ -562,6 +570,24 @@ FLAC__StreamDecoderReadStatus flac_decoder::read_callback(FLAC__byte buffer[], s } +//------------------------------------------------- +// metadata_callback - handle STREAMINFO metadata +//------------------------------------------------- + +void flac_decoder::metadata_callback_static(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) +{ + // ignore all but STREAMINFO metadata + if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO) + return; + + // parse out the data we care about + flac_decoder *fldecoder = reinterpret_cast(client_data); + fldecoder->m_sample_rate = metadata->data.stream_info.sample_rate; + fldecoder->m_bits_per_sample = metadata->data.stream_info.bits_per_sample; + fldecoder->m_channels = metadata->data.stream_info.channels; +} + + //------------------------------------------------- // tell_callback - handle requests to find out // where in the input stream we are diff --git a/src/lib/util/flac.h b/src/lib/util/flac.h index 5f2a4cbf71a..add4e506525 100644 --- a/src/lib/util/flac.h +++ b/src/lib/util/flac.h @@ -121,9 +121,10 @@ public: ~flac_decoder(); // getters (valid after reset) - UINT32 sample_rate() const { return FLAC__stream_decoder_get_sample_rate(m_decoder); } - UINT8 channels() const { return FLAC__stream_decoder_get_channels(m_decoder); } - UINT32 block_size() const { return FLAC__stream_decoder_get_blocksize(m_decoder); } + UINT32 sample_rate() const { return m_sample_rate; } + UINT8 channels() const { return m_channels; } + UINT8 bits_per_sample() const { return m_bits_per_sample; } + UINT32 total_samples() const { return FLAC__stream_decoder_get_total_samples(m_decoder); } FLAC__StreamDecoderState state() const { return FLAC__stream_decoder_get_state(m_decoder); } const char *state_string() const { return FLAC__stream_decoder_get_resolved_state_string(m_decoder); } @@ -144,6 +145,7 @@ private: // internal helpers static FLAC__StreamDecoderReadStatus read_callback_static(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data); FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], size_t *bytes); + static void metadata_callback_static(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); static FLAC__StreamDecoderTellStatus tell_callback_static(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data); static FLAC__StreamDecoderWriteStatus write_callback_static(const FLAC__StreamDecoder *decoder, const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]); @@ -152,6 +154,9 @@ private: // output state FLAC__StreamDecoder * m_decoder; // actual encoder core_file * m_file; // output file + UINT32 m_sample_rate; // decoded sample rate + UINT8 m_channels; // decoded number of channels + UINT8 m_bits_per_sample; // decoded bits per sample UINT32 m_compressed_offset; // current offset in compressed data const FLAC__byte * m_compressed_start; // start of compressed data UINT32 m_compressed_length; // length of compressed data diff --git a/src/lib/util/hashing.h b/src/lib/util/hashing.h index 08aeec5ac60..b3976a46415 100644 --- a/src/lib/util/hashing.h +++ b/src/lib/util/hashing.h @@ -44,7 +44,6 @@ #include "osdcore.h" #include "astring.h" -//#include "zlib.h" #include "md5.h" #include "sha1.h" diff --git a/src/mame/audio/8080bw.c b/src/mame/audio/8080bw.c index 4c9847a25b2..7b71f82bc98 100644 --- a/src/mame/audio/8080bw.c +++ b/src/mame/audio/8080bw.c @@ -38,10 +38,10 @@ WRITE8_HANDLER( invadpt2_sh_port_1_w ) sn76477_enable_w(state->m_sn, !(data & 0x01)); /* SAUCER SOUND */ - if (rising_bits & 0x02) sample_start(state->m_samples, 0, 0, 0); /* MISSLE SOUND */ - if (rising_bits & 0x04) sample_start(state->m_samples, 1, 1, 0); /* EXPLOSION */ - if (rising_bits & 0x08) sample_start(state->m_samples, 2, 2, 0); /* INVADER HIT */ - if (rising_bits & 0x10) sample_start(state->m_samples, 5, 8, 0); /* BONUS MISSILE BASE */ + if (rising_bits & 0x02) state->m_samples->start(0, 0); /* MISSLE SOUND */ + if (rising_bits & 0x04) state->m_samples->start(1, 1); /* EXPLOSION */ + if (rising_bits & 0x08) state->m_samples->start(2, 2); /* INVADER HIT */ + if (rising_bits & 0x10) state->m_samples->start(5, 8); /* BONUS MISSILE BASE */ state->m_screen_red = data & 0x04; @@ -63,11 +63,11 @@ WRITE8_HANDLER( invadpt2_sh_port_2_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_2_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 4, 3, 0); /* FLEET */ - if (rising_bits & 0x02) sample_start(state->m_samples, 4, 4, 0); /* FLEET */ - if (rising_bits & 0x04) sample_start(state->m_samples, 4, 5, 0); /* FLEET */ - if (rising_bits & 0x08) sample_start(state->m_samples, 4, 6, 0); /* FLEET */ - if (rising_bits & 0x10) sample_start(state->m_samples, 3, 7, 0); /* SAUCER HIT */ + if (rising_bits & 0x01) state->m_samples->start(4, 3); /* FLEET */ + if (rising_bits & 0x02) state->m_samples->start(4, 4); /* FLEET */ + if (rising_bits & 0x04) state->m_samples->start(4, 5); /* FLEET */ + if (rising_bits & 0x08) state->m_samples->start(4, 6); /* FLEET */ + if (rising_bits & 0x10) state->m_samples->start(3, 7); /* SAUCER HIT */ state->m_c8080bw_flip_screen = data & 0x20; @@ -88,9 +88,9 @@ WRITE8_HANDLER( spcewars_sh_port_w ) sn76477_enable_w(state->m_sn, !(data & 0x01)); /* Saucer Sound */ - if (rising_bits & 0x02) sample_start(state->m_samples, 0, 0, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(state->m_samples, 1, 1, 0); /* Base Hit */ - if (rising_bits & 0x08) sample_start(state->m_samples, 2, 2, 0); /* Invader Hit */ + if (rising_bits & 0x02) state->m_samples->start(0, 0); /* Shot Sound */ + if (rising_bits & 0x04) state->m_samples->start(1, 1); /* Base Hit */ + if (rising_bits & 0x08) state->m_samples->start(2, 2); /* Invader Hit */ speaker_level_w(state->m_speaker, (data & 0x10) ? 1 : 0); /* Various bitstream tunes */ @@ -130,11 +130,11 @@ WRITE8_HANDLER( lrescue_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 0, 3, 0); /* Thrust */ - if (rising_bits & 0x02) sample_start(state->m_samples, 1, 2, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(state->m_samples, 0, 1, 0); /* Death */ - if (rising_bits & 0x08) sample_start(state->m_samples, 1, 0, 0); /* Alien Hit */ - if (rising_bits & 0x10) sample_start(state->m_samples, 2, 5, 0); /* Bonus Ship (not confirmed) */ + if (rising_bits & 0x01) state->m_samples->start(0, 3); /* Thrust */ + if (rising_bits & 0x02) state->m_samples->start(1, 2); /* Shot Sound */ + if (rising_bits & 0x04) state->m_samples->start(0, 1); /* Death */ + if (rising_bits & 0x08) state->m_samples->start(1, 0); /* Alien Hit */ + if (rising_bits & 0x10) state->m_samples->start(2, 5); /* Bonus Ship (not confirmed) */ space->machine().sound().system_enable(data & 0x20); @@ -148,14 +148,14 @@ WRITE8_HANDLER( lrescue_sh_port_2_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_2_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 1, 8, 0); /* Footstep high tone */ - if (rising_bits & 0x02) sample_start(state->m_samples, 1, 7, 0); /* Footstep low tone */ - if (rising_bits & 0x04) sample_start(state->m_samples, 1, 4, 0); /* Bonus when counting men saved */ + if (rising_bits & 0x01) state->m_samples->start(1, 8); /* Footstep high tone */ + if (rising_bits & 0x02) state->m_samples->start(1, 7); /* Footstep low tone */ + if (rising_bits & 0x04) state->m_samples->start(1, 4); /* Bonus when counting men saved */ speaker_level_w(state->m_speaker, (data & 0x08) ? 1 : 0); /* Bitstream tunes - endlevel and bonus1 */ - if (rising_bits & 0x10) sample_start(state->m_samples, 3, 6, 0); /* Shooting Star and Rescue Ship sounds */ - if ((~data & 0x10) && (state->m_port_2_last_extra & 0x10)) sample_stop (state->m_samples, 3); /* This makes the rescue ship sound beep on and off */ + if (rising_bits & 0x10) state->m_samples->start(3, 6); /* Shooting Star and Rescue Ship sounds */ + if ((~data & 0x10) && (state->m_port_2_last_extra & 0x10)) state->m_samples->stop(3); /* This makes the rescue ship sound beep on and off */ state->m_c8080bw_flip_screen = data & 0x20; @@ -188,11 +188,11 @@ WRITE8_HANDLER( ballbomb_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 1, 2, 0); /* Hit a balloon */ - if (rising_bits & 0x02) sample_start(state->m_samples, 2, 0, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(state->m_samples, 2, 1, 0); /* Base Hit */ - if (rising_bits & 0x08) sample_start(state->m_samples, 1, 7, 0); /* Hit a Bomb */ - if (rising_bits & 0x10) sample_start(state->m_samples, 3, 8, 0); /* Bonus Base at 1500 points */ + if (rising_bits & 0x01) state->m_samples->start(1, 2); /* Hit a balloon */ + if (rising_bits & 0x02) state->m_samples->start(2, 0); /* Shot Sound */ + if (rising_bits & 0x04) state->m_samples->start(2, 1); /* Base Hit */ + if (rising_bits & 0x08) state->m_samples->start(1, 7); /* Hit a Bomb */ + if (rising_bits & 0x10) state->m_samples->start(3, 8); /* Bonus Base at 1500 points */ space->machine().sound().system_enable(data & 0x20); @@ -206,9 +206,9 @@ WRITE8_HANDLER( ballbomb_sh_port_2_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_2_last_extra; - if (data & 0x01) sample_start(state->m_samples, 0, 7, 0); /* Indicates plane will drop bombs */ - if (data & 0x04) sample_start(state->m_samples, 0, 4, 0); /* Plane is dropping new balloons at start of level */ - if (rising_bits & 0x10) sample_start(state->m_samples, 2, 2, 0); /* Balloon hit and bomb drops */ + if (data & 0x01) state->m_samples->start(0, 7); /* Indicates plane will drop bombs */ + if (data & 0x04) state->m_samples->start(0, 4); /* Plane is dropping new balloons at start of level */ + if (rising_bits & 0x10) state->m_samples->start(2, 2); /* Balloon hit and bomb drops */ state->m_c8080bw_flip_screen = data & 0x20; @@ -265,10 +265,10 @@ WRITE8_HANDLER( indianbt_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 1, 7, 0); /* Death */ - if (rising_bits & 0x02) sample_start(state->m_samples, 0, 1, 0); /* Shot Sound */ - if (rising_bits & 0x04) sample_start(state->m_samples, 2, 3, 0); /* Move */ - if (rising_bits & 0x08) sample_start(state->m_samples, 3, 2, 0); /* Hit */ + if (rising_bits & 0x01) state->m_samples->start(1, 7); /* Death */ + if (rising_bits & 0x02) state->m_samples->start(0, 1); /* Shot Sound */ + if (rising_bits & 0x04) state->m_samples->start(2, 3); /* Move */ + if (rising_bits & 0x08) state->m_samples->start(3, 2); /* Hit */ space->machine().sound().system_enable(data & 0x20); @@ -282,10 +282,10 @@ WRITE8_HANDLER( indianbt_sh_port_2_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_2_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 4, 0, 0); /* Bird dropped an egg, Lasso used */ - if (rising_bits & 0x02) sample_start(state->m_samples, 4, 2, 0); /* Egg hatches, egg shot */ - if (rising_bits & 0x08) sample_start(state->m_samples, 5, 0, 0); /* Grabber, Lasso caught something */ - if (rising_bits & 0x10) sample_start(state->m_samples, 3, 7, 0); /* Lasso sound */ + if (rising_bits & 0x01) state->m_samples->start(4, 0); /* Bird dropped an egg, Lasso used */ + if (rising_bits & 0x02) state->m_samples->start(4, 2); /* Egg hatches, egg shot */ + if (rising_bits & 0x08) state->m_samples->start(5, 0); /* Grabber, Lasso caught something */ + if (rising_bits & 0x10) state->m_samples->start(3, 7); /* Lasso sound */ state->m_port_2_last_extra = data; } @@ -954,9 +954,9 @@ WRITE8_HANDLER( rollingc_sh_port_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_3_last_extra; - if (rising_bits & 0x02) sample_start(state->m_samples, 4, 0, 0); /* Steering */ - if (rising_bits & 0x04) sample_start(state->m_samples, 0, 1, 0); /* Collision */ - if (rising_bits & 0x10) sample_start(state->m_samples, 1, 8, 0); /* Computer car is starting to move */ + if (rising_bits & 0x02) state->m_samples->start(4, 0); /* Steering */ + if (rising_bits & 0x04) state->m_samples->start(0, 1); /* Collision */ + if (rising_bits & 0x10) state->m_samples->start(1, 8); /* Computer car is starting to move */ state->m_port_3_last_extra = data; } @@ -980,24 +980,24 @@ WRITE8_HANDLER( invrvnge_sh_port_w ) switch (data) { case 0x06: - sample_start(state->m_samples, 1, 0, 0); /* Shoot */ + state->m_samples->start(1, 0); /* Shoot */ break; case 0x14: - sample_start(state->m_samples, 2, 2, 0); /* Hit Alien */ + state->m_samples->start(2, 2); /* Hit Alien */ break; case 0x16: - sample_start(state->m_samples, 2, 5, 0); /* Hit Asteroid */ + state->m_samples->start(2, 5); /* Hit Asteroid */ break; case 0x1e: - sample_start(state->m_samples, 3, 1, 0); /* Death (followed by 0x0a byte), also bit 4 of port 5 */ + state->m_samples->start(3, 1); /* Death (followed by 0x0a byte), also bit 4 of port 5 */ break; case 0x18: /* Fuel Low */ case 0x30: /* Fuel bar filling up */ - sample_start(state->m_samples, 4, 7, 0); + state->m_samples->start(4, 7); break; case 0x02: /* Coin */ @@ -1007,7 +1007,7 @@ WRITE8_HANDLER( invrvnge_sh_port_w ) break; case 0x3a: /* Thrust, Docking, extra ship? */ - sample_start(state->m_samples, 0, 8, 0); + state->m_samples->start(0, 8); break; } } @@ -1023,13 +1023,13 @@ WRITE8_HANDLER( lupin3_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 0, 6, 0); /* Walking, get money */ + if (rising_bits & 0x01) state->m_samples->start(0, 6); /* Walking, get money */ sn76477_enable_w(state->m_sn, data & 0x02 ? 0:1); /* Helicopter */ - if (rising_bits & 0x04) sample_start(state->m_samples, 0, 7, 0); /* Translocate */ - if (rising_bits & 0x08) sample_start(state->m_samples, 0, 1, 0); /* Jail */ - if (rising_bits & 0x10) sample_start(state->m_samples, 3, 8, 0); /* Bonus Man */ + if (rising_bits & 0x04) state->m_samples->start(0, 7); /* Translocate */ + if (rising_bits & 0x08) state->m_samples->start(0, 1); /* Jail */ + if (rising_bits & 0x10) state->m_samples->start(3, 8); /* Bonus Man */ state->m_port_1_last_extra = data; } @@ -1039,11 +1039,11 @@ WRITE8_HANDLER( lupin3_sh_port_2_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_2_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 0, 3, 0); /* Lands on top of building, wife kicks man */ - if (rising_bits & 0x02) sample_start(state->m_samples, 1, 2, 0); /* deposit money, start intermission, end game */ - if (rising_bits & 0x04) sample_start(state->m_samples, 2, 5, 0); /* deposit money, start intermission, Slides down rope */ - if (rising_bits & 0x08) sample_start(state->m_samples, 3, 0, 0); /* start intermission, end game */ - //if (rising_bits & 0x10) sample_start(state->m_samples, 3, 9, 0); /* Dog barking */ + if (rising_bits & 0x01) state->m_samples->start(0, 3); /* Lands on top of building, wife kicks man */ + if (rising_bits & 0x02) state->m_samples->start(1, 2); /* deposit money, start intermission, end game */ + if (rising_bits & 0x04) state->m_samples->start(2, 5); /* deposit money, start intermission, Slides down rope */ + if (rising_bits & 0x08) state->m_samples->start(3, 0); /* start intermission, end game */ + //if (rising_bits & 0x10) state->m_samples->start(3, 9); /* Dog barking */ state->m_color_map = data & 0x40; @@ -1068,8 +1068,8 @@ WRITE8_HANDLER( schasercv_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x02) sample_start(state->m_samples, 1, 6, 0); /* Ran over a dot */ - if (rising_bits & 0x10) sample_start(state->m_samples, 0, 1, 0); /* Death */ + if (rising_bits & 0x02) state->m_samples->start(1, 6); /* Ran over a dot */ + if (rising_bits & 0x10) state->m_samples->start(0, 1); /* Death */ state->m_port_1_last_extra = data; } @@ -1096,11 +1096,11 @@ WRITE8_HANDLER( yosakdon_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 0, 3, 0); /* Game Over */ - if (rising_bits & 0x02) sample_start(state->m_samples, 2, 0, 0); /* Bird dead */ - if (rising_bits & 0x04) sample_start(state->m_samples, 0, 1, 0); /* Rifle being fired */ - if (rising_bits & 0x08) sample_start(state->m_samples, 1, 2, 0); /* Man dead */ - if (rising_bits & 0x10) sample_start(state->m_samples, 5, 8, 0); /* Bonus Man? */ + if (rising_bits & 0x01) state->m_samples->start(0, 3); /* Game Over */ + if (rising_bits & 0x02) state->m_samples->start(2, 0); /* Bird dead */ + if (rising_bits & 0x04) state->m_samples->start(0, 1); /* Rifle being fired */ + if (rising_bits & 0x08) state->m_samples->start(1, 2); /* Man dead */ + if (rising_bits & 0x10) state->m_samples->start(5, 8); /* Bonus Man? */ space->machine().sound().system_enable(data & 0x20); @@ -1112,12 +1112,12 @@ WRITE8_HANDLER( yosakdon_sh_port_2_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_2_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 1, 6, 0); /* Ready? , Game Over */ - if (rising_bits & 0x04) sample_start(state->m_samples, 3, 7, 0); /* Big bird dead */ + if (rising_bits & 0x01) state->m_samples->start(1, 6); /* Ready? , Game Over */ + if (rising_bits & 0x04) state->m_samples->start(3, 7); /* Big bird dead */ sn76477_enable_w(state->m_sn, data & 0x08 ? 0:1); /* Big bird */ - if (rising_bits & 0x10) sample_start(state->m_samples, 2, 7, 0); /* Game Over */ + if (rising_bits & 0x10) state->m_samples->start(2, 7); /* Game Over */ state->m_c8080bw_flip_screen = data & 0x20; @@ -1136,8 +1136,8 @@ WRITE8_HANDLER( shuttlei_sh_port_1_w ) _8080bw_state *state = space->machine().driver_data<_8080bw_state>(); UINT8 rising_bits = data & ~state->m_port_1_last_extra; - if (rising_bits & 0x01) sample_start(state->m_samples, 4, 4, 0); /* Fleet move */ - if (rising_bits & 0x02) sample_start(state->m_samples, 5, 8, 0); /* Extra Tank */ + if (rising_bits & 0x01) state->m_samples->start(4, 4); /* Fleet move */ + if (rising_bits & 0x02) state->m_samples->start(5, 8); /* Extra Tank */ sn76477_enable_w(state->m_sn, data & 0x04 ? 0:1); /* UFO */ @@ -1151,19 +1151,19 @@ WRITE8_HANDLER( shuttlei_sh_port_2_w ) switch (data) { case 0x23: - sample_start(state->m_samples, 2, 2, 0); /* Hit */ + state->m_samples->start(2, 2); /* Hit */ break; case 0x2b: - sample_start(state->m_samples, 0, 0, 0); /* Shoot */ + state->m_samples->start(0, 0); /* Shoot */ break; case 0xa3: - sample_start(state->m_samples, 3, 7, 0); /* Hit UFO */ + state->m_samples->start(3, 7); /* Hit UFO */ break; case 0xab: - sample_start(state->m_samples, 1, 1, 0); /* Death */ + state->m_samples->start(1, 1); /* Death */ break; } } diff --git a/src/mame/audio/astrof.c b/src/mame/audio/astrof.c index f2e0435366e..f7b64000785 100644 --- a/src/mame/audio/astrof.c +++ b/src/mame/audio/astrof.c @@ -38,10 +38,10 @@ WRITE8_HANDLER( astrof_audio_1_w ) UINT8 rising_bits = data & ~state->m_port_1_last; if (state->m_astrof_death_playing) - state->m_astrof_death_playing = sample_playing(state->m_samples, CHANNEL_EXPLOSION); + state->m_astrof_death_playing = state->m_samples->playing(CHANNEL_EXPLOSION); if (state->m_astrof_bosskill_playing) - state->m_astrof_bosskill_playing = sample_playing(state->m_samples, CHANNEL_EXPLOSION); + state->m_astrof_bosskill_playing = state->m_samples->playing(CHANNEL_EXPLOSION); /* D2 - explosion */ if (rising_bits & 0x04) @@ -55,19 +55,19 @@ WRITE8_HANDLER( astrof_audio_1_w ) if ((data & 0x08) && (~state->m_port_1_last & 0x08)) { int sample = SAMPLE_WAVE + (data & 3); - sample_start(state->m_samples, CHANNEL_WAVE, sample, 1); + state->m_samples->start(CHANNEL_WAVE, sample, 1); } if ((~data & 0x08) && (state->m_port_1_last & 0x08)) - sample_stop(state->m_samples, CHANNEL_WAVE); + state->m_samples->stop(CHANNEL_WAVE); /* D4 - boss laser */ if ((rising_bits & 0x10) && !state->m_astrof_bosskill_playing) - sample_start(state->m_samples, CHANNEL_BOSSFIRE, SAMPLE_BOSSFIRE, 0); + state->m_samples->start(CHANNEL_BOSSFIRE, SAMPLE_BOSSFIRE, 0); /* D5 - fire */ if ((rising_bits & 0x20) && !state->m_astrof_bosskill_playing) - sample_start(state->m_samples, CHANNEL_FIRE, SAMPLE_FIRE, 0); + state->m_samples->start(CHANNEL_FIRE, SAMPLE_FIRE, 0); /* D6 - don't know. Probably something to do with the explosion sounds */ @@ -95,19 +95,19 @@ WRITE8_HANDLER( astrof_audio_2_w ) { if (!state->m_astrof_bosskill_playing) { - sample_start(state->m_samples, CHANNEL_EXPLOSION, SAMPLE_BOSSKILL, 0); + state->m_samples->start(CHANNEL_EXPLOSION, SAMPLE_BOSSKILL, 0); state->m_astrof_bosskill_playing = 1; } } else if (data & 0x02) - sample_start(state->m_samples, CHANNEL_EXPLOSION, SAMPLE_BOSSHIT, 0); + state->m_samples->start(CHANNEL_EXPLOSION, SAMPLE_BOSSHIT, 0); else if (data & 0x01) - sample_start(state->m_samples, CHANNEL_EXPLOSION, SAMPLE_EKILLED, 0); + state->m_samples->start(CHANNEL_EXPLOSION, SAMPLE_EKILLED, 0); else { if (!state->m_astrof_death_playing) { - sample_start(state->m_samples, CHANNEL_EXPLOSION, SAMPLE_DEATH, 0); + state->m_samples->start(CHANNEL_EXPLOSION, SAMPLE_DEATH, 0); state->m_astrof_death_playing = 1; } } @@ -117,7 +117,7 @@ WRITE8_HANDLER( astrof_audio_2_w ) /* D3 - low fuel warning */ if (rising_bits & 0x08) - sample_start(state->m_samples, CHANNEL_FUEL, SAMPLE_FUEL, 0); + state->m_samples->start(CHANNEL_FUEL, SAMPLE_FUEL, 0); state->m_port_2_last = data; } @@ -151,8 +151,7 @@ static const samples_interface astrof_samples_interface = MACHINE_CONFIG_FRAGMENT( astrof_audio ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(astrof_samples_interface) + MCFG_SAMPLES_ADD("samples", astrof_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/audio/blockade.c b/src/mame/audio/blockade.c index b860f63cf8c..0608e6cab02 100644 --- a/src/mame/audio/blockade.c +++ b/src/mame/audio/blockade.c @@ -44,9 +44,9 @@ WRITE8_DEVICE_HANDLER( blockade_sound_freq_w ) WRITE8_HANDLER( blockade_env_on_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); if (BLOCKADE_LOG) mame_printf_debug("Boom Start\n"); - sample_start(samples, 0,0,0); + samples->start(0,0); return; } diff --git a/src/mame/audio/carnival.c b/src/mame/audio/carnival.c index d864ddfa0bf..45d814e907e 100644 --- a/src/mame/audio/carnival.c +++ b/src/mame/audio/carnival.c @@ -75,8 +75,8 @@ #define PSG_BC_LATCH_ADDRESS ( MUSIC_PORT2_PSG_BDIR | MUSIC_PORT2_PSG_BC1 ) -#define PLAY(samp,id,loop) sample_start( samp, id, id, loop ) -#define STOP(samp,id) sample_stop( samp, id ) +#define PLAY(samp,id,loop) samp->start( id, id, loop ) +#define STOP(samp,id) samp->stop( id ) /* sample file names */ @@ -127,7 +127,7 @@ static int psgData = 0; WRITE8_HANDLER( carnival_audio_1_w ) { static int port1State = 0; - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int bitsChanged; int bitsGoneHigh; int bitsGoneLow; @@ -206,7 +206,7 @@ WRITE8_HANDLER( carnival_audio_1_w ) WRITE8_HANDLER( carnival_audio_2_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int bitsChanged; int bitsGoneHigh; int bitsGoneLow; @@ -306,7 +306,6 @@ MACHINE_CONFIG_FRAGMENT( carnival_audio ) MCFG_SOUND_ADD("psg", AY8910, PSG_CLOCK) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(carnival_samples_interface) + MCFG_SAMPLES_ADD("samples", carnival_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END diff --git a/src/mame/audio/cclimber.c b/src/mame/audio/cclimber.c index 497276fadc1..08f44b19f8a 100644 --- a/src/mame/audio/cclimber.c +++ b/src/mame/audio/cclimber.c @@ -15,7 +15,7 @@ static INT16 *samplebuf; /* buffer to decode samples at run time */ static SAMPLES_START( cclimber_sh_start ) { - running_machine &machine = device->machine(); + running_machine &machine = device.machine(); samplebuf = 0; if (machine.region("samples")->base()) samplebuf = auto_alloc_array(machine, INT16, 2 * machine.region("samples")->bytes()); @@ -27,7 +27,7 @@ static void cclimber_play_sample(running_machine &machine, int start,int freq,in int len; int romlen = machine.region("samples")->bytes(); const UINT8 *rom = machine.region("samples")->base(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); if (!rom) return; @@ -47,7 +47,7 @@ static void cclimber_play_sample(running_machine &machine, int start,int freq,in len++; } - sample_start_raw(samples,0,samplebuf,2 * len,freq,0); + samples->start_raw(0,samplebuf,2 * len,freq); } diff --git a/src/mame/audio/cinemat.c b/src/mame/audio/cinemat.c index 96d50cb56f8..76f1aa676f8 100644 --- a/src/mame/audio/cinemat.c +++ b/src/mame/audio/cinemat.c @@ -143,31 +143,31 @@ static const samples_interface spacewar_samples_interface = static void spacewar_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* Explosion - rising edge */ if (SOUNDVAL_RISING_EDGE(0x01)) - sample_start(samples, 0, (machine.rand() & 1) ? 0 : 6, 0); + samples->start(0, (machine.rand() & 1) ? 0 : 6); /* Fire sound - rising edge */ if (SOUNDVAL_RISING_EDGE(0x02)) - sample_start(samples, 1, (machine.rand() & 1) ? 1 : 7, 0); + samples->start(1, (machine.rand() & 1) ? 1 : 7); /* Player 1 thrust - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 3, 3, 1); + samples->start(3, 3, true); if (SOUNDVAL_RISING_EDGE(0x04)) - sample_stop(samples, 3); + samples->stop(3); /* Player 2 thrust - 0=on, 1-off */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 4, 4, 1); + samples->start(4, 4, true); if (SOUNDVAL_RISING_EDGE(0x08)) - sample_stop(samples, 4); + samples->stop(4); /* Mute - 0=off, 1=on */ if (SOUNDVAL_FALLING_EDGE(0x10)) - sample_start(samples, 2, 2, 1); /* play idle sound */ + samples->start(2, 2, true); /* play idle sound */ if (SOUNDVAL_RISING_EDGE(0x10)) { int i; @@ -175,10 +175,10 @@ static void spacewar_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bi /* turn off all but the idle sound */ for (i = 0; i < 5; i++) if (i != 2) - sample_stop(samples, i); + samples->stop(i); /* Pop when board is shut off */ - sample_start(samples, 2, 5, 0); + samples->start(2, 5); } } @@ -193,8 +193,7 @@ MACHINE_CONFIG_FRAGMENT( spacewar_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(spacewar_samples_interface) + MCFG_SAMPLES_ADD("samples", spacewar_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -223,19 +222,19 @@ static const samples_interface barrier_samples_interface = static void barrier_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* Player die - rising edge */ if (SOUNDVAL_RISING_EDGE(0x01)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* Player move - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* Enemy move - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); } static MACHINE_RESET( barrier ) @@ -249,8 +248,7 @@ MACHINE_CONFIG_FRAGMENT( barrier_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(barrier_samples_interface) + MCFG_SAMPLES_ADD("samples", barrier_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -278,7 +276,7 @@ static const samples_interface speedfrk_samples_interface = static void speedfrk_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* on the falling edge of bit 0x08, clock the inverse of bit 0x04 into the top of the shiftreg */ if (SOUNDVAL_FALLING_EDGE(0x08)) @@ -292,9 +290,9 @@ static void speedfrk_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bi /* off-road - 1=on, 0=off */ if (SOUNDVAL_RISING_EDGE(0x10)) - sample_start(samples, 0, 0, 1); + samples->start(0, 0, true); if (SOUNDVAL_FALLING_EDGE(0x10)) - sample_stop(samples, 0); + samples->stop(0); /* start LED is controlled by bit 0x02 */ set_led_status(machine, 0, ~sound_val & 0x02); @@ -311,8 +309,7 @@ MACHINE_CONFIG_FRAGMENT( speedfrk_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(speedfrk_samples_interface) + MCFG_SAMPLES_ADD("samples", speedfrk_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -344,37 +341,37 @@ static const samples_interface starhawk_samples_interface = static void starhawk_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x01)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* right laser - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* left laser - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); /* K - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 3, 3, 1); + samples->start(3, 3, true); if (SOUNDVAL_RISING_EDGE(0x08)) - sample_stop(samples, 3); + samples->stop(3); /* master - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x10)) - sample_start(samples, 4, 4, 1); + samples->start(4, 4, true); if (SOUNDVAL_RISING_EDGE(0x10)) - sample_stop(samples, 4); + samples->stop(4); /* K exit - 1=on, 0=off */ if (SOUNDVAL_RISING_EDGE(0x80)) - sample_start(samples, 3, 5, 1); + samples->start(3, 5, true); if (SOUNDVAL_FALLING_EDGE(0x80)) - sample_stop(samples, 3); + samples->stop(3); } static MACHINE_RESET( starhawk ) @@ -388,8 +385,7 @@ MACHINE_CONFIG_FRAGMENT( starhawk_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(starhawk_samples_interface) + MCFG_SAMPLES_ADD("samples", starhawk_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -421,31 +417,31 @@ static const samples_interface sundance_samples_interface = static void sundance_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* bong - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x01)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* whoosh - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); /* ping - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); /* ping - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x10)) - sample_start(samples, 4, 4, 0); + samples->start(4, 4); /* hatch - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x80)) - sample_start(samples, 5, 5, 0); + samples->start(5, 5); } static MACHINE_RESET( sundance ) @@ -459,8 +455,7 @@ MACHINE_CONFIG_FRAGMENT( sundance_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(sundance_samples_interface) + MCFG_SAMPLES_ADD("samples", sundance_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -496,40 +491,40 @@ static void tailg_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_ /* the falling edge of bit 0x10 clocks bit 0x08 into the mux selected by bits 0x07 */ if (SOUNDVAL_FALLING_EDGE(0x10)) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* update the shift register (actually just a simple mux) */ state->m_current_shift = (state->m_current_shift & ~(1 << (sound_val & 7))) | (((sound_val >> 3) & 1) << (sound_val & 7)); /* explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x01)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* rumble - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x02)) - sample_start(samples, 1, 1, 1); + samples->start(1, 1, true); if (SHIFTREG_RISING_EDGE(0x02)) - sample_stop(samples, 1); + samples->stop(1); /* laser - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x04)) - sample_start(samples, 2, 2, 1); + samples->start(2, 2, true); if (SHIFTREG_RISING_EDGE(0x04)) - sample_stop(samples, 2); + samples->stop(2); /* shield - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x08)) - sample_start(samples, 3, 3, 1); + samples->start(3, 3, true); if (SHIFTREG_RISING_EDGE(0x08)) - sample_stop(samples, 3); + samples->stop(3); /* bounce - falling edge */ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 4, 4, 0); + samples->start(4, 4); /* hyperspace - falling edge */ if (SHIFTREG_FALLING_EDGE(0x20)) - sample_start(samples, 5, 5, 0); + samples->start(5, 5); /* LED */ set_led_status(machine, 0, state->m_current_shift & 0x40); @@ -550,8 +545,7 @@ MACHINE_CONFIG_FRAGMENT( tailg_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(tailg_samples_interface) + MCFG_SAMPLES_ADD("samples", tailg_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -582,31 +576,31 @@ static const samples_interface warrior_samples_interface = static void warrior_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* normal level - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x01)) - sample_start(samples, 0, 0, 1); + samples->start(0, 0, true); if (SOUNDVAL_RISING_EDGE(0x01)) - sample_stop(samples, 0); + samples->stop(0); /* hi level - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 1, 1, 1); + samples->start(1, 1, true); if (SOUNDVAL_RISING_EDGE(0x02)) - sample_stop(samples, 1); + samples->stop(1); /* explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); /* fall - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); /* appear - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x10)) - sample_start(samples, 4, 4, 0); + samples->start(4, 4); } static MACHINE_RESET( warrior ) @@ -620,8 +614,7 @@ MACHINE_CONFIG_FRAGMENT( warrior_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(warrior_samples_interface) + MCFG_SAMPLES_ADD("samples", warrior_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -655,7 +648,7 @@ static const samples_interface armora_samples_interface = static void armora_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) @@ -668,19 +661,19 @@ static void armora_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits /* lo explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* jeep fire - falling edge */ if (SHIFTREG_FALLING_EDGE(0x20)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* hi explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x40)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); /* tank fire - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); /* remember the previous value */ state->m_last_shift = state->m_current_shift; @@ -689,21 +682,21 @@ static void armora_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits /* tank sound - 0=on, 1=off */ /* still not totally correct - should be multiple speeds based on remaining bits in shift reg */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 4, 4, 1); + samples->start(4, 4, true); if (SOUNDVAL_RISING_EDGE(0x02)) - sample_stop(samples, 4); + samples->stop(4); /* beep sound - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 5, 5, 1); + samples->start(5, 5, true); if (SOUNDVAL_RISING_EDGE(0x04)) - sample_stop(samples, 5); + samples->stop(5); /* chopper sound - 0=on, 1=off */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 6, 6, 1); + samples->start(6, 6, true); if (SOUNDVAL_RISING_EDGE(0x08)) - sample_stop(samples, 6); + samples->stop(6); } static MACHINE_RESET( armora ) @@ -717,8 +710,7 @@ MACHINE_CONFIG_FRAGMENT( armora_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(armora_samples_interface) + MCFG_SAMPLES_ADD("samples", armora_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -758,7 +750,7 @@ static const samples_interface ripoff_samples_interface = static void ripoff_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* on the rising edge of bit 0x02, clock bit 0x01 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x02)) @@ -769,19 +761,19 @@ static void ripoff_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits { /* background - 0=on, 1=off, selected by bits 0x38 */ if ((((state->m_current_shift ^ state->m_last_shift) & 0x38) && !(state->m_current_shift & 0x04)) || SHIFTREG_FALLING_EDGE(0x04)) - sample_start(samples, 5, 5 + ((state->m_current_shift >> 5) & 7), 1); + samples->start(5, 5 + ((state->m_current_shift >> 5) & 7), true); if (SHIFTREG_RISING_EDGE(0x04)) - sample_stop(samples, 5); + samples->stop(5); /* beep - falling edge */ if (SHIFTREG_FALLING_EDGE(0x02)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* motor - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x01)) - sample_start(samples, 1, 1, 1); + samples->start(1, 1, true); if (SHIFTREG_RISING_EDGE(0x01)) - sample_stop(samples, 1); + samples->stop(1); /* remember the previous value */ state->m_last_shift = state->m_current_shift; @@ -789,15 +781,15 @@ static void ripoff_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits /* torpedo - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); /* laser - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x10)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); /* explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x80)) - sample_start(samples, 4, 4, 0); + samples->start(4, 4); } static MACHINE_RESET( ripoff ) @@ -811,8 +803,7 @@ MACHINE_CONFIG_FRAGMENT( ripoff_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(ripoff_samples_interface) + MCFG_SAMPLES_ADD("samples", ripoff_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -847,7 +838,7 @@ static const samples_interface starcas_samples_interface = static void starcas_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); UINT32 target_pitch; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ @@ -859,29 +850,29 @@ static void starcas_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bit { /* fireball - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* shield hit - falling edge */ if (SHIFTREG_FALLING_EDGE(0x40)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* star sound - 0=off, 1=on */ if (SHIFTREG_RISING_EDGE(0x20)) - sample_start(samples, 2, 2, 1); + samples->start(2, 2, true); if (SHIFTREG_FALLING_EDGE(0x20)) - sample_stop(samples, 2); + samples->stop(2); /* thrust sound - 1=off, 0=on*/ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 3, 3, 1); + samples->start(3, 3, true); if (SHIFTREG_RISING_EDGE(0x10)) - sample_stop(samples, 3); + samples->stop(3); /* drone - 1=off, 0=on */ if (SHIFTREG_FALLING_EDGE(0x08)) - sample_start(samples, 4, 4, 1); + samples->start(4, 4, true); if (SHIFTREG_RISING_EDGE(0x08)) - sample_stop(samples, 4); + samples->stop(4); /* latch the drone pitch */ target_pitch = (state->m_current_shift & 7) + ((state->m_current_shift & 2) << 2); @@ -894,7 +885,7 @@ static void starcas_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bit state->m_current_pitch -= 225; if (state->m_current_pitch < target_pitch) state->m_current_pitch += 150; - sample_set_freq(samples, 4, state->m_current_pitch); + samples->set_frequency(4, state->m_current_pitch); state->m_last_frame = machine.primary_screen->frame_number(); } @@ -904,15 +895,15 @@ static void starcas_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bit /* loud explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 5, 5, 0); + samples->start(5, 5); /* soft explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 6, 6, 0); + samples->start(6, 6); /* player fire - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 7, 7, 0); + samples->start(7, 7); } static MACHINE_RESET( starcas ) @@ -926,8 +917,7 @@ MACHINE_CONFIG_FRAGMENT( starcas_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(starcas_samples_interface) + MCFG_SAMPLES_ADD("samples", starcas_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_CONFIG_END @@ -962,7 +952,7 @@ static const samples_interface solarq_samples_interface = static void solarq_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) @@ -976,53 +966,53 @@ static void solarq_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits /* loud explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* soft explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x40)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* thrust - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x20)) { state->m_target_volume = 1.0; - if (!sample_playing(samples, 2)) - sample_start(samples, 2, 2, 1); + if (!samples->playing(2)) + samples->start(2, 2, true); } if (SHIFTREG_RISING_EDGE(0x20)) state->m_target_volume = 0; /* ramp the thrust volume */ - if (sample_playing(samples, 2) && machine.primary_screen->frame_number() > state->m_last_frame) + if (samples->playing(2) && machine.primary_screen->frame_number() > state->m_last_frame) { if (state->m_current_volume > state->m_target_volume) state->m_current_volume -= 0.078f; if (state->m_current_volume < state->m_target_volume) state->m_current_volume += 0.078f; if (state->m_current_volume > 0) - sample_set_volume(samples, 2, state->m_current_volume); + samples->set_volume(2, state->m_current_volume); else - sample_stop(samples, 2); + samples->stop(2); state->m_last_frame = machine.primary_screen->frame_number(); } /* fire - falling edge */ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); /* capture - falling edge */ if (SHIFTREG_FALLING_EDGE(0x08)) - sample_start(samples, 4, 4, 0); + samples->start(4, 4); /* nuke - 1=on, 0=off */ if (SHIFTREG_RISING_EDGE(0x04)) - sample_start(samples, 5, 5, 1); + samples->start(5, 5, true); if (SHIFTREG_FALLING_EDGE(0x04)) - sample_stop(samples, 5); + samples->stop(5); /* photon - falling edge */ if (SHIFTREG_FALLING_EDGE(0x02)) - sample_start(samples, 6, 6, 0); + samples->start(6, 6); /* remember the previous value */ state->m_last_shift = state->m_current_shift; @@ -1035,17 +1025,17 @@ static void solarq_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits /* start/stop the music sample on the high bit */ if (SHIFTREG2_RISING_EDGE(0x8000)) - sample_start(samples, 7, 7, 1); + samples->start(7, 7, true); if (SHIFTREG2_FALLING_EDGE(0x8000)) - sample_stop(samples, 7); + samples->stop(7); /* set the frequency */ freq = 56818.181818 / (4096 - (state->m_current_shift & 0xfff)); - sample_set_freq(samples, 7, 44100 * freq / 1050); + samples->set_frequency(7, 44100 * freq / 1050); /* set the volume */ vol = (~state->m_current_shift >> 12) & 7; - sample_set_volume(samples, 7, vol / 7.0); + samples->set_volume(7, vol / 7.0); /* remember the previous value */ state->m_last_shift2 = state->m_current_shift; @@ -1063,8 +1053,7 @@ MACHINE_CONFIG_FRAGMENT( solarq_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(solarq_samples_interface) + MCFG_SAMPLES_ADD("samples", solarq_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_CONFIG_END @@ -1103,7 +1092,7 @@ static const samples_interface boxingb_samples_interface = static void boxingb_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ if (SOUNDVAL_RISING_EDGE(0x10)) @@ -1117,37 +1106,37 @@ static void boxingb_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bit /* soft explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* loud explosion - falling edge */ if (SHIFTREG_FALLING_EDGE(0x40)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* chirping birds - 0=on, 1=off */ if (SHIFTREG_FALLING_EDGE(0x20)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); if (SHIFTREG_RISING_EDGE(0x20)) - sample_stop(samples, 2); + samples->stop(2); /* egg cracking - falling edge */ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); /* bug pushing A - rising edge */ if (SHIFTREG_RISING_EDGE(0x08)) - sample_start(samples, 4, 4, 0); + samples->start(4, 4); /* bug pushing B - rising edge */ if (SHIFTREG_RISING_EDGE(0x04)) - sample_start(samples, 5, 5, 0); + samples->start(5, 5); /* bug dying - falling edge */ if (SHIFTREG_FALLING_EDGE(0x02)) - sample_start(samples, 6, 6, 0); + samples->start(6, 6); /* beetle on screen - falling edge */ if (SHIFTREG_FALLING_EDGE(0x01)) - sample_start(samples, 7, 7, 0); + samples->start(7, 7); /* remember the previous value */ state->m_last_shift = state->m_current_shift; @@ -1160,21 +1149,21 @@ static void boxingb_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bit /* start/stop the music sample on the high bit */ if (SHIFTREG2_RISING_EDGE(0x8000)) - sample_start(samples, 8, 8, 1); + samples->start(8, 8, true); if (SHIFTREG2_FALLING_EDGE(0x8000)) - sample_stop(samples, 8); + samples->stop(8); /* set the frequency */ freq = 56818.181818 / (4096 - (state->m_current_shift & 0xfff)); - sample_set_freq(samples, 8, 44100 * freq / 1050); + samples->set_frequency(8, 44100 * freq / 1050); /* set the volume */ vol = (~state->m_current_shift >> 12) & 3; - sample_set_volume(samples, 8, vol / 3.0); + samples->set_volume(8, vol / 3.0); /* cannon - falling edge */ if (SHIFTREG2_RISING_EDGE(0x4000)) - sample_start(samples, 9, 9, 0); + samples->start(9, 9); /* remember the previous value */ state->m_last_shift2 = state->m_current_shift; @@ -1182,11 +1171,11 @@ static void boxingb_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bit /* bounce - rising edge */ if (SOUNDVAL_RISING_EDGE(0x04)) - sample_start(samples, 10, 10, 0); + samples->start(10, 10); /* bell - falling edge */ if (SOUNDVAL_RISING_EDGE(0x08)) - sample_start(samples, 11, 11, 0); + samples->start(11, 11); } static MACHINE_RESET( boxingb ) @@ -1200,8 +1189,7 @@ MACHINE_CONFIG_FRAGMENT( boxingb_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(boxingb_samples_interface) + MCFG_SAMPLES_ADD("samples", boxingb_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -1236,7 +1224,7 @@ static const samples_interface wotw_samples_interface = static void wotw_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); UINT32 target_pitch; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ @@ -1248,29 +1236,29 @@ static void wotw_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_c { /* fireball - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* shield hit - falling edge */ if (SHIFTREG_FALLING_EDGE(0x40)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* star sound - 0=off, 1=on */ if (SHIFTREG_RISING_EDGE(0x20)) - sample_start(samples, 2, 2, 1); + samples->start(2, 2, true); if (SHIFTREG_FALLING_EDGE(0x20)) - sample_stop(samples, 2); + samples->stop(2); /* thrust sound - 1=off, 0=on*/ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 3, 3, 1); + samples->start(3, 3, true); if (SHIFTREG_RISING_EDGE(0x10)) - sample_stop(samples, 3); + samples->stop(3); /* drone - 1=off, 0=on */ if (SHIFTREG_FALLING_EDGE(0x08)) - sample_start(samples, 4, 4, 1); + samples->start(4, 4, true); if (SHIFTREG_RISING_EDGE(0x08)) - sample_stop(samples, 4); + samples->stop(4); /* latch the drone pitch */ target_pitch = (state->m_current_shift & 7) + ((state->m_current_shift & 2) << 2); @@ -1283,7 +1271,7 @@ static void wotw_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_c state->m_current_pitch -= 300; if (state->m_current_pitch < target_pitch) state->m_current_pitch += 200; - sample_set_freq(samples, 4, state->m_current_pitch); + samples->set_frequency(4, state->m_current_pitch); state->m_last_frame = machine.primary_screen->frame_number(); } @@ -1293,15 +1281,15 @@ static void wotw_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_c /* loud explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 5, 5, 0); + samples->start(5, 5); /* soft explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 6, 6, 0); + samples->start(6, 6); /* player fire - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 7, 7, 0); + samples->start(7, 7); } static MACHINE_RESET( wotw ) @@ -1315,8 +1303,7 @@ MACHINE_CONFIG_FRAGMENT( wotw_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(wotw_samples_interface) + MCFG_SAMPLES_ADD("samples", wotw_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -1351,7 +1338,7 @@ static const samples_interface wotwc_samples_interface = static void wotwc_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_changed) { cinemat_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); UINT32 target_pitch; /* on the rising edge of bit 0x10, clock bit 0x80 into the shift register */ @@ -1363,29 +1350,29 @@ static void wotwc_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_ { /* fireball - falling edge */ if (SHIFTREG_FALLING_EDGE(0x80)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); /* shield hit - falling edge */ if (SHIFTREG_FALLING_EDGE(0x40)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); /* star sound - 0=off, 1=on */ if (SHIFTREG_RISING_EDGE(0x20)) - sample_start(samples, 2, 2, 1); + samples->start(2, 2, true); if (SHIFTREG_FALLING_EDGE(0x20)) - sample_stop(samples, 2); + samples->stop(2); /* thrust sound - 1=off, 0=on*/ if (SHIFTREG_FALLING_EDGE(0x10)) - sample_start(samples, 3, 3, 1); + samples->start(3, 3, true); if (SHIFTREG_RISING_EDGE(0x10)) - sample_stop(samples, 3); + samples->stop(3); /* drone - 1=off, 0=on */ if (SHIFTREG_FALLING_EDGE(0x08)) - sample_start(samples, 4, 4, 1); + samples->start(4, 4, true); if (SHIFTREG_RISING_EDGE(0x08)) - sample_stop(samples, 4); + samples->stop(4); /* latch the drone pitch */ target_pitch = (state->m_current_shift & 7) + ((state->m_current_shift & 2) << 2); @@ -1398,7 +1385,7 @@ static void wotwc_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_ state->m_current_pitch -= 300; if (state->m_current_pitch < target_pitch) state->m_current_pitch += 200; - sample_set_freq(samples, 4, state->m_current_pitch); + samples->set_frequency(4, state->m_current_pitch); state->m_last_frame = machine.primary_screen->frame_number(); } @@ -1408,15 +1395,15 @@ static void wotwc_sound_w(running_machine &machine, UINT8 sound_val, UINT8 bits_ /* loud explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x02)) - sample_start(samples, 5, 5, 0); + samples->start(5, 5); /* soft explosion - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x04)) - sample_start(samples, 6, 6, 0); + samples->start(6, 6); /* player fire - falling edge */ if (SOUNDVAL_FALLING_EDGE(0x08)) - sample_start(samples, 7, 7, 0); + samples->start(7, 7); } static MACHINE_RESET( wotwc ) @@ -1430,8 +1417,7 @@ MACHINE_CONFIG_FRAGMENT( wotwc_sound ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(wotwc_samples_interface) + MCFG_SAMPLES_ADD("samples", wotwc_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/audio/circus.c b/src/mame/audio/circus.c index 436cd720642..8cb054b9181 100644 --- a/src/mame/audio/circus.c +++ b/src/mame/audio/circus.c @@ -193,26 +193,26 @@ WRITE8_HANDLER( circus_clown_z_w ) break; case 2 : /* Circus = Pop; Rip Cord = Splash */ - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); break; case 3 : /* Normal Video */ break; case 4 : /* Circus = Miss; Rip Cord = Scream */ - sample_start(state->m_samples, 1, 1, 0); + state->m_samples->start(1, 1); break; case 5 : /* Invert Video */ break; case 6 : /* Circus = Bounce; Rip Cord = Chute Open */ - sample_start(state->m_samples, 2, 2, 0); + state->m_samples->start(2, 2); break; case 7 : /* Circus = not used; Rip Cord = Whistle */ if (state->m_game_id == 4) - sample_start(state->m_samples, 3, 3, 0); + state->m_samples->start(3, 3); break; } break; @@ -221,19 +221,19 @@ WRITE8_HANDLER( circus_clown_z_w ) discrete_sound_w(state->m_discrete, ROBOTBWL_MUSIC_BIT, data & 0x08); /* Footsteps */ if (data & 0x40) /* Hit */ - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); if (data & 0x20) /* Roll */ - sample_start(state->m_samples, 1, 1, 0); + state->m_samples->start(1, 1); if (data & 0x10) /* Ball Drop */ - sample_start(state->m_samples, 2, 2, 0); + state->m_samples->start(2, 2); if (data & 0x02) /* Demerit */ - sample_start(state->m_samples, 3, 3, 0); + state->m_samples->start(3, 3); if (data & 0x01) /* Reward */ - sample_start(state->m_samples, 4, 4, 0); + state->m_samples->start(4, 4); // if (data & 0x04) /* Invert */ break; @@ -251,7 +251,7 @@ WRITE8_HANDLER( circus_clown_z_w ) break; case 2 : /* Crash */ - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); break; case 3 : /* Normal Video and Beep */ diff --git a/src/mame/audio/depthch.c b/src/mame/audio/depthch.c index 30cb64835d4..8e243ac975a 100644 --- a/src/mame/audio/depthch.c +++ b/src/mame/audio/depthch.c @@ -13,8 +13,8 @@ #define OUT_PORT_1_SONAR 0x08 -#define PLAY(samp,id,loop) sample_start( samp, id, id, loop ) -#define STOP(samp,id) sample_stop( samp, id ) +#define PLAY(samp,id,loop) samp->start( id, id, loop ) +#define STOP(samp,id) samp->stop( id ) /* sample file names */ @@ -37,8 +37,7 @@ static const samples_interface depthch_samples_interface = MACHINE_CONFIG_FRAGMENT( depthch_audio ) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(depthch_samples_interface) + MCFG_SAMPLES_ADD("samples", depthch_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_CONFIG_END @@ -56,7 +55,7 @@ enum WRITE8_HANDLER( depthch_audio_w ) { static int port1State = 0; - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int bitsChanged; int bitsGoneHigh; int bitsGoneLow; diff --git a/src/mame/audio/gorf.c b/src/mame/audio/gorf.c index 78e4381a387..de1368dc730 100644 --- a/src/mame/audio/gorf.c +++ b/src/mame/audio/gorf.c @@ -112,7 +112,7 @@ const char *const gorf_sample_names[] = READ8_HANDLER( gorf_speech_r ) { astrocde_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int Phoneme, Intonation; int i = 0; UINT8 data = offset >> 8; @@ -126,7 +126,7 @@ READ8_HANDLER( gorf_speech_r ) logerror("Date : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation); if(Phoneme==63) { - sample_stop(samples, 0); + samples->stop(0); if (strlen(state->m_totalword)>2) logerror("Clearing sample %s\n",state->m_totalword); state->m_totalword[0] = 0; /* Clear the total word stack */ return data; @@ -139,8 +139,8 @@ READ8_HANDLER( gorf_speech_r ) if (state->m_plural != 0) { logerror("found a possible plural at %d\n",state->m_plural-1); if (!strcmp("S",state->m_totalword)) { /* Plural check */ - sample_start(samples, 0, num_samples-2, 0); /* play the sample at position of word */ - sample_set_freq(samples, 0, 11025); /* play at correct rate */ + samples->start(0, num_samples-2); /* play the sample at position of word */ + samples->set_frequency(0, 11025); /* play at correct rate */ state->m_totalword[0] = 0; /* Clear the total word stack */ state->m_oldword[0] = 0; /* Clear the total word stack */ return data; @@ -162,8 +162,8 @@ READ8_HANDLER( gorf_speech_r ) } else { state->m_plural=0; } - sample_start(samples, 0, i, 0); /* play the sample at position of word */ - sample_set_freq(samples, 0, 11025); /* play at correct rate */ + samples->start(0, i); /* play the sample at position of word */ + samples->set_frequency(0, 11025); /* play at correct rate */ logerror("Playing sample %d",i); state->m_totalword[0] = 0; /* Clear the total word stack */ return data; @@ -177,6 +177,6 @@ READ8_HANDLER( gorf_speech_r ) CUSTOM_INPUT( gorf_speech_status_r ) { - device_t *samples = field.machine().device("samples"); - return !sample_playing(samples, 0); + samples_device *samples = field.machine().device("samples"); + return !samples->playing(0); } diff --git a/src/mame/audio/gottlieb.c b/src/mame/audio/gottlieb.c index 1310839b635..1eb16a71b0b 100644 --- a/src/mame/audio/gottlieb.c +++ b/src/mame/audio/gottlieb.c @@ -31,7 +31,7 @@ static void gottlieb1_sh_w(device_t *riot, UINT8 data); static void gottlieb2_sh_w(address_space *space, UINT8 data); -static void trigger_sample(device_t *samples, UINT8 data); +static void trigger_sample(samples_device *samples, UINT8 data); @@ -62,7 +62,7 @@ WRITE8_HANDLER( gottlieb_sh_w ) static void gottlieb1_sh_w(device_t *riot, UINT8 data) { - device_t *samples = riot->machine().device("samples"); + samples_device *samples = riot->machine().device("samples"); int pa7 = (data & 0x0f) != 0xf; int pa0_5 = ~data & 0x3f; @@ -112,24 +112,24 @@ static const riot6532_interface gottlieb_riot6532_intf = * *************************************/ -static void play_sample(device_t *samples, const char *phonemes) +static void play_sample(samples_device *samples, const char *phonemes) { if (strcmp(phonemes, "[0] HEH3LOOW AH1EH3I3YMTERI2NDAHN") == 0) /* Q-Bert - Hello, I am turned on */ - sample_start(samples, 0, 42, 0); + samples->start(0, 42); else if (strcmp(phonemes, "[0]BAH1EH1Y") == 0) /* Q-Bert - Bye, bye */ - sample_start(samples, 0, 43, 0); + samples->start(0, 43); else if (strcmp(phonemes, "[0]A2YHT LEH2FTTH") == 0) /* Reactor - Eight left */ - sample_start(samples, 0, 0, 0); + samples->start(0, 0); else if (strcmp(phonemes, "[0]SI3KS DTYN LEH2FTTH") == 0) /* Reactor - Sixteen left */ - sample_start(samples, 0, 1, 0); + samples->start(0, 1); else if (strcmp(phonemes, "[0]WO2RNYNG KO2R UH1NSDTABUH1L") == 0) /* Reactor - Warning core unstable */ - sample_start(samples, 0, 5, 0); + samples->start(0, 5); else if (strcmp(phonemes, "[0]CHAMBERR AE1EH2KTI1VA1I3DTEH1DT ") == 0) /* Reactor - Chamber activated */ - sample_start(samples, 0, 7, 0); + samples->start(0, 7); } -static void trigger_sample(device_t *samples, UINT8 data) +static void trigger_sample(samples_device *samples, UINT8 data) { gottlieb_state *state = samples->machine().driver_data(); /* Reactor samples */ @@ -141,7 +141,7 @@ static void trigger_sample(device_t *samples, UINT8 data) case 56: case 57: case 59: - sample_start(samples, 0, data - 53, 0); + samples->start(0, data - 53); break; case 31: @@ -151,7 +151,7 @@ static void trigger_sample(device_t *samples, UINT8 data) case 39: state->m_score_sample++; if (state->m_score_sample < 20) - sample_start(samples, 0, state->m_score_sample, 0); + samples->start(0, state->m_score_sample); break; } } @@ -166,16 +166,16 @@ static void trigger_sample(device_t *samples, UINT8 data) case 19: case 20: case 21: - sample_start(samples, 0, (data - 17) * 8 + state->m_random_offset, 0); + samples->start(0, (data - 17) * 8 + state->m_random_offset); state->m_random_offset = (state->m_random_offset + 1) & 7; break; case 22: - sample_start(samples, 0,40,0); + samples->start(0,40); break; case 23: - sample_start(samples, 0,41,0); + samples->start(0,41); break; } } @@ -185,12 +185,12 @@ static void trigger_sample(device_t *samples, UINT8 data) #ifdef UNUSED_FUNCTION void gottlieb_knocker(running_machine &machine) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); if (!strcmp(machine.system().name,"reactor")) /* reactor */ { } else if (samples != NULL) /* qbert */ - sample_start(samples, 0,44,0); + samples->start(0,44); } #endif @@ -234,7 +234,7 @@ logerror("Votrax: intonation %d, phoneme %02x %s\n",data >> 6,data & 0x3f,Phonem { if (state->m_votrax_queuepos > 1) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int last = -1; int i; char phonemes[200]; diff --git a/src/mame/audio/gotya.c b/src/mame/audio/gotya.c index c189063c6ed..711e19e1545 100644 --- a/src/mame/audio/gotya.c +++ b/src/mame/audio/gotya.c @@ -46,7 +46,7 @@ WRITE8_HANDLER( gotya_soundlatch_w ) if (data == 0) { - sample_stop(state->m_samples, 0); + state->m_samples->stop(0); state->m_theme_playing = 0; return; } @@ -62,7 +62,7 @@ WRITE8_HANDLER( gotya_soundlatch_w ) return; } - sample_start(state->m_samples, gotya_samples[sample_number].channel, sample_number, gotya_samples[sample_number].looping); + state->m_samples->start(gotya_samples[sample_number].channel, sample_number, gotya_samples[sample_number].looping); if (gotya_samples[sample_number].channel == 0) { diff --git a/src/mame/audio/gridlee.c b/src/mame/audio/gridlee.c index 4fd7597de1c..5df0408d863 100644 --- a/src/mame/audio/gridlee.c +++ b/src/mame/audio/gridlee.c @@ -24,7 +24,7 @@ struct gridlee_sound_state /* sound streaming variables */ sound_stream *m_stream; - device_t *m_samples; + samples_device *m_samples; double m_freq_to_step; UINT8 m_sound_data[24]; }; @@ -74,7 +74,7 @@ static DEVICE_START( gridlee_sound ) /* allocate the stream */ state->m_stream = device->machine().sound().stream_alloc(*device, 0, 1, machine.sample_rate(), NULL, gridlee_stream_update); - state->m_samples = device->machine().device("samples"); + state->m_samples = device->machine().device("samples"); state->m_freq_to_step = (double)(1 << 24) / (double)machine.sample_rate(); } @@ -102,7 +102,7 @@ WRITE8_DEVICE_HANDLER( gridlee_sound_w ) { gridlee_sound_state *state = get_safe_token(device); UINT8 *sound_data = state->m_sound_data; - device_t *samples = state->m_samples; + samples_device *samples = state->m_samples; state->m_stream->update(); @@ -110,13 +110,13 @@ WRITE8_DEVICE_HANDLER( gridlee_sound_w ) { case 0x04: if (data == 0xef && sound_data[offset] != 0xef) - sample_start(samples, 4, 1, 0); + samples->start(4, 1); else if (data != 0xef && sound_data[offset] == 0xef) - sample_stop(samples, 4); + samples->stop(4); // if (!(data & 0x01) && (sound_data[offset] & 0x01)) -// sample_start(samples, 5, 1, 0); +// samples->start(5, 1); // else if ((data & 0x01) && !(sound_data[offset] & 0x01)) -// sample_stop(samples, 5); +// samples->stop(5); break; case 0x0c: @@ -124,9 +124,9 @@ WRITE8_DEVICE_HANDLER( gridlee_sound_w ) case 0x0e: case 0x0f: if ((data & 1) && !(sound_data[offset] & 1)) - sample_start(samples, offset - 0x0c, 1 - sound_data[offset - 4], 0); + samples->start(offset - 0x0c, 1 - sound_data[offset - 4]); else if (!(data & 1) && (sound_data[offset] & 1)) - sample_stop(samples, offset - 0x0c); + samples->stop(offset - 0x0c); break; case 0x08+0x08: diff --git a/src/mame/audio/invinco.c b/src/mame/audio/invinco.c index 3f002719547..92e48c849c5 100644 --- a/src/mame/audio/invinco.c +++ b/src/mame/audio/invinco.c @@ -15,8 +15,8 @@ #define OUT_PORT_2_SHIPHIT 0x80 -#define PLAY(samp,id,loop) sample_start( samp, id, id, loop ) -#define STOP(samp,id) sample_stop( samp, id ) +#define PLAY(samp,id,loop) samp->start( id, id, loop ) +#define STOP(samp,id) samp->stop( id ) /* sample file names */ @@ -43,8 +43,7 @@ static const samples_interface invinco_samples_interface = MACHINE_CONFIG_FRAGMENT( invinco_audio ) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(invinco_samples_interface) + MCFG_SAMPLES_ADD("samples", invinco_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_CONFIG_END @@ -66,7 +65,7 @@ enum WRITE8_HANDLER( invinco_audio_w ) { static int port2State = 0; - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int bitsChanged; //int bitsGoneHigh; int bitsGoneLow; diff --git a/src/mame/audio/meadows.c b/src/mame/audio/meadows.c index ad998c2c586..c4134c1149d 100644 --- a/src/mame/audio/meadows.c +++ b/src/mame/audio/meadows.c @@ -30,7 +30,7 @@ static const INT16 waveform[2] = { -120*256, 120*256 }; /************************************/ SAMPLES_START( meadows_sh_start ) { - meadows_state *state = device->machine().driver_data(); + meadows_state *state = device.machine().driver_data(); state->m_0c00 = state->m_0c01 = state->m_0c02 = state->m_0c03 = 0; state->m_dac = 0; state->m_dac_enable = 0; @@ -38,10 +38,10 @@ SAMPLES_START( meadows_sh_start ) state->m_freq1 = state->m_freq2 = 1000; state->m_latched_0c01 = state->m_latched_0c02 = state->m_latched_0c03 = 0; - sample_set_volume(device,0,0); - sample_start_raw(device,0,waveform,ARRAY_LENGTH(waveform),state->m_freq1,1); - sample_set_volume(device,1,0); - sample_start_raw(device,1,waveform,ARRAY_LENGTH(waveform),state->m_freq2,1); + device.set_volume(0,0); + device.start_raw(0,waveform,ARRAY_LENGTH(waveform),state->m_freq1,true); + device.set_volume(1,0); + device.start_raw(1,waveform,ARRAY_LENGTH(waveform),state->m_freq2,true); } /************************************/ @@ -50,7 +50,7 @@ SAMPLES_START( meadows_sh_start ) void meadows_sh_update(running_machine &machine) { meadows_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); int preset, amp; if (state->m_latched_0c01 != state->m_0c01 || state->m_latched_0c03 != state->m_0c03) @@ -67,8 +67,8 @@ void meadows_sh_update(running_machine &machine) state->m_freq1 = BASE_CTR1 / (preset + 1); else amp = 0; logerror("meadows ctr1 channel #%d preset:%3d freq:%5d amp:%d\n", state->m_channel, preset, state->m_freq1, amp); - sample_set_freq(samples, 0, state->m_freq1 * sizeof(waveform)/2); - sample_set_volume(samples, 0,amp/255.0); + samples->set_frequency(0, state->m_freq1 * sizeof(waveform)/2); + samples->set_volume(0,amp/255.0); } if (state->m_latched_0c02 != state->m_0c02 || state->m_latched_0c03 != state->m_0c03) @@ -85,8 +85,8 @@ void meadows_sh_update(running_machine &machine) } else amp = 0; logerror("meadows ctr2 channel #%d preset:%3d freq:%5d amp:%d\n", state->m_channel+1, preset, state->m_freq2, amp); - sample_set_freq(samples, 1, state->m_freq2 * sizeof(waveform)); - sample_set_volume(samples, 1,amp/255.0); + samples->set_frequency(1, state->m_freq2 * sizeof(waveform)); + samples->set_volume(1,amp/255.0); } if (state->m_latched_0c03 != state->m_0c03) diff --git a/src/mame/audio/mw8080bw.c b/src/mame/audio/mw8080bw.c index deceba79773..c8624aa7a58 100644 --- a/src/mame/audio/mw8080bw.c +++ b/src/mame/audio/mw8080bw.c @@ -157,8 +157,7 @@ MACHINE_CONFIG_FRAGMENT( seawolf_audio ) MCFG_SOUND_START(samples) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(seawolf_samples_interface) + MCFG_SAMPLES_ADD("samples", seawolf_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.6) MACHINE_CONFIG_END @@ -169,19 +168,19 @@ WRITE8_HANDLER( seawolf_audio_w ) UINT8 rising_bits = data & ~state->m_port_1_last; /* if (data & 0x01) enable SHIP HIT sound */ - if (rising_bits & 0x01) sample_start(state->m_samples, 0, 0, 0); + if (rising_bits & 0x01) state->m_samples->start(0, 0); /* if (data & 0x02) enable TORPEDO sound */ - if (rising_bits & 0x02) sample_start(state->m_samples, 1, 1, 0); + if (rising_bits & 0x02) state->m_samples->start(1, 1); /* if (data & 0x04) enable DIVE sound */ - if (rising_bits & 0x04) sample_start(state->m_samples, 2, 2, 0); + if (rising_bits & 0x04) state->m_samples->start(2, 2); /* if (data & 0x08) enable SONAR sound */ - if (rising_bits & 0x08) sample_start(state->m_samples, 3, 3, 0); + if (rising_bits & 0x08) state->m_samples->start(3, 3); /* if (data & 0x10) enable MINE HIT sound */ - if (rising_bits & 0x10) sample_start(state->m_samples, 4, 4, 0); + if (rising_bits & 0x10) state->m_samples->start(4, 4); coin_counter_w(space->machine(), 0, (data >> 5) & 0x01); @@ -219,12 +218,10 @@ MACHINE_CONFIG_FRAGMENT( gunfight_audio ) MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MCFG_SOUND_ADD("samples1", SAMPLES, 0) - MCFG_SOUND_CONFIG(gunfight_samples_interface) + MCFG_SAMPLES_ADD("samples1", gunfight_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) - MCFG_SOUND_ADD("samples2", SAMPLES, 0) - MCFG_SOUND_CONFIG(gunfight_samples_interface) + MCFG_SAMPLES_ADD("samples2", gunfight_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_CONFIG_END @@ -245,22 +242,22 @@ WRITE8_HANDLER( gunfight_audio_w ) case 0x01: /* enable LEFT SHOOT sound (left speaker) */ - sample_start(state->m_samples1, 0, 0, 0); + state->m_samples1->start(0, 0); break; case 0x02: /* enable RIGHT SHOOT sound (right speaker) */ - sample_start(state->m_samples2, 0, 0, 0); + state->m_samples2->start(0, 0); break; case 0x03: /* enable LEFT HIT sound (left speaker) */ - sample_start(state->m_samples1, 0, 1, 0); + state->m_samples1->start(0, 1); break; case 0x04: /* enable RIGHT HIT sound (right speaker) */ - sample_start(state->m_samples2, 0, 1, 0); + state->m_samples2->start(0, 1); break; default: @@ -1577,12 +1574,10 @@ MACHINE_CONFIG_FRAGMENT( gmissile_audio ) MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MCFG_SOUND_ADD("samples1", SAMPLES, 0) - MCFG_SOUND_CONFIG(gmissile_samples_interface) + MCFG_SAMPLES_ADD("samples1", gmissile_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.9) - MCFG_SOUND_ADD("samples2", SAMPLES, 0) - MCFG_SOUND_CONFIG(gmissile_samples_interface) + MCFG_SAMPLES_ADD("samples2", gmissile_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.9) MACHINE_CONFIG_END @@ -1603,18 +1598,18 @@ WRITE8_HANDLER( gmissile_audio_1_w ) space->machine().sound().system_enable((data >> 3) & 0x01); /* if (data & 0x10) enable RIGHT MISSILE sound (goes to right speaker) */ - if (rising_bits & 0x10) sample_start(state->m_samples2, 0, 0, 0); + if (rising_bits & 0x10) state->m_samples2->start(0, 0); /* if (data & 0x20) enable LEFT EXPLOSION sound (goes to left speaker) */ output_set_value("L_EXP_LIGHT", (data >> 5) & 0x01); - if (rising_bits & 0x20) sample_start(state->m_samples1, 0, 1, 0); + if (rising_bits & 0x20) state->m_samples1->start(0, 1); /* if (data & 0x40) enable LEFT MISSILE sound (goes to left speaker) */ - if (rising_bits & 0x40) sample_start(state->m_samples1, 0, 0, 0); + if (rising_bits & 0x40) state->m_samples1->start(0, 0); /* if (data & 0x80) enable RIGHT EXPLOSION sound (goes to right speaker) */ output_set_value("R_EXP_LIGHT", (data >> 7) & 0x01); - if (rising_bits & 0x80) sample_start(state->m_samples2, 0, 1, 0); + if (rising_bits & 0x80) state->m_samples2->start(0, 1); state->m_port_1_last = data; } @@ -1676,12 +1671,10 @@ MACHINE_CONFIG_FRAGMENT( m4_audio ) MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MCFG_SOUND_ADD("samples1", SAMPLES, 0) - MCFG_SOUND_CONFIG(m4_samples_interface) + MCFG_SAMPLES_ADD("samples1", m4_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1) - MCFG_SOUND_ADD("samples2", SAMPLES, 0) - MCFG_SOUND_CONFIG(m4_samples_interface) + MCFG_SAMPLES_ADD("samples2", m4_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1) MACHINE_CONFIG_END @@ -1698,16 +1691,16 @@ WRITE8_HANDLER( m4_audio_1_w ) space->machine().sound().system_enable((data >> 3) & 0x01); /* if (data & 0x10) enable LEFT PLAYER SHOT sound (goes to left speaker) */ - if (rising_bits & 0x10) sample_start(state->m_samples1, 0, 0, 0); + if (rising_bits & 0x10) state->m_samples1->start(0, 0); /* if (data & 0x20) enable RIGHT PLAYER SHOT sound (goes to right speaker) */ - if (rising_bits & 0x20) sample_start(state->m_samples2, 0, 0, 0); + if (rising_bits & 0x20) state->m_samples2->start(0, 0); /* if (data & 0x40) enable LEFT PLAYER EXPLOSION sound via 300K res (goes to left speaker) */ - if (rising_bits & 0x40) sample_start(state->m_samples1, 1, 1, 0); + if (rising_bits & 0x40) state->m_samples1->start(1, 1); /* if (data & 0x80) enable RIGHT PLAYER EXPLOSION sound via 300K res (goes to right speaker) */ - if (rising_bits & 0x80) sample_start(state->m_samples2, 1, 1, 0); + if (rising_bits & 0x80) state->m_samples2->start(1, 1); state->m_port_1_last = data; } @@ -1719,10 +1712,10 @@ WRITE8_HANDLER( m4_audio_2_w ) UINT8 rising_bits = data & ~state->m_port_2_last; /* if (data & 0x01) enable LEFT PLAYER EXPLOSION sound via 510K res (goes to left speaker) */ - if (rising_bits & 0x01) sample_start(state->m_samples1, 1, 1, 0); + if (rising_bits & 0x01) state->m_samples1->start(1, 1); /* if (data & 0x02) enable RIGHT PLAYER EXPLOSION sound via 510K res (goes to right speaker) */ - if (rising_bits & 0x02) sample_start(state->m_samples2, 1, 1, 0); + if (rising_bits & 0x02) state->m_samples2->start(1, 1); /* if (data & 0x04) enable LEFT TANK MOTOR sound (goes to left speaker) */ @@ -1938,8 +1931,7 @@ MACHINE_CONFIG_FRAGMENT( clowns_audio ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(clowns_samples_interface) + MCFG_SAMPLES_ADD("samples", clowns_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.70) MCFG_SOUND_ADD("discrete", DISCRETE, 0) @@ -1974,7 +1966,7 @@ WRITE8_DEVICE_HANDLER( clowns_audio_2_w ) discrete_sound_w(device, CLOWNS_SPRINGBOARD_HIT_EN, (data >> 4) & 0x01); - if (rising_bits & 0x20) sample_start(state->m_samples, 0, 0, 0); /* springboard miss */ + if (rising_bits & 0x20) state->m_samples->start(0, 0); /* springboard miss */ /* D6 and D7 are not connected */ @@ -3341,8 +3333,7 @@ MACHINE_CONFIG_FRAGMENT( phantom2_audio ) MCFG_SOUND_START(samples) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(phantom2_samples_interface) + MCFG_SAMPLES_ADD("samples", phantom2_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1) MACHINE_CONFIG_END @@ -3353,7 +3344,7 @@ WRITE8_HANDLER( phantom2_audio_1_w ) UINT8 rising_bits = data & ~state->m_port_1_last; /* if (data & 0x01) enable PLAYER SHOT sound */ - if (rising_bits & 0x01) sample_start(state->m_samples, 0, 0, 0); + if (rising_bits & 0x01) state->m_samples->start(0, 0); /* if (data & 0x02) enable ENEMY SHOT sound */ @@ -3378,7 +3369,7 @@ WRITE8_HANDLER( phantom2_audio_2_w ) /* D0-D2 are not connected */ /* if (data & 0x08) enable EXPLOSION sound */ - if (rising_bits & 0x08) sample_start(state->m_samples, 1, 1, 0); + if (rising_bits & 0x08) state->m_samples->start(1, 1); output_set_value("EXPLAMP", (data >> 4) & 0x01); @@ -3628,8 +3619,7 @@ MACHINE_CONFIG_FRAGMENT( invaders_samples_audio ) MCFG_SOUND_CONFIG(invaders_sn76477_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(invaders_samples_interface) + MCFG_SAMPLES_ADD("samples", invaders_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/audio/polyplay.c b/src/mame/audio/polyplay.c index 685c1dc3930..a84dd7c2a70 100644 --- a/src/mame/audio/polyplay.c +++ b/src/mame/audio/polyplay.c @@ -20,7 +20,7 @@ SAMPLES_START( polyplay_sh_start ) { - polyplay_state *state = device->machine().driver_data(); + polyplay_state *state = device.machine().driver_data(); int i; for (i = 0; i < SAMPLE_LENGTH / 2; i++) { @@ -49,29 +49,29 @@ void polyplay_set_channel2(running_machine &machine, int active) void polyplay_play_channel1(running_machine &machine, int data) { polyplay_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); if (data) { state->m_freq1 = 2457600 / 16 / data / 8; - sample_set_volume(samples, 0, state->m_channel_playing1 * 1.0); - sample_start_raw(samples, 0, state->m_backgroundwave, ARRAY_LENGTH(state->m_backgroundwave), sizeof(state->m_backgroundwave)*state->m_freq1,1); + samples->set_volume(0, state->m_channel_playing1 * 1.0); + samples->start_raw(0, state->m_backgroundwave, ARRAY_LENGTH(state->m_backgroundwave), sizeof(state->m_backgroundwave)*state->m_freq1,true); } else { - sample_stop(samples, 0); - sample_stop(samples, 1); + samples->stop(0); + samples->stop(1); } } void polyplay_play_channel2(running_machine &machine, int data) { polyplay_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); if (data) { state->m_freq2 = 2457600 / 16 / data / 8; - sample_set_volume(samples, 1, state->m_channel_playing2 * 1.0); - sample_start_raw(samples, 1, state->m_backgroundwave, ARRAY_LENGTH(state->m_backgroundwave), sizeof(state->m_backgroundwave)*state->m_freq2,1); + samples->set_volume(1, state->m_channel_playing2 * 1.0); + samples->start_raw(1, state->m_backgroundwave, ARRAY_LENGTH(state->m_backgroundwave), sizeof(state->m_backgroundwave)*state->m_freq2,true); } else { - sample_stop(samples, 0); - sample_stop(samples, 1); + samples->stop(0); + samples->stop(1); } } diff --git a/src/mame/audio/pulsar.c b/src/mame/audio/pulsar.c index 2b64ff0ea32..c9caf1ac089 100644 --- a/src/mame/audio/pulsar.c +++ b/src/mame/audio/pulsar.c @@ -28,8 +28,8 @@ #define OUT_PORT_2_MOVMAZE 0x10 -#define PLAY(samp,id,loop) sample_start( samp, id, id, loop ) -#define STOP(samp,id) sample_stop( samp, id ) +#define PLAY(samp,id,loop) samp->start( id, id, loop ) +#define STOP(samp,id) samp->stop( id ) /* sample file names */ @@ -60,8 +60,7 @@ static const samples_interface pulsar_samples_interface = MACHINE_CONFIG_FRAGMENT( pulsar_audio ) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(pulsar_samples_interface) + MCFG_SAMPLES_ADD("samples", pulsar_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_CONFIG_END @@ -88,7 +87,7 @@ static int port1State = 0; WRITE8_HANDLER( pulsar_audio_1_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int bitsChanged; //int bitsGoneHigh; int bitsGoneLow; @@ -139,7 +138,7 @@ WRITE8_HANDLER( pulsar_audio_1_w ) WRITE8_HANDLER( pulsar_audio_2_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); static int port2State = 0; int bitsChanged; int bitsGoneHigh; @@ -159,7 +158,7 @@ WRITE8_HANDLER( pulsar_audio_2_w ) if ( bitsGoneLow & OUT_PORT_2_GATE ) { - sample_start( samples, SND_CLANG, SND_GATE, 0 ); + samples->start(SND_CLANG, SND_GATE); } if ( bitsGoneHigh & OUT_PORT_2_GATE ) { diff --git a/src/mame/audio/segag80r.c b/src/mame/audio/segag80r.c index 368714fd40c..99cb44497ee 100644 --- a/src/mame/audio/segag80r.c +++ b/src/mame/audio/segag80r.c @@ -190,8 +190,7 @@ MACHINE_CONFIG_FRAGMENT( astrob_sound_board ) MCFG_SOUND_START(astrob) /* sound hardware */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(astrob_samples_interface) + MCFG_SAMPLES_ADD("samples", astrob_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END @@ -225,7 +224,7 @@ WRITE8_HANDLER( astrob_sound_w ) { 120.0f, 82.0f, 62.0f, 56.0f, 47.0f, 39.0f, 33.0f, 27.0f, 24.0f, 22.0f }; - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); float freq_factor; UINT8 diff = data ^ state->m_sound_state[offset]; @@ -235,54 +234,54 @@ WRITE8_HANDLER( astrob_sound_w ) { case 0: /* INVADER-1: channel 0 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 0, (data & 0x80) ? 0 : 1, TRUE); - if ((data & 0x01) && sample_playing(samples, 0)) sample_stop(samples, 0); + if ((diff & 0x01) && !(data & 0x01)) samples->start(0, (data & 0x80) ? 0 : 1, true); + if ((data & 0x01) && samples->playing(0)) samples->stop(0); /* INVADER-2: channel 1 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 1, (data & 0x80) ? 2 : 3, TRUE); - if ((data & 0x02) && sample_playing(samples, 1)) sample_stop(samples, 1); + if ((diff & 0x02) && !(data & 0x02)) samples->start(1, (data & 0x80) ? 2 : 3, true); + if ((data & 0x02) && samples->playing(1)) samples->stop(1); /* INVADER-3: channel 2 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 2, (data & 0x80) ? 4 : 5, TRUE); - if ((data & 0x04) && sample_playing(samples, 2)) sample_stop(samples, 2); + if ((diff & 0x04) && !(data & 0x04)) samples->start(2, (data & 0x80) ? 4 : 5, true); + if ((data & 0x04) && samples->playing(2)) samples->stop(2); /* INVADER-4: channel 3 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 3, (data & 0x80) ? 6 : 7, TRUE); - if ((data & 0x08) && sample_playing(samples, 3)) sample_stop(samples, 3); + if ((diff & 0x08) && !(data & 0x08)) samples->start(3, (data & 0x80) ? 6 : 7, true); + if ((data & 0x08) && samples->playing(3)) samples->stop(3); /* ASTROIDS: channel 4 */ - if ((diff & 0x10) && !(data & 0x10)) sample_start(samples, 4, 8, TRUE); - if ((data & 0x10) && sample_playing(samples, 4)) sample_stop(samples, 4); + if ((diff & 0x10) && !(data & 0x10)) samples->start(4, 8, true); + if ((data & 0x10) && samples->playing(4)) samples->stop(4); /* MUTE */ space->machine().sound().system_mute(data & 0x20); /* REFILL: channel 5 */ - if (!(data & 0x40) && !sample_playing(samples, 5)) sample_start(samples, 5, 9, FALSE); - if ( (data & 0x40) && sample_playing(samples, 5)) sample_stop(samples, 5); + if (!(data & 0x40) && !samples->playing(5)) samples->start(5, 9); + if ( (data & 0x40) && samples->playing(5)) samples->stop(5); /* WARP: changes which sample is played for the INVADER samples above */ if (diff & 0x80) { - if (sample_playing(samples, 0)) sample_start(samples, 0, (data & 0x80) ? 0 : 1, TRUE); - if (sample_playing(samples, 1)) sample_start(samples, 1, (data & 0x80) ? 2 : 3, TRUE); - if (sample_playing(samples, 2)) sample_start(samples, 2, (data & 0x80) ? 4 : 5, TRUE); - if (sample_playing(samples, 3)) sample_start(samples, 3, (data & 0x80) ? 6 : 7, TRUE); + if (samples->playing(0)) samples->start(0, (data & 0x80) ? 0 : 1, true); + if (samples->playing(1)) samples->start(1, (data & 0x80) ? 2 : 3, true); + if (samples->playing(2)) samples->start(2, (data & 0x80) ? 4 : 5, true); + if (samples->playing(3)) samples->start(3, (data & 0x80) ? 6 : 7, true); } break; case 1: /* LASER #1: channel 6 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 6, 10, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(6, 10); /* LASER #2: channel 7 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 7, 11, FALSE); + if ((diff & 0x02) && !(data & 0x02)) samples->start(7, 11); /* SHORT EXPL: channel 8 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 8, 12, FALSE); + if ((diff & 0x04) && !(data & 0x04)) samples->start(8, 12); /* LONG EXPL: channel 8 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 8, 13, FALSE); + if ((diff & 0x08) && !(data & 0x08)) samples->start(8, 13); /* ATTACK RATE */ if ((diff & 0x10) && !(data & 0x10)) state->m_sound_rate = (state->m_sound_rate + 1) % 10; @@ -291,10 +290,10 @@ WRITE8_HANDLER( astrob_sound_w ) if (!(data & 0x20)) state->m_sound_rate = 0; /* BONUS: channel 9 */ - if ((diff & 0x40) && !(data & 0x40)) sample_start(samples, 9, 14, FALSE); + if ((diff & 0x40) && !(data & 0x40)) samples->start(9, 14); /* SONAR: channel 10 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 10, 15, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(10, 15); break; } @@ -308,10 +307,10 @@ WRITE8_HANDLER( astrob_sound_w ) /* adjust the sample rate of invader sounds based the sound_rate */ /* this is an approximation */ - if (sample_playing(samples, 0)) sample_set_freq(samples, 0, sample_get_base_freq(samples, 0) * freq_factor); - if (sample_playing(samples, 1)) sample_set_freq(samples, 1, sample_get_base_freq(samples, 1) * freq_factor); - if (sample_playing(samples, 2)) sample_set_freq(samples, 2, sample_get_base_freq(samples, 2) * freq_factor); - if (sample_playing(samples, 3)) sample_set_freq(samples, 3, sample_get_base_freq(samples, 3) * freq_factor); + if (samples->playing(0)) samples->set_frequency(0, samples->base_frequency(0) * freq_factor); + if (samples->playing(1)) samples->set_frequency(1, samples->base_frequency(1) * freq_factor); + if (samples->playing(2)) samples->set_frequency(2, samples->base_frequency(2) * freq_factor); + if (samples->playing(3)) samples->set_frequency(3, samples->base_frequency(3) * freq_factor); } @@ -422,8 +421,7 @@ MACHINE_CONFIG_FRAGMENT( 005_sound_board ) /* sound hardware */ MCFG_SOUND_START(sega005) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(sega005_samples_interface) + MCFG_SAMPLES_ADD("samples", sega005_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("005", SEGA005, 0) @@ -459,32 +457,32 @@ static SOUND_START( sega005 ) static WRITE8_DEVICE_HANDLER( sega005_sound_a_w ) { segag80r_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[0]; state->m_sound_state[0] = data; /* LARGE EXPL: channel 0 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 0, 0, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(0, 0); /* SMALL EXPL: channel 1 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 1, 1, FALSE); + if ((diff & 0x02) && !(data & 0x02)) samples->start(1, 1); /* DROP BOMB: channel 2 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 2, 2, FALSE); + if ((diff & 0x04) && !(data & 0x04)) samples->start(2, 2); /* SHOOT PISTOL: channel 3 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 3, 3, FALSE); + if ((diff & 0x08) && !(data & 0x08)) samples->start(3, 3); /* MISSILE: channel 4 */ - if ((diff & 0x10) && !(data & 0x10)) sample_start(samples, 4, 4, FALSE); + if ((diff & 0x10) && !(data & 0x10)) samples->start(4, 4); /* HELICOPTER: channel 5 */ - if ((diff & 0x20) && !(data & 0x20) && !sample_playing(samples, 5)) sample_start(samples, 5, 5, TRUE); - if ((diff & 0x20) && (data & 0x20)) sample_stop(samples, 5); + if ((diff & 0x20) && !(data & 0x20) && !samples->playing(5)) samples->start(5, 5, true); + if ((diff & 0x20) && (data & 0x20)) samples->stop(5); /* WHISTLE: channel 6 */ - if ((diff & 0x40) && !(data & 0x40) && !sample_playing(samples, 6)) sample_start(samples, 6, 6, TRUE); - if ((diff & 0x40) && (data & 0x40)) sample_stop(samples, 6); + if ((diff & 0x40) && !(data & 0x40) && !samples->playing(6)) samples->start(6, 6, true); + if ((diff & 0x40) && (data & 0x40)) samples->stop(6); } @@ -664,8 +662,7 @@ MACHINE_CONFIG_FRAGMENT( spaceod_sound_board ) /* sound hardware */ MCFG_SOUND_START(spaceod) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(spaceod_samples_interface) + MCFG_SAMPLES_ADD("samples", spaceod_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END @@ -694,7 +691,7 @@ static SOUND_START( spaceod ) WRITE8_HANDLER( spaceod_sound_w ) { segag80r_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[offset]; state->m_sound_state[offset] = data; @@ -702,40 +699,40 @@ WRITE8_HANDLER( spaceod_sound_w ) { case 0: /* BACK G: channel 0 */ - if ((diff & 0x01) && !(data & 0x01) && !sample_playing(samples, 0)) sample_start(samples, 0, 7, TRUE); - if ((diff & 0x01) && (data & 0x01)) sample_stop(samples, 0); + if ((diff & 0x01) && !(data & 0x01) && !samples->playing(0)) samples->start(0, 7, true); + if ((diff & 0x01) && (data & 0x01)) samples->stop(0); /* SHORT EXP: channel 1 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 1, 2, FALSE); + if ((diff & 0x04) && !(data & 0x04)) samples->start(1, 2); /* ACCELERATE: channel 2 */ - if ((diff & 0x10) && !(data & 0x10)) sample_start(samples, 2, 8, FALSE); + if ((diff & 0x10) && !(data & 0x10)) samples->start(2, 8); /* BATTLE STAR: channel 3 */ - if ((diff & 0x20) && !(data & 0x20)) sample_start(samples, 3, 10, FALSE); + if ((diff & 0x20) && !(data & 0x20)) samples->start(3, 10); /* D BOMB: channel 4 */ - if ((diff & 0x40) && !(data & 0x40)) sample_start(samples, 4, 1, FALSE); + if ((diff & 0x40) && !(data & 0x40)) samples->start(4, 1); /* LONG EXP: channel 5 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 5, 3, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(5, 3); break; case 1: /* SHOT: channel 6 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 6, 0, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(6, 0); /* BONUS UP: channel 7 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 7, 6, FALSE); + if ((diff & 0x02) && !(data & 0x02)) samples->start(7, 6); /* WARP: channel 8 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 8, 4, FALSE); + if ((diff & 0x08) && !(data & 0x08)) samples->start(8, 4); /* APPEARANCE UFO: channel 9 */ - if ((diff & 0x40) && !(data & 0x40)) sample_start(samples, 9, 5, FALSE); + if ((diff & 0x40) && !(data & 0x40)) samples->start(9, 5); /* BLACK HOLE: channel 10 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 10, 9, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(10, 9); break; } } @@ -841,8 +838,7 @@ MACHINE_CONFIG_FRAGMENT( monsterb_sound_board ) /* sound hardware */ MCFG_SOUND_START(monsterb) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(monsterb_samples_interface) + MCFG_SAMPLES_ADD("samples", monsterb_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("music", TMS36XX, 247) @@ -902,15 +898,15 @@ static WRITE8_DEVICE_HANDLER( monsterb_sound_a_w ) static WRITE8_DEVICE_HANDLER( monsterb_sound_b_w ) { segag80r_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[1]; state->m_sound_state[1] = data; /* SHOT: channel 0 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 0, 0, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(0, 0); /* DIVE: channel 1 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 1, 1, FALSE); + if ((diff & 0x02) && !(data & 0x02)) samples->start(1, 1); /* TODO: D7 on Port B might affect TMS3617 output (mute?) */ } diff --git a/src/mame/audio/segag80v.c b/src/mame/audio/segag80v.c index 606c69deb5f..f9e7c7f0cd6 100644 --- a/src/mame/audio/segag80v.c +++ b/src/mame/audio/segag80v.c @@ -137,197 +137,197 @@ d0 crafts joining WRITE8_HANDLER( elim1_sh_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); data ^= 0xff; /* Play fireball sample */ if (data & 0x02) - sample_start (samples, 0, 0, 0); + samples->start(0, 0); /* Play explosion samples */ if (data & 0x04) - sample_start (samples, 1, 10, 0); + samples->start(1, 10); if (data & 0x08) - sample_start (samples, 1, 9, 0); + samples->start(1, 9); if (data & 0x10) - sample_start (samples, 1, 8, 0); + samples->start(1, 8); /* Play bounce sample */ if (data & 0x20) { - if (sample_playing(samples, 2)) - sample_stop (samples, 2); - sample_start (samples, 2, 1, 0); + if (samples->playing(2)) + samples->stop(2); + samples->start(2, 1); } /* Play lazer sample */ if (data & 0xc0) { - if (sample_playing(samples, 3)) - sample_stop (samples, 3); - sample_start (samples, 3, 5, 0); + if (samples->playing(3)) + samples->stop(3); + samples->start(3, 5); } } WRITE8_HANDLER( elim2_sh_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); data ^= 0xff; /* Play thrust sample */ if (data & 0x0f) - sample_start (samples, 4, 6, 0); + samples->start(4, 6); else - sample_stop (samples, 4); + samples->stop(4); /* Play skitter sample */ if (data & 0x10) - sample_start (samples, 5, 2, 0); + samples->start(5, 2); /* Play eliminator sample */ if (data & 0x20) - sample_start (samples, 6, 3, 0); + samples->start(6, 3); /* Play electron samples */ if (data & 0x40) - sample_start (samples, 7, 7, 0); + samples->start(7, 7); if (data & 0x80) - sample_start (samples, 7, 4, 0); + samples->start(7, 4); } WRITE8_HANDLER( zektor1_sh_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); data ^= 0xff; /* Play fireball sample */ if (data & 0x02) - sample_start (samples, 0, 0, 0); + samples->start(0, 0); /* Play explosion samples */ if (data & 0x04) - sample_start (samples, 1, 10, 0); + samples->start(1, 10); if (data & 0x08) - sample_start (samples, 1, 9, 0); + samples->start(1, 9); if (data & 0x10) - sample_start (samples, 1, 8, 0); + samples->start(1, 8); /* Play bounce sample */ if (data & 0x20) { - if (sample_playing(samples, 2)) - sample_stop (samples, 2); - sample_start (samples, 2, 1, 0); + if (samples->playing(2)) + samples->stop(2); + samples->start(2, 1); } /* Play lazer sample */ if (data & 0xc0) { - if (sample_playing(samples, 3)) - sample_stop (samples, 3); - sample_start (samples, 3, 5, 0); + if (samples->playing(3)) + samples->stop(3); + samples->start(3, 5); } } WRITE8_HANDLER( zektor2_sh_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); data ^= 0xff; /* Play thrust sample */ if (data & 0x0f) - sample_start (samples, 4, 6, 0); + samples->start(4, 6); else - sample_stop (samples, 4); + samples->stop(4); /* Play skitter sample */ if (data & 0x10) - sample_start (samples, 5, 2, 0); + samples->start(5, 2); /* Play eliminator sample */ if (data & 0x20) - sample_start (samples, 6, 3, 0); + samples->start(6, 3); /* Play electron samples */ if (data & 0x40) - sample_start (samples, 7, 40, 0); + samples->start(7, 40); if (data & 0x80) - sample_start (samples, 7, 41, 0); + samples->start(7, 41); } WRITE8_HANDLER( spacfury1_sh_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); data ^= 0xff; /* craft growing */ if (data & 0x01) - sample_start (samples, 1, 0, 0); + samples->start(1, 0); /* craft moving */ if (data & 0x02) { - if (!sample_playing(samples, 2)) - sample_start (samples, 2, 1, 1); + if (!samples->playing(2)) + samples->start(2, 1, true); } else - sample_stop (samples, 2); + samples->stop(2); /* Thrust */ if (data & 0x04) { - if (!sample_playing(samples, 3)) - sample_start (samples, 3, 4, 1); + if (!samples->playing(3)) + samples->start(3, 4, true); } else - sample_stop (samples, 3); + samples->stop(3); /* star spin */ if (data & 0x40) - sample_start (samples, 4, 8, 0); + samples->start(4, 8); /* partial warship? */ if (data & 0x80) - sample_start (samples, 4, 9, 0); + samples->start(4, 9); } WRITE8_HANDLER( spacfury2_sh_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); data ^= 0xff; /* craft joining */ if (data & 0x01) - sample_start (samples, 5, 2, 0); + samples->start(5, 2); /* ship firing */ if (data & 0x02) { - if (sample_playing(samples, 6)) - sample_stop(samples, 6); - sample_start(samples, 6, 3, 0); + if (samples->playing(6)) + samples->stop(6); + samples->start(6, 3); } /* fireball */ if (data & 0x04) - sample_start (samples, 7, 6, 0); + samples->start(7, 6); /* small explosion */ if (data & 0x08) - sample_start (samples, 7, 6, 0); + samples->start(7, 6); /* large explosion */ if (data & 0x10) - sample_start (samples, 7, 5, 0); + samples->start(7, 5); /* docking bang */ if (data & 0x20) - sample_start (samples, 0, 7, 0); + samples->start(0, 7); } diff --git a/src/mame/audio/senjyo.c b/src/mame/audio/senjyo.c index 00060c0456d..48d777e9ecc 100644 --- a/src/mame/audio/senjyo.c +++ b/src/mame/audio/senjyo.c @@ -52,13 +52,13 @@ WRITE8_HANDLER( senjyo_volume_w ) samples_device *samples = space->machine().device("samples"); state->m_single_volume = data & 0x0f; - sample_set_volume(samples, 0, state->m_single_volume / 15.0); + samples->set_volume(0, state->m_single_volume / 15.0); } static TIMER_CALLBACK( senjyo_sh_update ) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); senjyo_state *state = machine.driver_data(); /* ctc2 timer single tone generator frequency */ @@ -69,13 +69,13 @@ static TIMER_CALLBACK( senjyo_sh_update ) else state->m_single_rate = 0; - sample_set_freq(samples, 0, state->m_single_rate); + samples->set_frequency(0, state->m_single_rate); } SAMPLES_START( senjyo_sh_start ) { - running_machine &machine = device->machine(); + running_machine &machine = device.machine(); senjyo_state *state = machine.driver_data(); int i; @@ -87,8 +87,8 @@ SAMPLES_START( senjyo_sh_start ) /* CTC2 single tone generator */ state->m_single_rate = 1000; state->m_single_volume = 0; - sample_set_volume(device, 0, state->m_single_volume / 15.0); - sample_start_raw(device, 0, state->m_single_data, SINGLE_LENGTH, state->m_single_rate, 1); + device.set_volume(0, state->m_single_volume / 15.0); + device.start_raw(0, state->m_single_data, SINGLE_LENGTH, state->m_single_rate, true); machine.scheduler().timer_pulse(machine.primary_screen->frame_period(), FUNC(senjyo_sh_update)); } diff --git a/src/mame/audio/snk6502.c b/src/mame/audio/snk6502.c index ac7e92c9945..ebefd7d1eae 100644 --- a/src/mame/audio/snk6502.c +++ b/src/mame/audio/snk6502.c @@ -49,7 +49,7 @@ struct _snk6502_sound_state INT32 m_tone_clock; sound_stream * m_tone_stream; - device_t *m_samples; + samples_device *m_samples; UINT8 *m_ROM; int m_Sound0StopOnRollover; UINT8 m_LastPort1; @@ -653,7 +653,7 @@ static DEVICE_START( snk6502_sound ) { snk6502_sound_state *state = get_safe_token(device); - state->m_samples = device->machine().device("samples"); + state->m_samples = device->machine().device("samples"); state->m_ROM = device->machine().region("snk6502")->base(); // adjusted @@ -695,7 +695,7 @@ WRITE8_HANDLER( sasuke_sound_w ) { device_t *device = space->machine().device("snk6502"); snk6502_sound_state *state = get_safe_token(device); - device_t *samples = state->m_samples; + samples_device *samples = state->m_samples; TONE *tone_channels = state->m_tone_channels; switch (offset) @@ -715,13 +715,13 @@ WRITE8_HANDLER( sasuke_sound_w ) */ if ((~data & 0x01) && (state->m_LastPort1 & 0x01)) - sample_start(samples, 0, 0, 0); + samples->start(0, 0); if ((~data & 0x02) && (state->m_LastPort1 & 0x02)) - sample_start(samples, 1, 1, 0); + samples->start(1, 1); if ((~data & 0x04) && (state->m_LastPort1 & 0x04)) - sample_start(samples, 2, 2, 0); + samples->start(2, 2); if ((~data & 0x08) && (state->m_LastPort1 & 0x08)) - sample_start(samples, 3, 3, 0); + samples->start(3, 3); if ((data & 0x80) && (~state->m_LastPort1 & 0x80)) { @@ -765,7 +765,7 @@ WRITE8_HANDLER( satansat_sound_w ) { device_t *device = space->machine().device("snk6502"); snk6502_sound_state *state = get_safe_token(device); - device_t *samples = state->m_samples; + samples_device *samples = state->m_samples; TONE *tone_channels = state->m_tone_channels; switch (offset) @@ -782,7 +782,7 @@ WRITE8_HANDLER( satansat_sound_w ) /* bit 2 = analog sound trigger */ if (data & 0x04 && !(state->m_LastPort1 & 0x04)) - sample_start(samples, 0, 1, 0); + samples->start(0, 1); if (data & 0x08) { @@ -832,7 +832,7 @@ WRITE8_HANDLER( vanguard_sound_w ) { device_t *device = space->machine().device("snk6502"); snk6502_sound_state *state = get_safe_token(device); - device_t *samples = state->m_samples; + samples_device *samples = state->m_samples; TONE *tone_channels = state->m_tone_channels; switch (offset) @@ -860,13 +860,13 @@ WRITE8_HANDLER( vanguard_sound_w ) /* play noise samples requested by sound command byte */ /* SHOT A */ if (data & 0x20 && !(state->m_LastPort1 & 0x20)) - sample_start(samples, 1, 0, 0); + samples->start(1, 0); else if (!(data & 0x20) && state->m_LastPort1 & 0x20) - sample_stop(samples, 1); + samples->stop(1); /* BOMB */ if (data & 0x80 && !(state->m_LastPort1 & 0x80)) - sample_start(samples, 2, 1, 0); + samples->start(2, 1); if (data & 0x08) { @@ -1086,7 +1086,7 @@ static void snk6502_speech_w(running_machine &machine, UINT8 data, const UINT16 device_t *device = machine.device("snk6502"); snk6502_sound_state *state = get_safe_token(device); - device_t *samples = state->m_samples; + samples_device *samples = state->m_samples; if ((data & HD38880_CTP) && (data & HD38880_CMV)) { @@ -1100,7 +1100,7 @@ static void snk6502_speech_w(running_machine &machine, UINT8 data, const UINT16 case HD38880_START: logerror("speech: START\n"); - if (state->m_hd38880_data_bytes == 5 && !sample_playing(samples, 0)) + if (state->m_hd38880_data_bytes == 5 && !samples->playing(0)) { int i; @@ -1108,7 +1108,7 @@ static void snk6502_speech_w(running_machine &machine, UINT8 data, const UINT16 { if (table[i] && table[i] == state->m_hd38880_addr) { - sample_start(samples, 0, start + i, 0); + samples->start(0, start + i); break; } } @@ -1120,7 +1120,7 @@ static void snk6502_speech_w(running_machine &machine, UINT8 data, const UINT16 break; case HD38880_STOP: - sample_stop(samples, 0); + samples->stop(0); logerror("speech: STOP\n"); break; diff --git a/src/mame/audio/spacefb.c b/src/mame/audio/spacefb.c index e194cc65d4d..e2413c6a601 100644 --- a/src/mame/audio/spacefb.c +++ b/src/mame/audio/spacefb.c @@ -35,15 +35,15 @@ READ8_HANDLER( spacefb_audio_t1_r ) WRITE8_HANDLER( spacefb_port_1_w ) { spacefb_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); cputag_set_input_line(space->machine(), "audiocpu", 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE); /* enemy killed */ - if (!(data & 0x01) && (state->m_sound_latch & 0x01)) sample_start(samples, 0,0,0); + if (!(data & 0x01) && (state->m_sound_latch & 0x01)) samples->start(0,0); /* ship fire */ - if (!(data & 0x40) && (state->m_sound_latch & 0x40)) sample_start(samples, 1,1,0); + if (!(data & 0x40) && (state->m_sound_latch & 0x40)) samples->start(1,1); /* * Explosion Noise @@ -57,10 +57,10 @@ WRITE8_HANDLER( spacefb_port_1_w ) { if (data & 0x80) /* play decaying noise */ - sample_start(samples, 2,3,0); + samples->start(2,3); else /* start looping noise */ - sample_start(samples, 2,2,1); + samples->start(2,2, true); } state->m_sound_latch = data; @@ -91,7 +91,6 @@ MACHINE_CONFIG_FRAGMENT( spacefb_audio ) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(spacefb_samples_interface) + MCFG_SAMPLES_ADD("samples", spacefb_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/audio/suna8.c b/src/mame/audio/suna8.c index a4ab8e220c9..2aaafb99240 100644 --- a/src/mame/audio/suna8.c +++ b/src/mame/audio/suna8.c @@ -16,14 +16,15 @@ WRITE8_DEVICE_HANDLER( suna8_play_samples_w ) suna8_state *state = device->machine().driver_data(); if( data ) { + samples_device *samples = downcast(device); if( ~data & 0x10 ) { - sample_start_raw(device, 0, &state->m_samplebuf[0x800*state->m_sample], 0x0800, 4000, 0); + samples->start_raw(0, &state->m_samplebuf[0x800*state->m_sample], 0x0800, 4000); } else if( ~data & 0x08 ) { state->m_sample &= 3; - sample_start_raw(device, 0, &state->m_samplebuf[0x800*(state->m_sample+7)], 0x0800, 4000, 0); + samples->start_raw(0, &state->m_samplebuf[0x800*(state->m_sample+7)], 0x0800, 4000); } } } @@ -35,7 +36,8 @@ WRITE8_DEVICE_HANDLER( rranger_play_samples_w ) { if(( state->m_sample != 0 ) && ( ~data & 0x30 )) // don't play state->m_sample zero when the bit is active { - sample_start_raw(device, 0, &state->m_samplebuf[0x800*state->m_sample], 0x0800, 4000, 0); + samples_device *samples = downcast(device); + samples->start_raw(0, &state->m_samplebuf[0x800*state->m_sample], 0x0800, 4000); } } } @@ -48,8 +50,8 @@ WRITE8_DEVICE_HANDLER( suna8_samples_number_w ) SAMPLES_START( suna8_sh_start ) { - suna8_state *state = device->machine().driver_data(); - running_machine &machine = device->machine(); + suna8_state *state = device.machine().driver_data(); + running_machine &machine = device.machine(); int i, len = machine.region("samples")->bytes(); UINT8 *ROM = machine.region("samples")->base(); diff --git a/src/mame/audio/targ.c b/src/mame/audio/targ.c index 1e5f7134ecb..bc9872b8960 100644 --- a/src/mame/audio/targ.c +++ b/src/mame/audio/targ.c @@ -45,52 +45,52 @@ static const INT16 sine_wave[32] = -static void adjust_sample(device_t *samples, UINT8 freq) +static void adjust_sample(samples_device *samples, UINT8 freq) { tone_freq = freq; if ((tone_freq == 0xff) || (tone_freq == 0x00)) - sample_set_volume(samples, 3, 0); + samples->set_volume(3, 0); else { - sample_set_freq(samples, 3, 1.0 * max_freq / (0xff - tone_freq)); - sample_set_volume(samples, 3, tone_active); + samples->set_frequency(3, 1.0 * max_freq / (0xff - tone_freq)); + samples->set_volume(3, tone_active); } } WRITE8_HANDLER( targ_audio_1_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); /* CPU music */ if ((data & 0x01) != (port_1_last & 0x01)) dac_data_w(space->machine().device("dac"),(data & 0x01) * 0xff); /* shot */ - if (FALLING_EDGE(0x02) && !sample_playing(samples, 0)) sample_start(samples, 0,1,0); - if (RISING_EDGE(0x02)) sample_stop(samples, 0); + if (FALLING_EDGE(0x02) && !samples->playing(0)) samples->start(0,1); + if (RISING_EDGE(0x02)) samples->stop(0); /* crash */ if (RISING_EDGE(0x20)) { if (data & 0x40) - sample_start(samples, 1,2,0); + samples->start(1,2); else - sample_start(samples, 1,0,0); + samples->start(1,0); } /* Sspec */ if (data & 0x10) - sample_stop(samples, 2); + samples->stop(2); else { if ((data & 0x08) != (port_1_last & 0x08)) { if (data & 0x08) - sample_start(samples, 2,3,1); + samples->start(2,3,true); else - sample_start(samples, 2,4,1); + samples->start(2,4,true); } } @@ -114,7 +114,7 @@ WRITE8_HANDLER( targ_audio_2_w ) { if ((data & 0x01) && !(port_2_last & 0x01)) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 *prom = space->machine().region("targ")->base(); tone_pointer = (tone_pointer + 1) & 0x0f; @@ -128,7 +128,7 @@ WRITE8_HANDLER( targ_audio_2_w ) WRITE8_HANDLER( spectar_audio_2_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); adjust_sample(samples, data); } @@ -147,14 +147,14 @@ static const char *const sample_names[] = static void common_audio_start(running_machine &machine, int freq) { - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); max_freq = freq; tone_freq = 0; tone_active = 0; - sample_set_volume(samples, 3, 0); - sample_start_raw(samples, 3, sine_wave, 32, 1000, 1); + samples->set_volume(3, 0); + samples->start_raw(3, sine_wave, 32, 1000, true); state_save_register_global(machine, port_1_last); state_save_register_global(machine, port_2_last); @@ -165,14 +165,13 @@ static void common_audio_start(running_machine &machine, int freq) static SAMPLES_START( spectar_audio_start ) { - running_machine &machine = device->machine(); - common_audio_start(machine, SPECTAR_MAXFREQ); + common_audio_start(device.machine(), SPECTAR_MAXFREQ); } static SAMPLES_START( targ_audio_start ) { - running_machine &machine = device->machine(); + running_machine &machine = device.machine(); common_audio_start(machine, TARG_MAXFREQ); tone_pointer = 0; @@ -201,8 +200,7 @@ MACHINE_CONFIG_FRAGMENT( spectar_audio ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(spectar_samples_interface) + MCFG_SAMPLES_ADD("samples", spectar_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) @@ -214,8 +212,7 @@ MACHINE_CONFIG_FRAGMENT( targ_audio ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(targ_samples_interface) + MCFG_SAMPLES_ADD("samples", targ_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) diff --git a/src/mame/audio/turbo.c b/src/mame/audio/turbo.c index 685b5002bd2..9b32b270a83 100644 --- a/src/mame/audio/turbo.c +++ b/src/mame/audio/turbo.c @@ -19,19 +19,19 @@ * *************************************/ -static void turbo_update_samples(turbo_state *state, device_t *samples) +static void turbo_update_samples(turbo_state *state, samples_device *samples) { /* accelerator sounds */ /* BSEL == 3 --> off */ /* BSEL == 2 --> standard */ /* BSEL == 1 --> tunnel */ /* BSEL == 0 --> ??? */ - if (state->m_turbo_bsel == 3 && sample_playing(samples, 5)) - sample_stop(samples, 5); - else if (state->m_turbo_bsel != 3 && !sample_playing(samples, 5)) - sample_start(samples, 5, 7, TRUE); - if (sample_playing(samples, 5)) - sample_set_freq(samples, 5, sample_get_base_freq(samples, 5) * ((state->m_turbo_accel & 0x3f) / 5.25 + 1)); + if (state->m_turbo_bsel == 3 && samples->playing(5)) + samples->stop(5); + else if (state->m_turbo_bsel != 3 && !samples->playing(5)) + samples->start(5, 7, true); + if (samples->playing(5)) + samples->set_frequency(5, samples->base_frequency(5) * ((state->m_turbo_accel & 0x3f) / 5.25 + 1)); } @@ -72,7 +72,7 @@ if (!((data >> 4) & 1)) mame_printf_debug("/TRIG4\n"); WRITE8_DEVICE_HANDLER( turbo_sound_a_w ) { #if (!DISCRETE_TEST) - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); #endif turbo_state *state = device->machine().driver_data(); UINT8 diff = data ^ state->m_sound_state[0]; @@ -81,28 +81,28 @@ WRITE8_DEVICE_HANDLER( turbo_sound_a_w ) #if (!DISCRETE_TEST) /* /CRASH.S: channel 0 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 0, 5, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(0, 5); /* /TRIG1: channel 1 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 1, 0, FALSE); + if ((diff & 0x02) && !(data & 0x02)) samples->start(1, 0); /* /TRIG2: channel 1 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 1, 1, FALSE); + if ((diff & 0x04) && !(data & 0x04)) samples->start(1, 1); /* /TRIG3: channel 1 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 1, 2, FALSE); + if ((diff & 0x08) && !(data & 0x08)) samples->start(1, 2); /* /TRIG4: channel 1 */ - if ((diff & 0x10) && !(data & 0x10)) sample_start(samples, 1, 3, FALSE); + if ((diff & 0x10) && !(data & 0x10)) samples->start(1, 3); /* OSEL0 */ state->m_turbo_osel = (state->m_turbo_osel & 6) | ((data >> 5) & 1); /* /SLIP: channel 2 */ - if ((diff & 0x40) && !(data & 0x40)) sample_start(samples, 2, 4, FALSE); + if ((diff & 0x40) && !(data & 0x40)) samples->start(2, 4); /* /CRASH.L: channel 3 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 3, 5, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(3, 5); /* update any samples */ turbo_update_samples(state, samples); @@ -122,7 +122,7 @@ WRITE8_DEVICE_HANDLER( turbo_sound_a_w ) WRITE8_DEVICE_HANDLER( turbo_sound_b_w ) { - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); turbo_state *state = device->machine().driver_data(); UINT8 diff = data ^ state->m_sound_state[1]; state->m_sound_state[1] = data; @@ -132,11 +132,11 @@ WRITE8_DEVICE_HANDLER( turbo_sound_b_w ) output_set_value("tachometer", state->m_turbo_accel); /* /AMBU: channel 4 */ - if ((diff & 0x40) && !(data & 0x40) && !sample_playing(samples, 4)) sample_start(samples, 4, 8, TRUE); - if ((diff & 0x40) && (data & 0x40)) sample_stop(samples, 4); + if ((diff & 0x40) && !(data & 0x40) && !samples->playing(4)) samples->start(4, 8, true); + if ((diff & 0x40) && (data & 0x40)) samples->stop(4); /* /SPIN: channel 2 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 2, 6, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(2, 6); /* update any samples */ turbo_update_samples(state, samples); @@ -145,7 +145,7 @@ WRITE8_DEVICE_HANDLER( turbo_sound_b_w ) WRITE8_DEVICE_HANDLER( turbo_sound_c_w ) { - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); turbo_state *state = device->machine().driver_data(); /* OSEL1-2 */ @@ -200,8 +200,7 @@ MACHINE_CONFIG_FRAGMENT( turbo_samples ) MCFG_SPEAKER_ADD("lspeaker", -0.2, 0.0, 1.0) /* left */ MCFG_SPEAKER_ADD("rspeaker", 0.2, 0.0, 1.0) /* right */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(turbo_samples_interface) + MCFG_SAMPLES_ADD("samples", turbo_samples_interface) /* channel 0 = CRASH.S -> CRASH.S/SM */ MCFG_SOUND_ROUTE(0, "fspeaker", 0.25) @@ -304,7 +303,7 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_a_w ) } -INLINE void subroc3d_update_volume(device_t *samples, int leftchan, UINT8 dis, UINT8 dir) +INLINE void subroc3d_update_volume(samples_device *samples, int leftchan, UINT8 dis, UINT8 dir) { float volume = (float)(15 - dis) / 16.0f; float lvol, rvol; @@ -319,14 +318,14 @@ INLINE void subroc3d_update_volume(device_t *samples, int leftchan, UINT8 dis, U lvol = rvol = 0; /* if the sample is playing, adjust it */ - sample_set_volume(samples, leftchan + 0, lvol); - sample_set_volume(samples, leftchan + 1, rvol); + samples->set_volume(leftchan + 0, lvol); + samples->set_volume(leftchan + 1, rvol); } WRITE8_DEVICE_HANDLER( subroc3d_sound_b_w ) { - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); turbo_state *state = device->machine().driver_data(); UINT8 diff = data ^ state->m_sound_state[1]; state->m_sound_state[1] = data; @@ -336,10 +335,10 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_b_w ) { state->m_subroc3d_mdis = state->m_sound_state[0] & 0x0f; state->m_subroc3d_mdir = (state->m_sound_state[0] >> 4) & 0x07; - if (!sample_playing(samples, 0)) + if (!samples->playing(0)) { - sample_start(samples, 0, 0, TRUE); - sample_start(samples, 1, 0, TRUE); + samples->start(0, 0, true); + samples->start(1, 0, true); } subroc3d_update_volume(samples, 0, state->m_subroc3d_mdis, state->m_subroc3d_mdir); } @@ -349,10 +348,10 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_b_w ) { state->m_subroc3d_tdis = state->m_sound_state[0] & 0x0f; state->m_subroc3d_tdir = (state->m_sound_state[0] >> 4) & 0x07; - if (!sample_playing(samples, 2)) + if (!samples->playing(2)) { - sample_start(samples, 2, 1, TRUE); - sample_start(samples, 3, 1, TRUE); + samples->start(2, 1, true); + samples->start(3, 1, true); } subroc3d_update_volume(samples, 2, state->m_subroc3d_tdis, state->m_subroc3d_tdir); } @@ -362,10 +361,10 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_b_w ) { state->m_subroc3d_fdis = state->m_sound_state[0] & 0x0f; state->m_subroc3d_fdir = (state->m_sound_state[0] >> 4) & 0x07; - if (!sample_playing(samples, 4)) + if (!samples->playing(4)) { - sample_start(samples, 4, 2, TRUE); - sample_start(samples, 5, 2, TRUE); + samples->start(4, 2, true); + samples->start(5, 2, true); } subroc3d_update_volume(samples, 4, state->m_subroc3d_fdis, state->m_subroc3d_fdir); } @@ -382,7 +381,7 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_b_w ) WRITE8_DEVICE_HANDLER( subroc3d_sound_c_w ) { - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); turbo_state *state = device->machine().driver_data(); UINT8 diff = data ^ state->m_sound_state[2]; state->m_sound_state[2] = data; @@ -390,28 +389,28 @@ WRITE8_DEVICE_HANDLER( subroc3d_sound_c_w ) /* /FIRE TRIG */ /* FIRE SELECT */ if ((diff & 0x01) && (data & 0x01)) - sample_start(samples, 8, (data & 0x02) ? 6 : 5, FALSE); + samples->start(8, (data & 0x02) ? 6 : 5); /* /SHIP EXP TRIG -> MY SHIP EXP: channel 9 */ if ((diff & 0x04) && (data & 0x04)) - sample_start(samples, 9, 7, FALSE); + samples->start(9, 7); /* /HIT TRIG -> HIT.L/R: channels 6+7 */ if ((diff & 0x08) && (data & 0x08)) { - sample_start(samples, 6, (state->m_sound_state[0] & 0x80) ? 4 : 3, FALSE); - sample_start(samples, 7, (state->m_sound_state[0] & 0x80) ? 4 : 3, FALSE); + samples->start(6, (state->m_sound_state[0] & 0x80) ? 4 : 3); + samples->start(7, (state->m_sound_state[0] & 0x80) ? 4 : 3); } /* /ALARM TRIG -> ALARM.M: channel 10 */ /* ALARM SELECT */ if ((diff & 0x10) && (data & 0x10)) - sample_start(samples, 10, (data & 0x20) ? 10 : 9, FALSE); + samples->start(10, (data & 0x20) ? 10 : 9); /* /PROLOGUE */ - if (!sample_playing(samples, 11)) - sample_start(samples, 11, 8, TRUE); - sample_set_volume(samples, 11, (data & 0x40) ? 0 : 1.0); + if (!samples->playing(11)) + samples->start(11, 8, true); + samples->set_volume(11, (data & 0x40) ? 0 : 1.0); /* /GAME START */ device->machine().sound().system_mute(data & 0x80); @@ -453,8 +452,7 @@ static const samples_interface subroc3d_samples_interface = MACHINE_CONFIG_FRAGMENT( subroc3d_samples ) MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(subroc3d_samples_interface) + MCFG_SAMPLES_ADD("samples", subroc3d_samples_interface) /* MISSILE in channels 0 and 1 */ MCFG_SOUND_ROUTE(0, "lspeaker", 0.25) @@ -497,24 +495,24 @@ MACHINE_CONFIG_END * *************************************/ -static void buckrog_update_samples(turbo_state *state, device_t *samples) +static void buckrog_update_samples(turbo_state *state, samples_device *samples) { /* accelerator sounds */ - if (sample_playing(samples, 5)) - sample_set_freq(samples, 5, sample_get_base_freq(samples, 5) * (state->m_buckrog_myship / 100.25 + 1)); + if (samples->playing(5)) + samples->set_frequency(5, samples->base_frequency(5) * (state->m_buckrog_myship / 100.25 + 1)); } WRITE8_DEVICE_HANDLER( buckrog_sound_a_w ) { - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); turbo_state *state = device->machine().driver_data(); UINT8 diff = data ^ state->m_sound_state[0]; state->m_sound_state[0] = data; /* clock HIT DIS from bits 0-2 */ if ((diff & 0x10) && (data & 0x10)) - sample_set_volume(samples, 3, (float)(/*7 - */(data & 7)) / 7.0f); + samples->set_volume(3, (float)(/*7 - */(data & 7)) / 7.0f); /* clock ACC from bits 0-3 */ if ((diff & 0x20) && (data & 0x20)) @@ -524,49 +522,49 @@ WRITE8_DEVICE_HANDLER( buckrog_sound_a_w ) } /* /ALARM0: channel 0 */ - if ((diff & 0x40) && !(data & 0x40)) sample_start(samples, 0, 0, FALSE); + if ((diff & 0x40) && !(data & 0x40)) samples->start(0, 0); /* /ALARM1: channel 0 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 0, 1, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(0, 1); } WRITE8_DEVICE_HANDLER( buckrog_sound_b_w ) { - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); turbo_state *state = device->machine().driver_data(); UINT8 diff = data ^ state->m_sound_state[1]; state->m_sound_state[1] = data; /* /ALARM3: channel 0 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 0, 2, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(0, 2); /* /ALARM4: channel 0 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 0, 3, FALSE); + if ((diff & 0x02) && !(data & 0x02)) samples->start(0, 3); /* /FIRE: channel 1 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 1, 5, FALSE); + if ((diff & 0x04) && !(data & 0x04)) samples->start(1, 5); /* /EXP: channel 2 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 2, 4, FALSE); + if ((diff & 0x08) && !(data & 0x08)) samples->start(2, 4); /* /HIT: channel 3 */ if ((diff & 0x10) && !(data & 0x10)) { - sample_start(samples, 3, 7, FALSE); + samples->start(3, 7); buckrog_update_samples(state, samples); } /* /REBOUND: channel 4 */ - if ((diff & 0x20) && !(data & 0x20)) sample_start(samples, 4, 6, FALSE); + if ((diff & 0x20) && !(data & 0x20)) samples->start(4, 6); /* SHIP: channel 5 */ - if ((diff & 0x40) && (data & 0x40) && !sample_playing(samples, 5)) + if ((diff & 0x40) && (data & 0x40) && !samples->playing(5)) { - sample_start(samples, 5, 8, TRUE); + samples->start(5, 8, true); buckrog_update_samples(state, samples); } - if ((diff & 0x40) && !(data & 0x40) && sample_playing(samples, 5)) sample_stop(samples, 5); + if ((diff & 0x40) && !(data & 0x40) && samples->playing(5)) samples->stop(5); /* GAME ON */ device->machine().sound().system_enable(data & 0x80); @@ -607,8 +605,7 @@ static const samples_interface buckrog_samples_interface = MACHINE_CONFIG_FRAGMENT( buckrog_samples ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(buckrog_samples_interface) + MCFG_SAMPLES_ADD("samples", buckrog_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END diff --git a/src/mame/audio/vicdual.c b/src/mame/audio/vicdual.c index 7f012b14595..8423ddf0b9e 100644 --- a/src/mame/audio/vicdual.c +++ b/src/mame/audio/vicdual.c @@ -120,8 +120,7 @@ static const samples_interface frogs_samples_interface = MACHINE_CONFIG_FRAGMENT( frogs_audio ) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(frogs_samples_interface) + MCFG_SAMPLES_ADD("samples", frogs_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.35) MCFG_SOUND_ADD("discrete", DISCRETE, 0) @@ -132,8 +131,8 @@ MACHINE_CONFIG_END static TIMER_CALLBACK( frogs_croak_callback ) { - device_t *samples = machine.device("samples"); - sample_stop(samples, 2); + samples_device *samples = machine.device("samples"); + samples->stop(2); } @@ -145,7 +144,7 @@ MACHINE_START( frogs_audio ) WRITE8_HANDLER( frogs_audio_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); device_t *discrete = space->machine().device("discrete"); static int last_croak = 0; static int last_buzzz = 0; @@ -160,11 +159,11 @@ WRITE8_HANDLER( frogs_audio_w ) // discrete_sound_w(discrete, FROGS_SPLASH_EN, data & 0x80); if (data & 0x01) - sample_start (samples, 3, 3, 0); // Hop + samples->start(3, 3); // Hop if (data & 0x02) - sample_start (samples, 0, 0, 0); // Boing + samples->start(0, 0); // Boing if (new_croak) - sample_start (samples, 2, 2, 0); // Croak + samples->start(2, 2); // Croak else { if (last_croak) @@ -187,12 +186,12 @@ WRITE8_HANDLER( frogs_audio_w ) * 12 seconds. */ if (!last_buzzz) - sample_start (samples, 1, 1, 1); // Buzzz + samples->start(1, 1, true); // Buzzz } else - sample_stop(samples, 1); + samples->stop(1); if (data & 0x80) - sample_start (samples, 4, 4, 0); // Splash + samples->start(4, 4); // Splash last_croak = new_croak; last_buzzz = new_buzzz; diff --git a/src/mame/audio/wow.c b/src/mame/audio/wow.c index 0f2957a42c0..5b6318f3cf4 100644 --- a/src/mame/audio/wow.c +++ b/src/mame/audio/wow.c @@ -103,7 +103,7 @@ const char *const wow_sample_names[] = READ8_HANDLER( wow_speech_r ) { astrocde_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); int Phoneme/*, Intonation*/; int i = 0; UINT8 data = offset >> 8; @@ -117,7 +117,7 @@ READ8_HANDLER( wow_speech_r ) //logerror("Data : %d Speech : %s at intonation %d\n",Phoneme, PhonemeTable[Phoneme],Intonation); if(Phoneme==63) { - sample_stop(samples, 0); + samples->stop(0); //logerror("Clearing sample %s\n",state->m_totalword); state->m_totalword[0] = 0; /* Clear the total word stack */ return data; @@ -132,8 +132,8 @@ READ8_HANDLER( wow_speech_r ) if (state->m_plural != 0) { //logerror("found a possible plural at %d\n",state->m_plural-1); if (!strcmp("S",state->m_totalword)) { /* Plural check */ - sample_start(samples, 0, num_samples-2, 0); /* play the sample at position of word */ - sample_set_freq(samples, 0, 11025); /* play at correct rate */ + samples->start(0, num_samples-2); /* play the sample at position of word */ + samples->set_frequency(0, 11025); /* play at correct rate */ state->m_totalword[0] = 0; /* Clear the total word stack */ state->m_oldword[0] = 0; /* Clear the total word stack */ return data; @@ -156,8 +156,8 @@ READ8_HANDLER( wow_speech_r ) } else { state->m_plural=0; } - sample_start(samples, 0, i, 0); /* play the sample at position of word */ - sample_set_freq(samples, 0, 11025); /* play at correct rate */ + samples->start(0, i); /* play the sample at position of word */ + samples->set_frequency(0, 11025); /* play at correct rate */ //logerror("Playing sample %d\n",i); state->m_totalword[0] = 0; /* Clear the total word stack */ return data; @@ -171,6 +171,6 @@ READ8_HANDLER( wow_speech_r ) CUSTOM_INPUT( wow_speech_status_r ) { - device_t *samples = field.machine().device("samples"); - return !sample_playing(samples, 0); + samples_device *samples = field.machine().device("samples"); + return !samples->playing(0); } diff --git a/src/mame/audio/zaxxon.c b/src/mame/audio/zaxxon.c index 6e88ddc3d39..799bd50ec8b 100644 --- a/src/mame/audio/zaxxon.c +++ b/src/mame/audio/zaxxon.c @@ -98,8 +98,7 @@ static const samples_interface zaxxon_samples_interface = MACHINE_CONFIG_FRAGMENT( zaxxon_samples ) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(zaxxon_samples_interface) + MCFG_SAMPLES_ADD("samples", zaxxon_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END @@ -114,72 +113,72 @@ MACHINE_CONFIG_END WRITE8_DEVICE_HANDLER( zaxxon_sound_a_w ) { zaxxon_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[0]; state->m_sound_state[0] = data; /* PLAYER SHIP A/B: volume */ - sample_set_volume(samples, 10, 0.5 + 0.157 * (data & 0x03)); - sample_set_volume(samples, 11, 0.5 + 0.157 * (data & 0x03)); + samples->set_volume(10, 0.5 + 0.157 * (data & 0x03)); + samples->set_volume(11, 0.5 + 0.157 * (data & 0x03)); /* PLAYER SHIP C: channel 10 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 10, 10, TRUE); - if ((diff & 0x04) && (data & 0x04)) sample_stop(samples, 10); + if ((diff & 0x04) && !(data & 0x04)) samples->start(10, 10, true); + if ((diff & 0x04) && (data & 0x04)) samples->stop(10); /* PLAYER SHIP D: channel 11 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 11, 11, TRUE); - if ((diff & 0x08) && (data & 0x08)) sample_stop(samples, 11); + if ((diff & 0x08) && !(data & 0x08)) samples->start(11, 11, true); + if ((diff & 0x08) && (data & 0x08)) samples->stop(11); /* HOMING MISSILE: channel 0 */ - if ((diff & 0x10) && !(data & 0x10)) sample_start(samples, 0, 0, TRUE); - if ((diff & 0x10) && (data & 0x10)) sample_stop(samples, 0); + if ((diff & 0x10) && !(data & 0x10)) samples->start(0, 0, true); + if ((diff & 0x10) && (data & 0x10)) samples->stop(0); /* BASE MISSILE: channel 1 */ - if ((diff & 0x20) && !(data & 0x20)) sample_start(samples, 1, 1, FALSE); + if ((diff & 0x20) && !(data & 0x20)) samples->start(1, 1); /* LASER: channel 2 */ - if ((diff & 0x40) && !(data & 0x40)) sample_start(samples, 2, 2, TRUE); - if ((diff & 0x40) && (data & 0x40)) sample_stop(samples, 2); + if ((diff & 0x40) && !(data & 0x40)) samples->start(2, 2, true); + if ((diff & 0x40) && (data & 0x40)) samples->stop(2); /* BATTLESHIP: channel 3 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 3, 3, TRUE); - if ((diff & 0x80) && (data & 0x80)) sample_stop(samples, 3); + if ((diff & 0x80) && !(data & 0x80)) samples->start(3, 3, true); + if ((diff & 0x80) && (data & 0x80)) samples->stop(3); } WRITE8_DEVICE_HANDLER( zaxxon_sound_b_w ) { zaxxon_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[1]; state->m_sound_state[1] = data; /* S-EXP: channel 4 */ - if ((diff & 0x10) && !(data & 0x10)) sample_start(samples, 4, 4, FALSE); + if ((diff & 0x10) && !(data & 0x10)) samples->start(4, 4); /* M-EXP: channel 5 */ - if ((diff & 0x20) && !(data & 0x20) && !sample_playing(samples, 5)) sample_start(samples, 5, 5, FALSE); + if ((diff & 0x20) && !(data & 0x20) && !samples->playing(5)) samples->start(5, 5); /* CANNON: channel 6 */ - if ((diff & 0x80) && !(data & 0x80)) sample_start(samples, 6, 6, FALSE); + if ((diff & 0x80) && !(data & 0x80)) samples->start(6, 6); } WRITE8_DEVICE_HANDLER( zaxxon_sound_c_w ) { zaxxon_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[2]; state->m_sound_state[2] = data; /* SHOT: channel 7 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 7, 7, FALSE); + if ((diff & 0x01) && !(data & 0x01)) samples->start(7, 7); /* ALARM2: channel 8 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 8, 8, FALSE); + if ((diff & 0x04) && !(data & 0x04)) samples->start(8, 8); /* ALARM3: channel 9 */ - if ((diff & 0x08) && !(data & 0x08) && !sample_playing(samples, 9)) sample_start(samples, 9, 9, FALSE); + if ((diff & 0x08) && !(data & 0x08) && !samples->playing(9)) samples->start(9, 9); } @@ -210,8 +209,7 @@ static const samples_interface congo_samples_interface = MACHINE_CONFIG_FRAGMENT( congo_samples ) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(congo_samples_interface) + MCFG_SAMPLES_ADD("samples", congo_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END @@ -226,37 +224,37 @@ MACHINE_CONFIG_END WRITE8_DEVICE_HANDLER( congo_sound_b_w ) { zaxxon_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[1]; state->m_sound_state[1] = data; /* bit 7 = mute */ /* GORILLA: channel 0 */ - if ((diff & 0x02) && !(data & 0x02) && !sample_playing(samples, 0)) sample_start(samples, 0, 0, FALSE); + if ((diff & 0x02) && !(data & 0x02) && !samples->playing(0)) samples->start(0, 0); } WRITE8_DEVICE_HANDLER( congo_sound_c_w ) { zaxxon_state *state = device->machine().driver_data(); - device_t *samples = device->machine().device("samples"); + samples_device *samples = device->machine().device("samples"); UINT8 diff = data ^ state->m_sound_state[2]; state->m_sound_state[2] = data; /* BASS DRUM: channel 1 */ - if ((diff & 0x01) && !(data & 0x01)) sample_start(samples, 1, 1, FALSE); - if ((diff & 0x01) && (data & 0x01)) sample_stop(samples, 1); + if ((diff & 0x01) && !(data & 0x01)) samples->start(1, 1); + if ((diff & 0x01) && (data & 0x01)) samples->stop(1); /* CONGA (LOW): channel 2 */ - if ((diff & 0x02) && !(data & 0x02)) sample_start(samples, 2, 2, FALSE); - if ((diff & 0x02) && (data & 0x02)) sample_stop(samples, 2); + if ((diff & 0x02) && !(data & 0x02)) samples->start(2, 2); + if ((diff & 0x02) && (data & 0x02)) samples->stop(2); /* CONGA (HIGH): channel 3 */ - if ((diff & 0x04) && !(data & 0x04)) sample_start(samples, 3, 3, FALSE); - if ((diff & 0x04) && (data & 0x04)) sample_stop(samples, 3); + if ((diff & 0x04) && !(data & 0x04)) samples->start(3, 3); + if ((diff & 0x04) && (data & 0x04)) samples->stop(3); /* RIM: channel 4 */ - if ((diff & 0x08) && !(data & 0x08)) sample_start(samples, 4, 4, FALSE); - if ((diff & 0x08) && (data & 0x08)) sample_stop(samples, 4); + if ((diff & 0x08) && !(data & 0x08)) samples->start(4, 4); + if ((diff & 0x08) && (data & 0x08)) samples->stop(4); } diff --git a/src/mame/drivers/8080bw.c b/src/mame/drivers/8080bw.c index 1a594384bb2..269e0f0241f 100644 --- a/src/mame/drivers/8080bw.c +++ b/src/mame/drivers/8080bw.c @@ -806,8 +806,7 @@ static MACHINE_CONFIG_DERIVED_CLASS( lrescue, mw8080bw_root, _8080bw_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(lrescue_samples_interface) + MCFG_SAMPLES_ADD("samples", lrescue_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75) /* extra audio channel */ diff --git a/src/mame/drivers/aristmk4.c b/src/mame/drivers/aristmk4.c index 5d7687d239c..e11c87d56b6 100644 --- a/src/mame/drivers/aristmk4.c +++ b/src/mame/drivers/aristmk4.c @@ -266,7 +266,7 @@ public: int m_rtc_address_strobe; int m_rtc_data_strobe; - device_t *m_samples; + samples_device *m_samples; UINT8 *m_shapeRomPtr; UINT8 m_shapeRom[0xc000]; UINT8 *m_mkiv_vram; @@ -577,7 +577,7 @@ static WRITE8_DEVICE_HANDLER(mkiv_pia_outb) if(emet[i]) { //logerror("Mechanical meter %d pulse: %02d\n",i+1, emet[i]); - sample_start(state->m_samples,i,0, FALSE); // pulse sound for mechanical meters + state->m_samples->start(i,0); // pulse sound for mechanical meters } } } @@ -1617,7 +1617,7 @@ static MACHINE_START( aristmk4 ) { aristmk4_state *state = machine.driver_data(); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state_save_register_global_pointer(machine, state->m_nvram, 0x1000); // state->m_nvram } @@ -1701,8 +1701,7 @@ static MACHINE_CONFIG_START( aristmk4, aristmk4_state ) MCFG_SOUND_CONFIG(ay8910_config2) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(meter_samples_interface) + MCFG_SAMPLES_ADD("samples", meter_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.05) MACHINE_CONFIG_END diff --git a/src/mame/drivers/astinvad.c b/src/mame/drivers/astinvad.c index 2546b1a9573..d078b7b9921 100644 --- a/src/mame/drivers/astinvad.c +++ b/src/mame/drivers/astinvad.c @@ -61,7 +61,7 @@ public: device_t *m_maincpu; device_t *m_ppi8255_0; device_t *m_ppi8255_1; - device_t *m_samples; + samples_device *m_samples; }; @@ -230,7 +230,7 @@ static MACHINE_START( kamikaze ) state->m_maincpu = machine.device("maincpu"); state->m_ppi8255_0 = machine.device("ppi8255_0"); state->m_ppi8255_1 = machine.device("ppi8255_1"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->m_int_timer = machine.scheduler().timer_alloc(FUNC(kamizake_int_gen)); state->m_int_timer->adjust(machine.primary_screen->time_until_pos(128), 128); @@ -256,7 +256,7 @@ static MACHINE_START( spaceint ) astinvad_state *state = machine.driver_data(); state->m_maincpu = machine.device("maincpu"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->save_item(NAME(state->m_screen_flip)); state->save_item(NAME(state->m_sound_state)); @@ -327,11 +327,11 @@ static WRITE8_DEVICE_HANDLER( astinvad_sound1_w ) int bits_gone_hi = data & ~state->m_sound_state[0]; state->m_sound_state[0] = data; - if (bits_gone_hi & 0x01) sample_start(state->m_samples, 0, SND_UFO, 1); - if (!(data & 0x01)) sample_stop(state->m_samples, 0); - if (bits_gone_hi & 0x02) sample_start(state->m_samples, 1, SND_SHOT, 0); - if (bits_gone_hi & 0x04) sample_start(state->m_samples, 2, SND_BASEHIT, 0); - if (bits_gone_hi & 0x08) sample_start(state->m_samples, 3, SND_INVADERHIT, 0); + if (bits_gone_hi & 0x01) state->m_samples->start(0, SND_UFO, true); + if (!(data & 0x01)) state->m_samples->stop(0); + if (bits_gone_hi & 0x02) state->m_samples->start(1, SND_SHOT); + if (bits_gone_hi & 0x04) state->m_samples->start(2, SND_BASEHIT); + if (bits_gone_hi & 0x08) state->m_samples->start(3, SND_INVADERHIT); device->machine().sound().system_enable(data & 0x20); state->m_screen_red = data & 0x04; @@ -344,11 +344,11 @@ static WRITE8_DEVICE_HANDLER( astinvad_sound2_w ) int bits_gone_hi = data & ~state->m_sound_state[1]; state->m_sound_state[1] = data; - if (bits_gone_hi & 0x01) sample_start(state->m_samples, 5, SND_FLEET1, 0); - if (bits_gone_hi & 0x02) sample_start(state->m_samples, 5, SND_FLEET2, 0); - if (bits_gone_hi & 0x04) sample_start(state->m_samples, 5, SND_FLEET3, 0); - if (bits_gone_hi & 0x08) sample_start(state->m_samples, 5, SND_FLEET4, 0); - if (bits_gone_hi & 0x10) sample_start(state->m_samples, 4, SND_UFOHIT, 0); + if (bits_gone_hi & 0x01) state->m_samples->start(5, SND_FLEET1); + if (bits_gone_hi & 0x02) state->m_samples->start(5, SND_FLEET2); + if (bits_gone_hi & 0x04) state->m_samples->start(5, SND_FLEET3); + if (bits_gone_hi & 0x08) state->m_samples->start(5, SND_FLEET4); + if (bits_gone_hi & 0x10) state->m_samples->start(4, SND_UFOHIT); state->m_screen_flip = (input_port_read(device->machine(), "CABINET") & data & 0x20) ? 0xff : 0x00; } @@ -360,16 +360,16 @@ static WRITE8_HANDLER( spaceint_sound1_w ) int bits_gone_hi = data & ~state->m_sound_state[0]; state->m_sound_state[0] = data; - if (bits_gone_hi & 0x01) sample_start(state->m_samples, 1, SND_SHOT, 0); - if (bits_gone_hi & 0x02) sample_start(state->m_samples, 2, SND_BASEHIT, 0); - if (bits_gone_hi & 0x04) sample_start(state->m_samples, 4, SND_UFOHIT, 0); - if (bits_gone_hi & 0x08) sample_start(state->m_samples, 0, SND_UFO, 1); - if (!(data & 0x08)) sample_stop(state->m_samples, 0); + if (bits_gone_hi & 0x01) state->m_samples->start(1, SND_SHOT); + if (bits_gone_hi & 0x02) state->m_samples->start(2, SND_BASEHIT); + if (bits_gone_hi & 0x04) state->m_samples->start(4, SND_UFOHIT); + if (bits_gone_hi & 0x08) state->m_samples->start(0, SND_UFO, true); + if (!(data & 0x08)) state->m_samples->stop(0); - if (bits_gone_hi & 0x10) sample_start(state->m_samples, 5, SND_FLEET1, 0); - if (bits_gone_hi & 0x20) sample_start(state->m_samples, 5, SND_FLEET2, 0); - if (bits_gone_hi & 0x40) sample_start(state->m_samples, 5, SND_FLEET3, 0); - if (bits_gone_hi & 0x80) sample_start(state->m_samples, 5, SND_FLEET4, 0); + if (bits_gone_hi & 0x10) state->m_samples->start(5, SND_FLEET1); + if (bits_gone_hi & 0x20) state->m_samples->start(5, SND_FLEET2); + if (bits_gone_hi & 0x40) state->m_samples->start(5, SND_FLEET3); + if (bits_gone_hi & 0x80) state->m_samples->start(5, SND_FLEET4); } @@ -381,7 +381,7 @@ static WRITE8_HANDLER( spaceint_sound2_w ) space->machine().sound().system_enable(data & 0x02); - if (bits_gone_hi & 0x04) sample_start(state->m_samples, 3, SND_INVADERHIT, 0); + if (bits_gone_hi & 0x04) state->m_samples->start(3, SND_INVADERHIT); state->m_screen_flip = (input_port_read(space->machine(), "CABINET") & data & 0x80) ? 0xff : 0x00; } @@ -605,8 +605,7 @@ static MACHINE_CONFIG_START( kamikaze, astinvad_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(astinvad_samples_interface) + MCFG_SAMPLES_ADD("samples", astinvad_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -642,8 +641,7 @@ static MACHINE_CONFIG_START( spaceint, astinvad_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(astinvad_samples_interface) + MCFG_SAMPLES_ADD("samples", astinvad_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/drivers/astrocde.c b/src/mame/drivers/astrocde.c index b194d7beccd..2afa24b74df 100644 --- a/src/mame/drivers/astrocde.c +++ b/src/mame/drivers/astrocde.c @@ -205,46 +205,46 @@ static WRITE8_HANDLER( seawolf2_lamps_w ) static WRITE8_HANDLER( seawolf2_sound_1_w ) // Port 40 { astrocde_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 rising_bits = data & ~state->m_port_1_last; state->m_port_1_last = data; - if (rising_bits & 0x01) sample_start(samples, 1, 1, 0); /* Left Torpedo */ - if (rising_bits & 0x02) sample_start(samples, 0, 0, 0); /* Left Ship Hit */ - if (rising_bits & 0x04) sample_start(samples, 4, 4, 0); /* Left Mine Hit */ - if (rising_bits & 0x08) sample_start(samples, 6, 1, 0); /* Right Torpedo */ - if (rising_bits & 0x10) sample_start(samples, 5, 0, 0); /* Right Ship Hit */ - if (rising_bits & 0x20) sample_start(samples, 9, 4, 0); /* Right Mine Hit */ + if (rising_bits & 0x01) samples->start(1, 1); /* Left Torpedo */ + if (rising_bits & 0x02) samples->start(0, 0); /* Left Ship Hit */ + if (rising_bits & 0x04) samples->start(4, 4); /* Left Mine Hit */ + if (rising_bits & 0x08) samples->start(6, 1); /* Right Torpedo */ + if (rising_bits & 0x10) samples->start(5, 0); /* Right Ship Hit */ + if (rising_bits & 0x20) samples->start(9, 4); /* Right Mine Hit */ } static WRITE8_HANDLER( seawolf2_sound_2_w ) // Port 41 { astrocde_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 rising_bits = data & ~state->m_port_2_last; state->m_port_2_last = data; - sample_set_volume(samples, 0, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 1, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 3, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 4, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 5, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 6, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 8, (data & 0x80) ? 1.0 : 0.0); - sample_set_volume(samples, 9, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(0, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(1, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(3, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(4, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(5, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(6, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(8, (data & 0x80) ? 1.0 : 0.0); + samples->set_volume(9, (data & 0x80) ? 1.0 : 0.0); /* dive panning controlled by low 3 bits */ - sample_set_volume(samples, 2, (float)(~data & 0x07) / 7.0); - sample_set_volume(samples, 7, (float)(data & 0x07) / 7.0); + samples->set_volume(2, (float)(~data & 0x07) / 7.0); + samples->set_volume(7, (float)(data & 0x07) / 7.0); if (rising_bits & 0x08) { - sample_start(samples, 2, 2, 0); - sample_start(samples, 7, 2, 0); + samples->start(2, 2); + samples->start(7, 2); } - if (rising_bits & 0x10) sample_start(samples, 8, 3, 0); /* Right Sonar */ - if (rising_bits & 0x20) sample_start(samples, 3, 3, 0); /* Left Sonar */ + if (rising_bits & 0x10) samples->start(8, 3); /* Right Sonar */ + if (rising_bits & 0x20) samples->start(3, 3); /* Left Sonar */ coin_counter_w(space->machine(), 0, data & 0x40); /* Coin Counter */ } @@ -1370,8 +1370,7 @@ static MACHINE_CONFIG_DERIVED( seawolf2, astrocade_base ) /* sound hardware */ MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(seawolf2_samples_interface) + MCFG_SAMPLES_ADD("samples", seawolf2_samples_interface) MCFG_SOUND_ROUTE(0, "lspeaker", 0.25) MCFG_SOUND_ROUTE(1, "lspeaker", 0.25) MCFG_SOUND_ROUTE(2, "lspeaker", 0.25) @@ -1421,8 +1420,7 @@ static MACHINE_CONFIG_DERIVED( wow, astrocade_base ) /* sound hardware */ MCFG_SPEAKER_ADD("center", 0.0, 0.0, 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(wow_samples_interface) + MCFG_SAMPLES_ADD("samples", wow_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "center", 0.85) MACHINE_CONFIG_END @@ -1448,8 +1446,7 @@ static MACHINE_CONFIG_DERIVED( gorf, astrocade_base ) MCFG_SOUND_ADD("astrocade2", ASTROCADE, ASTROCADE_CLOCK/4) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lower", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(gorf_samples_interface) + MCFG_SAMPLES_ADD("samples", gorf_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "upper", 0.85) MACHINE_CONFIG_END diff --git a/src/mame/drivers/astrof.c b/src/mame/drivers/astrof.c index 38abc3d29f9..55e505bb8ab 100644 --- a/src/mame/drivers/astrof.c +++ b/src/mame/drivers/astrof.c @@ -501,7 +501,7 @@ static MACHINE_START( astrof ) astrof_set_video_control_2(machine, 0xff); state->m_maincpu = machine.device("maincpu"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); /* register for state saving */ state->save_item(NAME(state->m_red_on)); diff --git a/src/mame/drivers/blockade.c b/src/mame/drivers/blockade.c index 23859978bbf..de1a1b3f68d 100644 --- a/src/mame/drivers/blockade.c +++ b/src/mame/drivers/blockade.c @@ -498,8 +498,7 @@ static MACHINE_CONFIG_START( blockade, blockade_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(blockade_samples_interface) + MCFG_SAMPLES_ADD("samples", blockade_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("discrete", DISCRETE, 0) diff --git a/src/mame/drivers/cclimber.c b/src/mame/drivers/cclimber.c index d87dc8b16cc..8d801fab5ff 100644 --- a/src/mame/drivers/cclimber.c +++ b/src/mame/drivers/cclimber.c @@ -1023,8 +1023,7 @@ static MACHINE_CONFIG_DERIVED( cclimber, root ) MCFG_SOUND_CONFIG(cclimber_ay8910_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(cclimber_samples_interface) + MCFG_SAMPLES_ADD("samples", cclimber_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/drivers/circus.c b/src/mame/drivers/circus.c index f3dae0260af..f251f1b3923 100644 --- a/src/mame/drivers/circus.c +++ b/src/mame/drivers/circus.c @@ -266,7 +266,7 @@ static MACHINE_START( circus ) circus_state *state = machine.driver_data(); state->m_maincpu = machine.device("maincpu"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->m_discrete = machine.device("discrete"); state->save_item(NAME(state->m_clown_x)); @@ -311,8 +311,7 @@ static MACHINE_CONFIG_START( circus, circus_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(circus_samples_interface) + MCFG_SAMPLES_ADD("samples", circus_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MCFG_SOUND_ADD("discrete", DISCRETE, 0) @@ -348,8 +347,7 @@ static MACHINE_CONFIG_START( robotbwl, circus_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(robotbwl_samples_interface) + MCFG_SAMPLES_ADD("samples", robotbwl_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MCFG_SOUND_ADD("discrete", DISCRETE, 0) @@ -392,8 +390,7 @@ static MACHINE_CONFIG_START( crash, circus_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(crash_samples_interface) + MCFG_SAMPLES_ADD("samples", crash_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MCFG_SOUND_ADD("discrete", DISCRETE, 0) @@ -428,8 +425,7 @@ static MACHINE_CONFIG_START( ripcord, circus_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(ripcord_samples_interface) + MCFG_SAMPLES_ADD("samples", ripcord_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MCFG_SOUND_ADD("discrete", DISCRETE, 0) diff --git a/src/mame/drivers/cosmic.c b/src/mame/drivers/cosmic.c index aa6ff686724..402ede6caeb 100644 --- a/src/mame/drivers/cosmic.c +++ b/src/mame/drivers/cosmic.c @@ -48,7 +48,7 @@ static WRITE8_HANDLER( panic_sound_output_w ) int count; if (data == 0) for (count = 0; count < 9; count++) - sample_stop(state->m_samples, count); + state->m_samples->stop(count); state->m_sound_enabled = data; } @@ -57,50 +57,50 @@ static WRITE8_HANDLER( panic_sound_output_w ) { switch (offset) { - case 0: if (data) sample_start(state->m_samples, 0, 0, 0); break; /* Walk */ - case 1: if (data) sample_start(state->m_samples, 0, 5, 0); break; /* Enemy Die 1 */ + case 0: if (data) state->m_samples->start(0, 0); break; /* Walk */ + case 1: if (data) state->m_samples->start(0, 5); break; /* Enemy Die 1 */ case 2: if (data) /* Drop 1 */ { - if (!sample_playing(state->m_samples, 1)) + if (!state->m_samples->playing(1)) { - sample_stop(state->m_samples, 2); - sample_start(state->m_samples, 1, 3, 0); + state->m_samples->stop(2); + state->m_samples->start(1, 3); } } else - sample_stop(state->m_samples, 1); + state->m_samples->stop(1); break; - case 3: if (data && !sample_playing(state->m_samples, 6)) /* Oxygen */ - sample_start(state->m_samples, 6, 9, 1); + case 3: if (data && !state->m_samples->playing(6)) /* Oxygen */ + state->m_samples->start(6, 9, true); break; case 4: break; /* Drop 2 */ - case 5: if (data) sample_start(state->m_samples, 0, 5, 0); break; /* Enemy Die 2 (use same sample as 1) */ - case 6: if (data && !sample_playing(state->m_samples, 1) && !sample_playing(state->m_samples, 3)) /* Hang */ - sample_start(state->m_samples, 2, 2, 0); + case 5: if (data) state->m_samples->start(0, 5); break; /* Enemy Die 2 (use same sample as 1) */ + case 6: if (data && !state->m_samples->playing(1) && !state->m_samples->playing(3)) /* Hang */ + state->m_samples->start(2, 2); break; case 7: if (data) /* Escape */ { - sample_stop(state->m_samples, 2); - sample_start(state->m_samples, 3, 4, 0); + state->m_samples->stop(2); + state->m_samples->start(3, 4); } else - sample_stop(state->m_samples, 3); + state->m_samples->stop(3); break; - case 8: if (data) sample_start(state->m_samples, 0, 1, 0); break; /* Stairs */ + case 8: if (data) state->m_samples->start(0, 1); break; /* Stairs */ case 9: if (data) /* Extend */ - sample_start(state->m_samples, 4, 8, 0); + state->m_samples->start(4, 8); else - sample_stop(state->m_samples, 4); + state->m_samples->stop(4); break; case 10: dac_data_w(state->m_dac, data); break;/* Bonus */ - case 15: if (data) sample_start(state->m_samples, 0, 6, 0); break; /* Player Die */ - case 16: if (data) sample_start(state->m_samples, 5, 7, 0); break; /* Enemy Laugh */ - case 17: if (data) sample_start(state->m_samples, 0, 10, 0); break; /* Coin - Not triggered by software */ + case 15: if (data) state->m_samples->start(0, 6); break; /* Player Die */ + case 16: if (data) state->m_samples->start(5, 7); break; /* Enemy Laugh */ + case 17: if (data) state->m_samples->start(0, 10); break; /* Coin - Not triggered by software */ } } @@ -126,7 +126,7 @@ static WRITE8_HANDLER( cosmicg_output_w ) state->m_sound_enabled = data; if (data == 0) for (count = 0; count < 9; count++) - sample_stop(state->m_samples, count); + state->m_samples->stop(count); } if (state->m_sound_enabled) @@ -138,37 +138,37 @@ static WRITE8_HANDLER( cosmicg_output_w ) /* be used for anything. It is implemented for sake of */ /* completness. Maybe it plays a tune if you win ? */ case 1: dac_data_w(state->m_dac, -data); break; - case 2: if (data) sample_start(state->m_samples, 0, state->m_march_select, 0); break; /* March Sound */ + case 2: if (data) state->m_samples->start(0, state->m_march_select); break; /* March Sound */ case 3: state->m_march_select = (state->m_march_select & 0xfe) | data; break; case 4: state->m_march_select = (state->m_march_select & 0xfd) | (data << 1); break; case 5: state->m_march_select = (state->m_march_select & 0xfb) | (data << 2); break; case 6: if (data) /* Killer Attack (crawly thing at bottom of screen) */ - sample_start(state->m_samples, 1, 8, 1); + state->m_samples->start(1, 8, true); else - sample_stop(state->m_samples, 1); + state->m_samples->stop(1); break; case 7: if (data) /* Bonus Chance & Got Bonus */ { - sample_stop(state->m_samples, 4); - sample_start(state->m_samples, 4, 10, 0); + state->m_samples->stop(4); + state->m_samples->start(4, 10); } break; case 8: if (data) { - if (!sample_playing(state->m_samples, 4)) sample_start(state->m_samples, 4, 9, 1); + if (!state->m_samples->playing(4)) state->m_samples->start(4, 9, true); } else - sample_stop(state->m_samples, 4); + state->m_samples->stop(4); break; - case 9: if (data) sample_start(state->m_samples, 3, 11, 0); break; /* Got Ship */ + case 9: if (data) state->m_samples->start(3, 11); break; /* Got Ship */ // case 11: watchdog_reset_w(0, 0); break; /* Watchdog */ - case 13: if (data) sample_start(state->m_samples, 8, 13 - state->m_gun_die_select, 0); break; /* Got Monster / Gunshot */ + case 13: if (data) state->m_samples->start(8, 13 - state->m_gun_die_select); break; /* Got Monster / Gunshot */ case 14: state->m_gun_die_select = data; break; - case 15: if (data) sample_start(state->m_samples, 5, 14, 0); break; /* Coin Extend (extra base) */ + case 15: if (data) state->m_samples->start(5, 14); break; /* Coin Extend (extra base) */ } } @@ -188,10 +188,10 @@ static WRITE8_HANDLER( cosmica_sound_output_w ) int count; if (data == 0) for (count = 0; count < 12; count++) - sample_stop(state->m_samples, count); + state->m_samples->stop(count); else { - sample_start(state->m_samples, 0, 0, 1); /*Background Noise*/ + state->m_samples->start(0, 0, true); /*Background Noise*/ } state->m_sound_enabled = data; @@ -201,7 +201,7 @@ static WRITE8_HANDLER( cosmica_sound_output_w ) { switch (offset) { - case 0: if (data) sample_start(state->m_samples, 1, 2, 0); break; /*Dive Bombing Type A*/ + case 0: if (data) state->m_samples->start(1, 2); break; /*Dive Bombing Type A*/ case 2: /*Dive Bombing Type B (Main Control)*/ if (data) @@ -209,58 +209,58 @@ static WRITE8_HANDLER( cosmica_sound_output_w ) switch (state->m_dive_bomb_b_select) { case 2: - if (sample_playing(state->m_samples, 2)) + if (state->m_samples->playing(2)) { - sample_stop(state->m_samples, 2); - sample_start(state->m_samples, 2, 3, 0); break; + state->m_samples->stop(2); + state->m_samples->start(2, 3); break; } else - sample_start(state->m_samples, 2, 3, 0); break; + state->m_samples->start(2, 3); break; case 3: - if (sample_playing(state->m_samples, 3)) + if (state->m_samples->playing(3)) { - sample_stop(state->m_samples, 3); - sample_start(state->m_samples, 3, 4, 0); break; + state->m_samples->stop(3); + state->m_samples->start(3, 4); break; } else - sample_start(state->m_samples, 3, 4, 0); break; + state->m_samples->start(3, 4); break; case 4: - if (sample_playing(state->m_samples, 4)) + if (state->m_samples->playing(4)) { - sample_stop(state->m_samples, 4); - sample_start(state->m_samples, 4, 5, 0); break; + state->m_samples->stop(4); + state->m_samples->start(4, 5); break; } else - sample_start(state->m_samples, 4, 5, 0); break; + state->m_samples->start(4, 5); break; case 5: - if (sample_playing(state->m_samples, 5)) + if (state->m_samples->playing(5)) { - sample_stop(state->m_samples, 5); - sample_start(state->m_samples, 5, 6, 0); break; + state->m_samples->stop(5); + state->m_samples->start(5, 6); break; } else - sample_start(state->m_samples, 5, 6, 0); break; + state->m_samples->start(5, 6); break; case 6: - if (sample_playing(state->m_samples, 6)) + if (state->m_samples->playing(6)) { - sample_stop(state->m_samples, 6); - sample_start(state->m_samples, 6, 7, 0); break; + state->m_samples->stop(6); + state->m_samples->start(6, 7); break; } else - sample_start(state->m_samples, 6, 7, 0); break; + state->m_samples->start(6, 7); break; case 7: - if (sample_playing(state->m_samples, 7)) + if (state->m_samples->playing(7)) { - sample_stop(state->m_samples, 7); - sample_start(state->m_samples, 7, 8, 0); break; + state->m_samples->stop(7); + state->m_samples->start(7, 8); break; } else - sample_start(state->m_samples, 7, 8, 0); break; + state->m_samples->start(7, 8); break; } } @@ -287,20 +287,20 @@ static WRITE8_HANDLER( cosmica_sound_output_w ) break; - case 6: if (data) sample_start(state->m_samples, 8, 9, 0); break; /*Fire Control*/ + case 6: if (data) state->m_samples->start(8, 9); break; /*Fire Control*/ - case 7: if (data) sample_start(state->m_samples, 9, 10, 0); break; /*Small Explosion*/ + case 7: if (data) state->m_samples->start(9, 10); break; /*Small Explosion*/ - case 8: if (data) sample_start(state->m_samples, 10, 11, 0); break; /*Loud Explosion*/ + case 8: if (data) state->m_samples->start(10, 11); break; /*Loud Explosion*/ case 9: if (data) - sample_start(state->m_samples, 11, 1, 1); + state->m_samples->start(11, 1, true); else - sample_stop(state->m_samples, 11); + state->m_samples->stop(11); break; /*Extend Sound control*/ - case 12: if (data) sample_start(state->m_samples, 11,12, 0); break; /*Insert Coin*/ + case 12: if (data) state->m_samples->start(11,12); break; /*Insert Coin*/ } } @@ -965,7 +965,7 @@ static MACHINE_START( cosmic ) { cosmic_state *state = machine.driver_data(); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->m_dac = machine.device("dac"); state->save_item(NAME(state->m_sound_enabled)); @@ -1035,8 +1035,7 @@ static MACHINE_CONFIG_DERIVED( panic, cosmic ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(panic_samples_interface) + MCFG_SAMPLES_ADD("samples", panic_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) @@ -1061,8 +1060,7 @@ static MACHINE_CONFIG_DERIVED( cosmica, cosmic ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(cosmica_samples_interface) + MCFG_SAMPLES_ADD("samples", cosmica_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) @@ -1099,8 +1097,7 @@ static MACHINE_CONFIG_START( cosmicg, cosmic_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(cosmicg_samples_interface) + MCFG_SAMPLES_ADD("samples", cosmicg_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("dac", DAC, 0) diff --git a/src/mame/drivers/dai3wksi.c b/src/mame/drivers/dai3wksi.c index 57807febf75..7ee0ed3b116 100644 --- a/src/mame/drivers/dai3wksi.c +++ b/src/mame/drivers/dai3wksi.c @@ -197,7 +197,7 @@ static SCREEN_UPDATE_RGB32( dai3wksi ) static WRITE8_HANDLER( dai3wksi_audio_1_w ) { dai3wksi_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 rising_bits = data & ~state->m_port_last1; state->m_enabled_sound = data & 0x80; @@ -205,12 +205,12 @@ static WRITE8_HANDLER( dai3wksi_audio_1_w ) if ((rising_bits & 0x20) && state->m_enabled_sound) { if (data & 0x04) - sample_start(samples, CHANNEL_SOUND5, SAMPLE_SOUND5, 0); + samples->start(CHANNEL_SOUND5, SAMPLE_SOUND5); else - sample_start(samples, CHANNEL_SOUND5, SAMPLE_SOUND5, 1); + samples->start(CHANNEL_SOUND5, SAMPLE_SOUND5, true); } if (!(data & 0x20) && (state->m_port_last1 & 0x20)) - sample_stop(samples, CHANNEL_SOUND5); + samples->stop(CHANNEL_SOUND5); state->m_port_last1 = data; } @@ -218,7 +218,7 @@ static WRITE8_HANDLER( dai3wksi_audio_1_w ) static WRITE8_HANDLER( dai3wksi_audio_2_w ) { dai3wksi_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 rising_bits = data & ~state->m_port_last2; state->m_dai3wksi_flipscreen = data & 0x10; @@ -227,15 +227,15 @@ static WRITE8_HANDLER( dai3wksi_audio_2_w ) if (state->m_enabled_sound) { - if (rising_bits & 0x01) sample_start(samples, CHANNEL_SOUND1, SAMPLE_SOUND1, 0); - if (rising_bits & 0x02) sample_start(samples, CHANNEL_SOUND2, SAMPLE_SOUND2, 0); - if (rising_bits & 0x08) sample_start(samples, CHANNEL_SOUND4, SAMPLE_SOUND4, 0); + if (rising_bits & 0x01) samples->start(CHANNEL_SOUND1, SAMPLE_SOUND1); + if (rising_bits & 0x02) samples->start(CHANNEL_SOUND2, SAMPLE_SOUND2); + if (rising_bits & 0x08) samples->start(CHANNEL_SOUND4, SAMPLE_SOUND4); if (rising_bits & 0x04) { if (!state->m_sound3_counter) - sample_start(samples, CHANNEL_SOUND3, SAMPLE_SOUND3_1, 0); + samples->start(CHANNEL_SOUND3, SAMPLE_SOUND3_1); else - sample_start(samples, CHANNEL_SOUND3, SAMPLE_SOUND3_2, 0); + samples->start(CHANNEL_SOUND3, SAMPLE_SOUND3_2); state->m_sound3_counter ^= 1; } @@ -247,14 +247,14 @@ static WRITE8_HANDLER( dai3wksi_audio_2_w ) static WRITE8_HANDLER( dai3wksi_audio_3_w ) { dai3wksi_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); if (state->m_enabled_sound) { if (data & 0x40) - sample_start(samples, CHANNEL_SOUND6, SAMPLE_SOUND6_1, 0); + samples->start(CHANNEL_SOUND6, SAMPLE_SOUND6_1); else if (data & 0x80) - sample_start(samples, CHANNEL_SOUND6, SAMPLE_SOUND6_2, 0); + samples->start(CHANNEL_SOUND6, SAMPLE_SOUND6_2); } } @@ -607,8 +607,7 @@ static MACHINE_CONFIG_START( dai3wksi, dai3wksi_state ) MCFG_SPEAKER_STANDARD_MONO("mono") #if (USE_SAMPLES) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(dai3wksi_samples_interface) + MCFG_SAMPLES_ADD("samples", dai3wksi_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) #else MCFG_SOUND_ADD("ic76", SN76477, 0) diff --git a/src/mame/drivers/equites.c b/src/mame/drivers/equites.c index 193a7630038..b5b81314be6 100644 --- a/src/mame/drivers/equites.c +++ b/src/mame/drivers/equites.c @@ -476,16 +476,17 @@ static WRITE8_HANDLER(equites_c0f8_w) static WRITE8_DEVICE_HANDLER( equites_8910porta_w ) { equites_state *state = device->machine().driver_data(); + samples_device *samples = downcast(device); // bongo 1 - sample_set_volume(device, 0, ((data & 0x30) >> 4) * 0.33); + samples->set_volume(0, ((data & 0x30) >> 4) * 0.33); if (data & ~state->m_ay_port_a & 0x80) - sample_start(device, 0, 0, 0); + samples->start(0, 0); // bongo 2 - sample_set_volume(device, 1, (data & 0x03) * 0.33); + samples->set_volume(1, (data & 0x03) * 0.33); if (data & ~state->m_ay_port_a & 0x08) - sample_start(device, 1, 1, 0); + samples->start(1, 1); state->m_ay_port_a = data; @@ -497,15 +498,16 @@ popmessage("HH %d(%d) CYM %d(%d)", state->m_hihat, BIT(state->m_ay_port_b, 6), s static WRITE8_DEVICE_HANDLER( equites_8910portb_w ) { equites_state *state = device->machine().driver_data(); + samples_device *samples = downcast(device); #if POPDRUMKIT if (data & ~state->m_ay_port_b & 0x08) state->m_cymbal++; if (data & ~state->m_ay_port_b & 0x04) state->m_hihat++; #endif // bongo 3 - sample_set_volume(device, 2, ((data & 0x30)>>4) * 0.33); + samples->set_volume(2, ((data & 0x30)>>4) * 0.33); if (data & ~state->m_ay_port_b & 0x80) - sample_start(device, 2, 2, 0); + samples->start(2, 2); // FIXME I'm just enabling the MSM5232 Noise Output for now. Proper emulation // of the analog circuitry should be done instead. @@ -1193,8 +1195,7 @@ static MACHINE_CONFIG_FRAGMENT( common_sound ) MCFG_SOUND_ADD("dac2", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(alphamc07_samples_interface) + MCFG_SAMPLES_ADD("samples", alphamc07_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) MACHINE_CONFIG_END diff --git a/src/mame/drivers/galaga.c b/src/mame/drivers/galaga.c index dfdf688bac8..22c5f09ba39 100644 --- a/src/mame/drivers/galaga.c +++ b/src/mame/drivers/galaga.c @@ -1854,8 +1854,7 @@ static MACHINE_CONFIG_DERIVED( battles, xevious ) /* sound hardware */ MCFG_DEVICE_REMOVE("discrete") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(battles_samples_interface) + MCFG_SAMPLES_ADD("samples", battles_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END diff --git a/src/mame/drivers/galaxian.c b/src/mame/drivers/galaxian.c index 2833e1008c6..ad315571411 100644 --- a/src/mame/drivers/galaxian.c +++ b/src/mame/drivers/galaxian.c @@ -2206,8 +2206,7 @@ static MACHINE_CONFIG_DERIVED( mshuttle, galaxian_base ) MCFG_SOUND_CONFIG(cclimber_ay8910_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(cclimber_samples_interface) + MCFG_SAMPLES_ADD("samples", cclimber_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MACHINE_CONFIG_END diff --git a/src/mame/drivers/gaplus.c b/src/mame/drivers/gaplus.c index 41f92a878fd..53774f52121 100644 --- a/src/mame/drivers/gaplus.c +++ b/src/mame/drivers/gaplus.c @@ -606,8 +606,7 @@ static MACHINE_CONFIG_START( gaplus, gaplus_state ) MCFG_SOUND_CONFIG(namco_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(gaplus_samples_interface) + MCFG_SAMPLES_ADD("samples", gaplus_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index bce8d9fbef7..864237e7fe0 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -1907,8 +1907,7 @@ static MACHINE_CONFIG_DERIVED( reactor, gottlieb1 ) MCFG_DEVICE_REMOVE("nvram") /* sound hardware */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(reactor_samples_interface) + MCFG_SAMPLES_ADD("samples", reactor_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END @@ -1916,8 +1915,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( qbert, gottlieb1 ) /* video hardware */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(qbert_samples_interface) + MCFG_SAMPLES_ADD("samples", qbert_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/gotya.c b/src/mame/drivers/gotya.c index 35e776e2616..65a5c434459 100644 --- a/src/mame/drivers/gotya.c +++ b/src/mame/drivers/gotya.c @@ -178,7 +178,7 @@ static MACHINE_START( gotya ) { gotya_state *state = machine.driver_data(); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->save_item(NAME(state->m_scroll_bit_8)); state->save_item(NAME(state->m_theme_playing)); @@ -219,8 +219,7 @@ static MACHINE_CONFIG_START( gotya, gotya_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(gotya_samples_interface) + MCFG_SAMPLES_ADD("samples", gotya_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/gridlee.c b/src/mame/drivers/gridlee.c index 8af986fefbd..87b0d8be2ae 100644 --- a/src/mame/drivers/gridlee.c +++ b/src/mame/drivers/gridlee.c @@ -451,8 +451,7 @@ static MACHINE_CONFIG_START( gridlee, gridlee_state ) MCFG_SOUND_ADD("gridlee", GRIDLEE, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(gridlee_samples_interface) + MCFG_SAMPLES_ADD("samples", gridlee_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40) MACHINE_CONFIG_END diff --git a/src/mame/drivers/m10.c b/src/mame/drivers/m10.c index 859c9590f25..d729e5af813 100644 --- a/src/mame/drivers/m10.c +++ b/src/mame/drivers/m10.c @@ -199,7 +199,7 @@ static MACHINE_START( m10 ) state->m_maincpu = machine.device("maincpu"); state->m_ic8j1 = machine.device("ic8j1"); state->m_ic8j2 = machine.device("ic8j2"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->save_item(NAME(state->m_bottomline)); state->save_item(NAME(state->m_flip)); @@ -266,27 +266,27 @@ static WRITE8_HANDLER( m10_ctrl_w ) break; case 0x01: /* MISSILE sound */ - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); break; case 0x02: /* EXPLOSION sound */ - sample_start(state->m_samples, 1, 1, 0); + state->m_samples->start(1, 1); break; case 0x03: /* INVADER HIT sound */ - sample_start(state->m_samples, 2, 2, 0); + state->m_samples->start(2, 2); break; case 0x04: /* BONUS BASE sound */ - sample_start(state->m_samples, 3, 8, 0); + state->m_samples->start(3, 8); break; case 0x05: /* FLEET MOVE sound */ - sample_start(state->m_samples, 3, 3, 0); + state->m_samples->start(3, 3); break; case 0x06: /* SAUCER HIT SOUND */ - sample_start(state->m_samples, 2, 7, 0); + state->m_samples->start(2, 7); break; default: popmessage("Unknown sound M10: %02x\n", data & 0x07); @@ -294,9 +294,9 @@ static WRITE8_HANDLER( m10_ctrl_w ) } /* UFO SOUND */ if (data & 0x08) - sample_stop(state->m_samples, 4); + state->m_samples->stop(4); else - sample_start(state->m_samples, 4, 9, 1); + state->m_samples->start(4, 9, true); } @@ -403,21 +403,21 @@ static WRITE8_HANDLER( m11_a100_w ) // audio control! /* MISSILE sound */ if (raising_bits & 0x01) - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); /* EXPLOSION sound */ if (raising_bits & 0x02) - sample_start(state->m_samples, 1, 1, 0); + state->m_samples->start(1, 1); /* Rapidly falling parachute */ if (raising_bits & 0x04) - sample_start(state->m_samples, 3, 8, 0); + state->m_samples->start(3, 8); /* Background sound ? */ if (data & 0x10) - sample_start(state->m_samples, 4, 9, 1); + state->m_samples->start(4, 9, true); else - sample_stop(state->m_samples, 4); + state->m_samples->stop(4); } @@ -446,34 +446,34 @@ static WRITE8_HANDLER( m15_a100_w ) #endif /* DOT sound */ if (falling_bits & 0x40) - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); #if 0 if (raising_bits & 0x40) - sample_stop(state->m_samples, 0); + state->m_samples->stop(0); #endif /* EXPLOSION sound */ if (falling_bits & 0x08) - sample_start(state->m_samples, 1, 1, 0); + state->m_samples->start(1, 1); #if 0 if (raising_bits & 0x08) - sample_stop(state->m_samples, 1); + state->m_samples->stop(1); #endif /* player changes lane */ if (falling_bits & 0x10) - sample_start(state->m_samples, 3, 3, 0); + state->m_samples->start(3, 3); #if 0 if (raising_bits & 0x10) - sample_stop(state->m_samples, 3); + state->m_samples->stop(3); #endif /* computer car changes lane */ if (falling_bits & 0x20) - sample_start(state->m_samples, 4, 4, 0); + state->m_samples->start(4, 4); #if 0 if (raising_bits & 0x20) - sample_stop(state->m_samples, 4); + state->m_samples->stop(4); #endif state->m_last = data; @@ -863,8 +863,7 @@ static MACHINE_CONFIG_START( m10, m10_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(m10_samples_interface) + MCFG_SAMPLES_ADD("samples", m10_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END @@ -903,8 +902,7 @@ static MACHINE_CONFIG_START( m15, m10_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(m10_samples_interface) + MCFG_SAMPLES_ADD("samples", m10_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/m63.c b/src/mame/drivers/m63.c index 511b6e92961..6232ee89b47 100644 --- a/src/mame/drivers/m63.c +++ b/src/mame/drivers/m63.c @@ -154,7 +154,7 @@ public: device_t *m_soundcpu; device_t *m_ay1; device_t *m_ay2; - device_t *m_samples; + samples_device *m_samples; }; @@ -433,7 +433,7 @@ static WRITE8_HANDLER( fghtbskt_samples_w ) m63_state *state = space->machine().driver_data(); if (data & 1) - sample_start_raw(state->m_samples, 0, state->m_samplebuf + ((data & 0xf0) << 8), 0x2000, 8000, 0); + state->m_samples->start_raw(0, state->m_samplebuf + ((data & 0xf0) << 8), 0x2000, 8000); } static WRITE8_HANDLER( nmi_mask_w ) @@ -687,7 +687,7 @@ GFXDECODE_END static SAMPLES_START( fghtbskt_sh_start ) { - running_machine &machine = device->machine(); + running_machine &machine = device.machine(); m63_state *state = machine.driver_data(); int i, len = machine.region("samples")->bytes(); UINT8 *ROM = machine.region("samples")->base(); @@ -719,7 +719,7 @@ static MACHINE_START( m63 ) state->m_soundcpu = machine.device("soundcpu"); state->m_ay1 = machine.device("ay1"); state->m_ay2 = machine.device("ay2"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->save_item(NAME(state->m_pal_bank)); state->save_item(NAME(state->m_fg_flag)); @@ -832,8 +832,7 @@ static MACHINE_CONFIG_START( fghtbskt, m63_state ) MCFG_SOUND_ADD("ay1", AY8910, XTAL_12MHz/8) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(fghtbskt_samples_interface) + MCFG_SAMPLES_ADD("samples", fghtbskt_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/drivers/mcr.c b/src/mame/drivers/mcr.c index 002092b271a..34f64d73f81 100644 --- a/src/mame/drivers/mcr.c +++ b/src/mame/drivers/mcr.c @@ -413,14 +413,14 @@ static WRITE8_HANDLER( kroozr_op4_w ) static WRITE8_HANDLER( journey_op4_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); /* if we're not playing the sample yet, start it */ - if (!sample_playing(samples, 0)) - sample_start(samples, 0, 0, 1); + if (!samples->playing(0)) + samples->start(0, 0, true); /* bit 0 turns cassette on/off */ - sample_set_pause(samples, 0, ~data & 1); + samples->pause(0, ~data & 1); } @@ -433,16 +433,16 @@ static WRITE8_HANDLER( journey_op4_w ) static WRITE8_HANDLER( twotiger_op4_w ) { - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); for (int i = 0; i < 2; i++) { /* play tape, and loop it */ - if (!sample_playing(samples, i)) - sample_start(samples, i, i, 1); + if (!samples->playing(i)) + samples->start(i, i, true); /* bit 1 turns cassette on/off */ - sample_set_pause(samples, i, ~data & 2); + samples->pause(i, ~data & 2); } // bit 2: lamp control? @@ -1660,8 +1660,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( mcr_90010_tt, mcr_90010 ) /* sound hardware */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(twotiger_samples_interface) + MCFG_SAMPLES_ADD("samples", twotiger_samples_interface) MCFG_SOUND_ROUTE(0, "lspeaker", 0.25) MCFG_SOUND_ROUTE(1, "rspeaker", 0.25) MACHINE_CONFIG_END @@ -1674,8 +1673,7 @@ static MACHINE_CONFIG_DERIVED( mcr_91475, mcr_90010 ) MCFG_PALETTE_LENGTH(128) /* sound hardware */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(journey_samples_interface) + MCFG_SAMPLES_ADD("samples", journey_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.25) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.25) MACHINE_CONFIG_END diff --git a/src/mame/drivers/meadows.c b/src/mame/drivers/meadows.c index 940df09b196..4c3013f2d5e 100644 --- a/src/mame/drivers/meadows.c +++ b/src/mame/drivers/meadows.c @@ -675,8 +675,7 @@ static MACHINE_CONFIG_START( meadows, meadows_state ) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(meadows_samples_interface) + MCFG_SAMPLES_ADD("samples", meadows_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END @@ -737,13 +736,11 @@ static MACHINE_CONFIG_START( bowl3d, meadows_state ) MCFG_SOUND_ADD("dac", DAC, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(meadows_samples_interface) + MCFG_SAMPLES_ADD("samples", meadows_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) /* audio hardware */ - MCFG_SOUND_ADD("samples2", SAMPLES, 0) - MCFG_SOUND_CONFIG(bowl3d_samples_interface) + MCFG_SAMPLES_ADD("samples2", bowl3d_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/ninjakd2.c b/src/mame/drivers/ninjakd2.c index a3f0f1788b8..7377bcd06e4 100644 --- a/src/mame/drivers/ninjakd2.c +++ b/src/mame/drivers/ninjakd2.c @@ -226,8 +226,8 @@ static WRITE8_HANDLER( ninjakd2_soundreset_w ) static SAMPLES_START( ninjakd2_init_samples ) { - ninjakd2_state *state = device->machine().driver_data(); - running_machine &machine = device->machine(); + ninjakd2_state *state = device.machine().driver_data(); + running_machine &machine = device.machine(); const UINT8* const rom = machine.region("pcm")->base(); const int length = machine.region("pcm")->bytes(); INT16* sampledata = auto_alloc_array(machine, INT16, length); @@ -244,7 +244,7 @@ static SAMPLES_START( ninjakd2_init_samples ) static WRITE8_HANDLER( ninjakd2_pcm_play_w ) { ninjakd2_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("pcm"); + samples_device *samples = space->machine().device("pcm"); const UINT8* const rom = space->machine().region("pcm")->base(); // only Ninja Kid II uses this @@ -262,9 +262,9 @@ static WRITE8_HANDLER( ninjakd2_pcm_play_w ) ++end; if (end - start) - sample_start_raw(samples, 0, &state->m_sampledata[start], end - start, NE555_FREQUENCY, 0); + samples->start_raw(0, &state->m_sampledata[start], end - start, NE555_FREQUENCY); else - sample_stop(samples, 0); + samples->stop(0); } } @@ -979,8 +979,7 @@ static MACHINE_CONFIG_START( ninjakd2, ninjakd2_state ) MCFG_SOUND_ROUTE(2, "mono", 0.10) MCFG_SOUND_ROUTE(3, "mono", 0.50) - MCFG_SOUND_ADD("pcm", SAMPLES, 0) - MCFG_SOUND_CONFIG(ninjakd2_samples_interface) + MCFG_SAMPLES_ADD("pcm", ninjakd2_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END diff --git a/src/mame/drivers/polyplay.c b/src/mame/drivers/polyplay.c index 6985a57061f..1fa29891d34 100644 --- a/src/mame/drivers/polyplay.c +++ b/src/mame/drivers/polyplay.c @@ -300,8 +300,7 @@ static MACHINE_CONFIG_START( polyplay, polyplay_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(polyplay_samples_interface) + MCFG_SAMPLES_ADD("samples", polyplay_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END diff --git a/src/mame/drivers/rallyx.c b/src/mame/drivers/rallyx.c index 832be234e19..feaac3cda8c 100644 --- a/src/mame/drivers/rallyx.c +++ b/src/mame/drivers/rallyx.c @@ -218,7 +218,7 @@ static WRITE8_HANDLER( rallyx_bang_w ) rallyx_state *state = space->machine().driver_data(); if (data == 0 && state->m_last_bang != 0) - sample_start(state->m_samples, 0, 0, 0); + state->m_samples->start(0, 0); state->m_last_bang = data; } @@ -880,7 +880,7 @@ static MACHINE_START( rallyx ) rallyx_state *state = machine.driver_data(); state->m_maincpu = machine.device("maincpu"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->save_item(NAME(state->m_last_bang)); state->save_item(NAME(state->m_stars_enable)); @@ -944,8 +944,7 @@ static MACHINE_CONFIG_START( rallyx, rallyx_state ) MCFG_SOUND_CONFIG(namco_config) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(rallyx_samples_interface) + MCFG_SAMPLES_ADD("samples", rallyx_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) MACHINE_CONFIG_END diff --git a/src/mame/drivers/safarir.c b/src/mame/drivers/safarir.c index 9f75333298a..e596be5ce1f 100644 --- a/src/mame/drivers/safarir.c +++ b/src/mame/drivers/safarir.c @@ -66,7 +66,7 @@ public: UINT8 *m_bg_scroll; UINT8 m_port_last; UINT8 m_port_last2; - device_t *m_samples; + samples_device *m_samples; }; @@ -235,36 +235,36 @@ static SCREEN_UPDATE_IND16( safarir ) static WRITE8_HANDLER( safarir_audio_w ) { safarir_state *state = space->machine().driver_data(); - device_t *samples = state->m_samples; + samples_device *samples = state->m_samples; UINT8 rising_bits = data & ~state->m_port_last; - if (rising_bits == 0x12) sample_start(samples, CHANNEL_SOUND1, SAMPLE_SOUND1_1, 0); - if (rising_bits == 0x02) sample_start(samples, CHANNEL_SOUND1, SAMPLE_SOUND1_2, 0); - if (rising_bits == 0x95) sample_start(samples, CHANNEL_SOUND1, SAMPLE_SOUND6, 0); + if (rising_bits == 0x12) samples->start(CHANNEL_SOUND1, SAMPLE_SOUND1_1); + if (rising_bits == 0x02) samples->start(CHANNEL_SOUND1, SAMPLE_SOUND1_2); + if (rising_bits == 0x95) samples->start(CHANNEL_SOUND1, SAMPLE_SOUND6); - if (rising_bits == 0x04 && (data == 0x15 || data ==0x16)) sample_start(samples, CHANNEL_SOUND2, SAMPLE_SOUND2, 0); + if (rising_bits == 0x04 && (data == 0x15 || data ==0x16)) samples->start(CHANNEL_SOUND2, SAMPLE_SOUND2); - if (data == 0x5f && (rising_bits == 0x49 || rising_bits == 0x5f)) sample_start(samples, CHANNEL_SOUND3, SAMPLE_SOUND3, 1); - if (data == 0x00 || rising_bits == 0x01) sample_stop(samples, CHANNEL_SOUND3); + if (data == 0x5f && (rising_bits == 0x49 || rising_bits == 0x5f)) samples->start(CHANNEL_SOUND3, SAMPLE_SOUND3, true); + if (data == 0x00 || rising_bits == 0x01) samples->stop(CHANNEL_SOUND3); if (data == 0x13) { if ((rising_bits == 0x13 && state->m_port_last != 0x04) || (rising_bits == 0x01 && state->m_port_last == 0x12)) { - sample_start(samples, CHANNEL_SOUND4, SAMPLE_SOUND7, 0); + samples->start(CHANNEL_SOUND4, SAMPLE_SOUND7); } - else if (rising_bits == 0x03 && state->m_port_last2 == 0x15 && !sample_playing(samples, CHANNEL_SOUND4)) + else if (rising_bits == 0x03 && state->m_port_last2 == 0x15 && !samples->playing(CHANNEL_SOUND4)) { - sample_start(samples, CHANNEL_SOUND4, SAMPLE_SOUND4_1, 0); + samples->start(CHANNEL_SOUND4, SAMPLE_SOUND4_1); } } - if (data == 0x53 && state->m_port_last == 0x55) sample_start(samples, CHANNEL_SOUND4, SAMPLE_SOUND4_2, 0); + if (data == 0x53 && state->m_port_last == 0x55) samples->start(CHANNEL_SOUND4, SAMPLE_SOUND4_2); - if (data == 0x1f && rising_bits == 0x1f) sample_start(samples, CHANNEL_SOUND5, SAMPLE_SOUND5_1, 0); - if (data == 0x14 && (rising_bits == 0x14 || rising_bits == 0x04)) sample_start(samples, CHANNEL_SOUND5, SAMPLE_SOUND5_2, 0); + if (data == 0x1f && rising_bits == 0x1f) samples->start(CHANNEL_SOUND5, SAMPLE_SOUND5_1); + if (data == 0x14 && (rising_bits == 0x14 || rising_bits == 0x04)) samples->start(CHANNEL_SOUND5, SAMPLE_SOUND5_2); - if (data == 0x07 && rising_bits == 0x07 && !sample_playing(samples, CHANNEL_SOUND6)) - sample_start(samples, CHANNEL_SOUND6, SAMPLE_SOUND8, 0); + if (data == 0x07 && rising_bits == 0x07 && !samples->playing(CHANNEL_SOUND6)) + samples->start(CHANNEL_SOUND6, SAMPLE_SOUND8); state->m_port_last2 = state->m_port_last; state->m_port_last = data; @@ -298,8 +298,7 @@ static const samples_interface safarir_samples_interface = static MACHINE_CONFIG_FRAGMENT( safarir_audio ) MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(safarir_samples_interface) + MCFG_SAMPLES_ADD("samples", safarir_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -319,7 +318,7 @@ static MACHINE_START( safarir ) state->m_ram_2 = auto_alloc_array(machine, UINT8, state->m_ram_size); state->m_port_last = 0; state->m_port_last2 = 0; - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); /* setup for save states */ state->save_pointer(NAME(state->m_ram_1), state->m_ram_size); diff --git a/src/mame/drivers/segag80v.c b/src/mame/drivers/segag80v.c index 687beeb3f66..7c0e3f8079d 100644 --- a/src/mame/drivers/segag80v.c +++ b/src/mame/drivers/segag80v.c @@ -927,8 +927,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( elim2, g80v_base ) /* custom sound board */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(elim2_samples_interface) + MCFG_SAMPLES_ADD("samples", elim2_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END @@ -936,8 +935,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( spacfury, g80v_base ) /* custom sound board */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(spacfury_samples_interface) + MCFG_SAMPLES_ADD("samples", spacfury_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10) /* speech board */ @@ -948,8 +946,7 @@ MACHINE_CONFIG_END static MACHINE_CONFIG_DERIVED( zektor, g80v_base ) /* custom sound board */ - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(zektor_samples_interface) + MCFG_SAMPLES_ADD("samples", zektor_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.10) MCFG_SOUND_ADD("aysnd", AY8910, CPU_CLOCK/2/2) diff --git a/src/mame/drivers/senjyo.c b/src/mame/drivers/senjyo.c index b99866a4bbf..ec7673a132b 100644 --- a/src/mame/drivers/senjyo.c +++ b/src/mame/drivers/senjyo.c @@ -586,8 +586,7 @@ static MACHINE_CONFIG_START( senjyo, senjyo_state ) MCFG_SOUND_ADD("sn3", SN76496, 2000000) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(senjyo_samples_interface) + MCFG_SAMPLES_ADD("samples", senjyo_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15) MACHINE_CONFIG_END diff --git a/src/mame/drivers/snk6502.c b/src/mame/drivers/snk6502.c index 8b6bf420cdc..7ede9421d0c 100644 --- a/src/mame/drivers/snk6502.c +++ b/src/mame/drivers/snk6502.c @@ -856,8 +856,7 @@ static MACHINE_CONFIG_START( sasuke, snk6502_state ) MCFG_SOUND_ADD("snk6502", SNK6502, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(sasuke_samples_interface) + MCFG_SAMPLES_ADD("samples", sasuke_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.12) MCFG_SOUND_ADD("sn76477.1", SN76477, 0) @@ -884,8 +883,7 @@ static MACHINE_CONFIG_DERIVED( satansat, sasuke ) MCFG_GFXDECODE(satansat) // sound hardware - MCFG_SOUND_REPLACE("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(vanguard_samples_interface) + MCFG_SAMPLES_REPLACE("samples", vanguard_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_REPLACE("sn76477.1", SN76477, 0) @@ -929,8 +927,7 @@ static MACHINE_CONFIG_START( vanguard, snk6502_state ) MCFG_SOUND_ADD("snk6502", SNK6502, 0) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(vanguard_samples_interface) + MCFG_SAMPLES_ADD("samples", vanguard_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MCFG_SOUND_ADD("sn76477.1", SN76477, 0) @@ -948,8 +945,7 @@ static MACHINE_CONFIG_DERIVED( fantasy, vanguard ) MCFG_CPU_PROGRAM_MAP(fantasy_map) // sound hardware - MCFG_SOUND_REPLACE("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(fantasy_samples_interface) + MCFG_SAMPLES_REPLACE("samples", fantasy_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) MCFG_SOUND_REPLACE("sn76477.1", SN76477, 0) diff --git a/src/mame/drivers/starcrus.c b/src/mame/drivers/starcrus.c index 5d4af86f849..6786eece7e6 100644 --- a/src/mame/drivers/starcrus.c +++ b/src/mame/drivers/starcrus.c @@ -159,8 +159,7 @@ static MACHINE_CONFIG_START( starcrus, starcrus_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(starcrus_samples_interface) + MCFG_SAMPLES_ADD("samples", starcrus_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/suna8.c b/src/mame/drivers/suna8.c index cb8b48c49df..6e42d2e51e2 100644 --- a/src/mame/drivers/suna8.c +++ b/src/mame/drivers/suna8.c @@ -1531,8 +1531,7 @@ static MACHINE_CONFIG_START( hardhead, suna8_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(suna8_samples_interface) + MCFG_SAMPLES_ADD("samples", suna8_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_CONFIG_END @@ -1595,8 +1594,7 @@ static MACHINE_CONFIG_START( rranger, suna8_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.90) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.90) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(suna8_samples_interface) + MCFG_SAMPLES_ADD("samples", suna8_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_CONFIG_END @@ -1767,8 +1765,7 @@ static MACHINE_CONFIG_START( starfigh, suna8_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(suna8_samples_interface) + MCFG_SAMPLES_ADD("samples", suna8_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_CONFIG_END @@ -1815,8 +1812,7 @@ static MACHINE_CONFIG_START( sparkman, suna8_state ) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(suna8_samples_interface) + MCFG_SAMPLES_ADD("samples", suna8_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.50) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/drivers/superqix.c b/src/mame/drivers/superqix.c index 22c6b1422ba..e507509a14a 100644 --- a/src/mame/drivers/superqix.c +++ b/src/mame/drivers/superqix.c @@ -110,8 +110,8 @@ DSW2 stored @ $f237 static SAMPLES_START( pbillian_sh_start ) { - superqix_state *state = device->machine().driver_data(); - running_machine &machine = device->machine(); + superqix_state *state = device.machine().driver_data(); + running_machine &machine = device.machine(); UINT8 *src = machine.region("samples")->base(); int i, len = machine.region("samples")->bytes(); @@ -124,7 +124,7 @@ static SAMPLES_START( pbillian_sh_start ) static WRITE8_HANDLER( pbillian_sample_trigger_w ) { superqix_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); UINT8 *src = space->machine().region("samples")->base(); int len = space->machine().region("samples")->bytes(); int start,end; @@ -135,7 +135,7 @@ static WRITE8_HANDLER( pbillian_sample_trigger_w ) while (end < len && src[end] != 0xff) end++; - sample_start_raw(samples, 0, state->m_samplebuf + start, end - start, 5000, 0); // 5khz ? + samples->start_raw(0, state->m_samplebuf + start, end - start, 5000); // 5khz ? } @@ -1070,8 +1070,7 @@ static MACHINE_CONFIG_START( pbillian, superqix_state ) MCFG_SOUND_CONFIG(pbillian_ay8910_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(pbillian_samples_interface) + MCFG_SAMPLES_ADD("samples", pbillian_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -1105,8 +1104,7 @@ static MACHINE_CONFIG_START( hotsmash, superqix_state ) MCFG_SOUND_CONFIG(hotsmash_ay8910_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(pbillian_samples_interface) + MCFG_SAMPLES_ADD("samples", pbillian_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/drivers/tankbatt.c b/src/mame/drivers/tankbatt.c index eb4a42e7bf6..e9608a18163 100644 --- a/src/mame/drivers/tankbatt.c +++ b/src/mame/drivers/tankbatt.c @@ -98,7 +98,7 @@ static WRITE8_HANDLER( tankbatt_interrupt_enable_w ) state->m_sound_enable = !data; /* hack - turn off the engine noise if the normal game nmi's are disabled */ - if (data) sample_stop (space->machine().device("samples"), 2); + if (data) space->machine().device("samples")->stop(2); } static WRITE8_HANDLER( tankbatt_demo_interrupt_enable_w ) @@ -112,23 +112,23 @@ static WRITE8_HANDLER( tankbatt_sh_expl_w ) tankbatt_state *state = space->machine().driver_data(); if (state->m_sound_enable) { - device_t *samples = space->machine().device("samples"); - sample_start (samples, 1, 3, 0); + samples_device *samples = space->machine().device("samples"); + samples->start(1, 3); } } static WRITE8_HANDLER( tankbatt_sh_engine_w ) { tankbatt_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); if (state->m_sound_enable) { if (data) - sample_start (samples, 2, 2, 1); + samples->start(2, 2, true); else - sample_start (samples, 2, 1, 1); + samples->start(2, 1, true); } - else sample_stop (samples, 2); + else samples->stop(2); } static WRITE8_HANDLER( tankbatt_sh_fire_w ) @@ -136,8 +136,8 @@ static WRITE8_HANDLER( tankbatt_sh_fire_w ) tankbatt_state *state = space->machine().driver_data(); if (state->m_sound_enable) { - device_t *samples = space->machine().device("samples"); - sample_start (samples, 0, 0, 0); + samples_device *samples = space->machine().device("samples"); + samples->start(0, 0); } } @@ -311,8 +311,7 @@ static MACHINE_CONFIG_START( tankbatt, tankbatt_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(tankbatt_samples_interface) + MCFG_SAMPLES_ADD("samples", tankbatt_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) MACHINE_CONFIG_END diff --git a/src/mame/drivers/thief.c b/src/mame/drivers/thief.c index b1cfc2fcfd0..ab40042acc5 100644 --- a/src/mame/drivers/thief.c +++ b/src/mame/drivers/thief.c @@ -59,35 +59,35 @@ enum kTalkTrack, kCrashTrack }; -static void tape_set_audio( device_t *samples, int track, int bOn ) +static void tape_set_audio( samples_device *samples, int track, int bOn ) { - sample_set_volume(samples, track, bOn ? 1.0 : 0.0 ); + samples->set_volume(track, bOn ? 1.0 : 0.0 ); } -static void tape_set_motor( device_t *samples, int bOn ) +static void tape_set_motor( samples_device *samples, int bOn ) { if( bOn ) { /* If talk track is not playing, start it. */ - if (! sample_playing(samples, kTalkTrack )) - sample_start( samples, 0, kTalkTrack, 1 ); + if (! samples->playing( kTalkTrack )) + samples->start( 0, kTalkTrack, true ); /* Resume playback of talk track. */ - sample_set_pause( samples, kTalkTrack, 0); + samples->pause( kTalkTrack, false); /* If crash track is not playing, start it. */ - if (! sample_playing(samples, kCrashTrack )) - sample_start( samples, 1, kCrashTrack, 1 ); + if (! samples->playing( kCrashTrack )) + samples->start( 1, kCrashTrack, true ); /* Resume playback of crash track. */ - sample_set_pause( samples, kCrashTrack, 0); + samples->pause( kCrashTrack, false); } else { /* Pause both the talk and crash tracks. */ - sample_set_pause( samples, kTalkTrack, 1 ); - sample_set_pause( samples, kCrashTrack, 1 ); + samples->pause( kTalkTrack, true ); + samples->pause( kCrashTrack, true ); } } @@ -113,27 +113,27 @@ static WRITE8_DEVICE_HANDLER( tape_control_w ) break; case 0x08: /* talk track on */ - tape_set_audio( device, kTalkTrack, 1 ); + tape_set_audio( downcast(device), kTalkTrack, 1 ); break; case 0x09: /* talk track off */ - tape_set_audio( device, kTalkTrack, 0 ); + tape_set_audio( downcast(device), kTalkTrack, 0 ); break; case 0x0a: /* motor on */ - tape_set_motor( device, 1 ); + tape_set_motor( downcast(device), 1 ); break; case 0x0b: /* motor off */ - tape_set_motor( device, 0 ); + tape_set_motor( downcast(device), 0 ); break; case 0x0c: /* crash track on */ - tape_set_audio( device, kCrashTrack, 1 ); + tape_set_audio( downcast(device), kCrashTrack, 1 ); break; case 0x0d: /* crash track off */ - tape_set_audio( device, kCrashTrack, 0 ); + tape_set_audio( downcast(device), kCrashTrack, 0 ); break; } } @@ -465,8 +465,7 @@ static MACHINE_CONFIG_START( sharkatt, thief_state ) MCFG_SOUND_ADD("ay2", AY8910, 4000000/4) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(sharkatt_samples_interface) + MCFG_SAMPLES_ADD("samples", sharkatt_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -502,8 +501,7 @@ static MACHINE_CONFIG_START( thief, thief_state ) MCFG_SOUND_ADD("ay2", AY8910, 4000000/4) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(thief_samples_interface) + MCFG_SAMPLES_ADD("samples", thief_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END @@ -539,8 +537,7 @@ static MACHINE_CONFIG_START( natodef, thief_state ) MCFG_SOUND_ADD("ay2", AY8910, 4000000/4) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(natodef_samples_interface) + MCFG_SAMPLES_ADD("samples", natodef_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_CONFIG_END diff --git a/src/mame/drivers/tmnt.c b/src/mame/drivers/tmnt.c index 257c4135b22..6cb13700116 100644 --- a/src/mame/drivers/tmnt.c +++ b/src/mame/drivers/tmnt.c @@ -264,11 +264,11 @@ static WRITE8_HANDLER( tmnt_sres_w ) /* bit 2 plays the title music */ if (data & 0x04) { - if (!sample_playing(state->m_samples, 0)) - sample_start_raw(state->m_samples, 0, state->m_sampledata, 0x40000, 20000, 0); + if (!state->m_samples->playing(0)) + state->m_samples->start_raw(0, state->m_sampledata, 0x40000, 20000); } else - sample_stop(state->m_samples, 0); + state->m_samples->stop(0); state->m_tmnt_soundlatch = data; } @@ -285,7 +285,7 @@ static READ8_DEVICE_HANDLER( tmnt_upd_busy_r ) static SAMPLES_START( tmnt_decode_sample ) { - running_machine &machine = device->machine(); + running_machine &machine = device.machine(); tmnt_state *state = machine.driver_data(); int i; UINT8 *source = machine.region("title")->base(); @@ -2235,7 +2235,7 @@ static MACHINE_START( common ) state->m_k053260 = machine.device("k053260"); state->m_k054539 = machine.device("k054539"); state->m_upd = machine.device("upd"); - state->m_samples = machine.device("samples"); + state->m_samples = machine.device("samples"); state->m_k052109 = machine.device("k052109"); state->m_k051960 = machine.device("k051960"); state->m_k053245 = machine.device("k053245"); @@ -2413,8 +2413,7 @@ static MACHINE_CONFIG_START( tmnt, tmnt_state ) MCFG_SOUND_ADD("upd", UPD7759, XTAL_640kHz) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(tmnt_samples_interface) + MCFG_SAMPLES_ADD("samples", tmnt_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/tnzs.c b/src/mame/drivers/tnzs.c index 9e474e106d2..f961988fcf9 100644 --- a/src/mame/drivers/tnzs.c +++ b/src/mame/drivers/tnzs.c @@ -632,7 +632,7 @@ Driver by Takahiro Nogi (nogi@kt.rim.or.jp) 1999/11/06 static SAMPLES_START( kageki_init_samples ) { - running_machine &machine = device->machine(); + running_machine &machine = device.machine(); tnzs_state *state = machine.driver_data(); UINT8 *scan, *src; INT16 *dest; @@ -717,16 +717,17 @@ static WRITE8_DEVICE_HANDLER( kageki_csport_w ) } else { + samples_device *samples = downcast(device); if (data > MAX_SAMPLES) { // stop samples - sample_stop(device, 0); + samples->stop(0); sprintf(mess, "VOICE:%02X STOP", data); } else { // play samples - sample_start_raw(device, 0, state->m_sampledata[data], state->m_samplesize[data], 7000, 0); + samples->start_raw(0, state->m_sampledata[data], state->m_samplesize[data], 7000); sprintf(mess, "VOICE:%02X PLAY", data); } // popmessage(mess); @@ -1818,8 +1819,7 @@ static MACHINE_CONFIG_START( kageki, tnzs_state ) MCFG_SOUND_ROUTE(2, "mono", 0.15) MCFG_SOUND_ROUTE(3, "mono", 0.35) - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(tnzs_samples_interface) + MCFG_SAMPLES_ADD("samples", tnzs_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_CONFIG_END diff --git a/src/mame/drivers/triplhnt.c b/src/mame/drivers/triplhnt.c index dec0543bf43..f7cb1e17610 100644 --- a/src/mame/drivers/triplhnt.c +++ b/src/mame/drivers/triplhnt.c @@ -36,7 +36,7 @@ void triplhnt_set_collision(running_machine &machine, int code) static void triplhnt_update_misc(running_machine &machine, int offset) { triplhnt_state *state = machine.driver_data(); - device_t *samples = machine.device("samples"); + samples_device *samples = machine.device("samples"); device_t *discrete = machine.device("discrete"); UINT8 is_witch_hunt; UINT8 bit = offset >> 1; @@ -80,14 +80,14 @@ static void triplhnt_update_misc(running_machine &machine, int offset) bit = ~state->m_misc_flags & 0x40; /* if we're not playing the sample yet, start it */ - if (!sample_playing(samples, 0)) - sample_start(samples, 0, 0, 1); - if (!sample_playing(samples, 1)) - sample_start(samples, 1, 1, 1); + if (!samples->playing(0)) + samples->start(0, 0, true); + if (!samples->playing(1)) + samples->start(1, 1, true); /* bit 6 turns cassette on/off */ - sample_set_pause(samples, 0, is_witch_hunt || bit); - sample_set_pause(samples, 1, !is_witch_hunt || bit); + samples->pause(0, is_witch_hunt || bit); + samples->pause(1, !is_witch_hunt || bit); } @@ -334,8 +334,7 @@ static MACHINE_CONFIG_START( triplhnt, triplhnt_state ) /* sound hardware */ MCFG_SPEAKER_STANDARD_MONO("mono") - MCFG_SOUND_ADD("samples", SAMPLES, 0) - MCFG_SOUND_CONFIG(triplhnt_samples_interface) + MCFG_SAMPLES_ADD("samples", triplhnt_samples_interface) MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) MCFG_SOUND_ADD("discrete", DISCRETE, 0) diff --git a/src/mame/includes/astrof.h b/src/mame/includes/astrof.h index 246cad2598f..28ccaef566b 100644 --- a/src/mame/includes/astrof.h +++ b/src/mame/includes/astrof.h @@ -4,6 +4,8 @@ ****************************************************************************/ +#include "sound/samples.h" + class astrof_state : public driver_device { public: @@ -33,7 +35,7 @@ public: /* devices */ device_t *m_maincpu; - device_t *m_samples; // astrof & abattle + samples_device *m_samples; // astrof & abattle device_t *m_sn; // tomahawk }; diff --git a/src/mame/includes/circus.h b/src/mame/includes/circus.h index c0153bb311f..2bea99c3b92 100644 --- a/src/mame/includes/circus.h +++ b/src/mame/includes/circus.h @@ -17,7 +17,7 @@ public: /* devices */ device_t *m_maincpu; - device_t *m_samples; + samples_device *m_samples; device_t *m_discrete; /* game id */ diff --git a/src/mame/includes/cosmic.h b/src/mame/includes/cosmic.h index 72c42bc99e3..9be549fb49d 100644 --- a/src/mame/includes/cosmic.h +++ b/src/mame/includes/cosmic.h @@ -4,6 +4,8 @@ *************************************************************************/ +#include "sound/samples.h" + #define COSMICG_MASTER_CLOCK XTAL_9_828MHz #define Z80_MASTER_CLOCK XTAL_10_816MHz @@ -36,7 +38,7 @@ public: UINT32 m_pixel_clock; /* devices */ - device_t *m_samples; + samples_device *m_samples; device_t *m_dac; }; diff --git a/src/mame/includes/gotya.h b/src/mame/includes/gotya.h index dd0cb1ee29e..9ef7c59ae24 100644 --- a/src/mame/includes/gotya.h +++ b/src/mame/includes/gotya.h @@ -1,3 +1,4 @@ +#include "sound/samples.h" class gotya_state : public driver_device { @@ -20,7 +21,7 @@ public: int m_theme_playing; /* devices */ - device_t *m_samples; + samples_device *m_samples; }; diff --git a/src/mame/includes/m10.h b/src/mame/includes/m10.h index 4c43e244cfb..2c5895a1abb 100644 --- a/src/mame/includes/m10.h +++ b/src/mame/includes/m10.h @@ -4,6 +4,7 @@ ****************************************************************************/ +#include "sound/samples.h" #define IREMM10_MASTER_CLOCK (12500000) @@ -59,7 +60,7 @@ public: device_t *m_maincpu; device_t *m_ic8j1; device_t *m_ic8j2; - device_t *m_samples; + samples_device *m_samples; }; diff --git a/src/mame/includes/mw8080bw.h b/src/mame/includes/mw8080bw.h index 08c4568c0ed..2709070b578 100644 --- a/src/mame/includes/mw8080bw.h +++ b/src/mame/includes/mw8080bw.h @@ -68,9 +68,9 @@ public: /* devices */ device_t *m_maincpu; device_t *m_mb14241; - device_t *m_samples; - device_t *m_samples1; - device_t *m_samples2; + samples_device *m_samples; + samples_device *m_samples1; + samples_device *m_samples2; device_t *m_sn1; device_t *m_sn2; device_t *m_sn; diff --git a/src/mame/includes/rallyx.h b/src/mame/includes/rallyx.h index c14cc572f6a..e1d44c258ea 100644 --- a/src/mame/includes/rallyx.h +++ b/src/mame/includes/rallyx.h @@ -1,3 +1,5 @@ +#include "sound/samples.h" + struct jungler_star { int x, y, color; @@ -33,7 +35,7 @@ public: /* devices */ cpu_device *m_maincpu; - device_t *m_samples; + samples_device *m_samples; UINT8 m_main_irq_mask; }; diff --git a/src/mame/includes/tmnt.h b/src/mame/includes/tmnt.h index 4f5503fa573..c0d0cde6b62 100644 --- a/src/mame/includes/tmnt.h +++ b/src/mame/includes/tmnt.h @@ -1,3 +1,4 @@ +#include "sound/samples.h" class tmnt_state : public driver_device { @@ -54,7 +55,7 @@ public: device_t *m_k053936; device_t *m_k054000; device_t *m_upd; - device_t *m_samples; + samples_device *m_samples; /* memory buffers */ INT16 m_sampledata[0x40000]; diff --git a/src/mame/machine/gaplus.c b/src/mame/machine/gaplus.c index cbe9d714792..cd5482ccea3 100644 --- a/src/mame/machine/gaplus.c +++ b/src/mame/machine/gaplus.c @@ -21,9 +21,9 @@ WRITE8_HANDLER( gaplus_customio_3_w ) { gaplus_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); if ((offset == 0x09) && (data >= 0x0f)) - sample_start(samples,0,0,0); + samples->start(0,0); state->m_customio_3[offset] = data; } diff --git a/src/mame/machine/mw8080bw.c b/src/mame/machine/mw8080bw.c index 3113e38ddae..5936d60b7cb 100644 --- a/src/mame/machine/mw8080bw.c +++ b/src/mame/machine/mw8080bw.c @@ -101,9 +101,9 @@ MACHINE_START( mw8080bw ) mw8080bw_create_interrupt_timer(machine); state->m_maincpu = machine.device("maincpu"); - state->m_samples = machine.device("samples"); - state->m_samples1 = machine.device("samples1"); - state->m_samples2 = machine.device("samples2"); + state->m_samples = machine.device("samples"); + state->m_samples1 = machine.device("samples1"); + state->m_samples2 = machine.device("samples2"); state->m_sn = machine.device("snsnd"); state->m_sn1 = machine.device("sn1"); state->m_sn2 = machine.device("sn2"); diff --git a/src/mame/machine/xevious.c b/src/mame/machine/xevious.c index 8a42e9e1c53..2071aaf74b1 100644 --- a/src/mame/machine/xevious.c +++ b/src/mame/machine/xevious.c @@ -159,10 +159,10 @@ WRITE8_HANDLER( battles_noise_sound_w ) if( (battles_sound_played == 0) && (data == 0xFF) ){ samples_device *samples = space->machine().device("samples"); if( customio[0] == 0x40 ){ - sample_start (samples, 0, 0, 0); + samples->start(0, 0); } else{ - sample_start (samples, 0, 1, 0); + samples->start(0, 1); } } battles_sound_played = data; diff --git a/src/mame/mame.c b/src/mame/mame.c index 4f5a6bfb4bf..27beb5bc5bd 100644 --- a/src/mame/mame.c +++ b/src/mame/mame.c @@ -8,6 +8,7 @@ Visit http://mamedev.org for licensing and usage restrictions. ****************************************************************************/ + #include "emu.h" #define APPNAME "MAME" diff --git a/src/mame/video/starcrus.c b/src/mame/video/starcrus.c index 57e71cd27a6..90e716f7855 100644 --- a/src/mame/video/starcrus.c +++ b/src/mame/video/starcrus.c @@ -30,7 +30,7 @@ VIDEO_START( starcrus ) WRITE8_HANDLER( starcrus_ship_parm_1_w ) { starcrus_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); state->m_s1_sprite = data&0x1f; state->m_engine1_on = ((data&0x20)>>5)^0x01; @@ -40,7 +40,7 @@ WRITE8_HANDLER( starcrus_ship_parm_1_w ) if (state->m_engine_sound_playing == 0) { state->m_engine_sound_playing = 1; - sample_start(samples, 0, 0, 1); /* engine sample */ + samples->start(0, 0, true); /* engine sample */ } } else @@ -48,7 +48,7 @@ WRITE8_HANDLER( starcrus_ship_parm_1_w ) if (state->m_engine_sound_playing == 1) { state->m_engine_sound_playing = 0; - sample_stop(samples, 0); + samples->stop(0); } } } @@ -56,7 +56,7 @@ WRITE8_HANDLER( starcrus_ship_parm_1_w ) WRITE8_HANDLER( starcrus_ship_parm_2_w ) { starcrus_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); state->m_s2_sprite = data&0x1f; set_led_status(space->machine(), 2,~data & 0x80); /* game over lamp */ @@ -68,7 +68,7 @@ WRITE8_HANDLER( starcrus_ship_parm_2_w ) if (state->m_engine_sound_playing == 0) { state->m_engine_sound_playing = 1; - sample_start(samples, 0, 0, 1); /* engine sample */ + samples->start(0, 0, true); /* engine sample */ } } else @@ -76,7 +76,7 @@ WRITE8_HANDLER( starcrus_ship_parm_2_w ) if (state->m_engine_sound_playing == 1) { state->m_engine_sound_playing = 0; - sample_stop(samples, 0); + samples->stop(0); } } @@ -85,7 +85,7 @@ WRITE8_HANDLER( starcrus_ship_parm_2_w ) WRITE8_HANDLER( starcrus_proj_parm_1_w ) { starcrus_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); state->m_p1_sprite = data&0x0f; state->m_launch1_on = ((data&0x20)>>5)^0x01; @@ -96,7 +96,7 @@ WRITE8_HANDLER( starcrus_proj_parm_1_w ) if (state->m_explode_sound_playing == 0) { state->m_explode_sound_playing = 1; - sample_start(samples, 1,1,1); /* explosion initial sample */ + samples->start(1,1, true); /* explosion initial sample */ } } else @@ -104,7 +104,7 @@ WRITE8_HANDLER( starcrus_proj_parm_1_w ) if (state->m_explode_sound_playing == 1) { state->m_explode_sound_playing = 0; - sample_start(samples, 1,2,0); /* explosion ending sample */ + samples->start(1,2); /* explosion ending sample */ } } @@ -113,7 +113,7 @@ WRITE8_HANDLER( starcrus_proj_parm_1_w ) if (state->m_launch1_sound_playing == 0) { state->m_launch1_sound_playing = 1; - sample_start(samples, 2,3,0); /* launch sample */ + samples->start(2,3); /* launch sample */ } } else @@ -125,7 +125,7 @@ WRITE8_HANDLER( starcrus_proj_parm_1_w ) WRITE8_HANDLER( starcrus_proj_parm_2_w ) { starcrus_state *state = space->machine().driver_data(); - device_t *samples = space->machine().device("samples"); + samples_device *samples = space->machine().device("samples"); state->m_p2_sprite = data&0x0f; state->m_launch2_on = ((data&0x20)>>5)^0x01; @@ -136,7 +136,7 @@ WRITE8_HANDLER( starcrus_proj_parm_2_w ) if (state->m_explode_sound_playing == 0) { state->m_explode_sound_playing = 1; - sample_start(samples, 1,1,1); /* explosion initial sample */ + samples->start(1,1, true); /* explosion initial sample */ } } else @@ -144,7 +144,7 @@ WRITE8_HANDLER( starcrus_proj_parm_2_w ) if (state->m_explode_sound_playing == 1) { state->m_explode_sound_playing = 0; - sample_start(samples, 1,2,0); /* explosion ending sample */ + samples->start(1,2); /* explosion ending sample */ } } @@ -153,7 +153,7 @@ WRITE8_HANDLER( starcrus_proj_parm_2_w ) if (state->m_launch2_sound_playing == 0) { state->m_launch2_sound_playing = 1; - sample_start(samples, 3,3,0); /* launch sample */ + samples->start(3,3); /* launch sample */ } } else