diff options
author | 2025-04-14 11:31:53 +0200 | |
---|---|---|
committer | 2025-04-14 22:28:31 +0200 | |
commit | cef6157803320544651bfc96457d2f8a6df0abd6 (patch) | |
tree | f8a64867e3d654cdcad5f4c24824ea82e2c77194 | |
parent | 9473c027358e1a2d5c93d240a48052368f9d3b84 (diff) |
New sound infrastructure.sound
Should be added soon:
- mute
- lua hookup (with documentation)
- speaker/microphone resampling
To be added a little later:
- compression
- reverb
Needs to be added by someone else:
- coreaudio
- direct
- portaudio
- xaudio2
- js
1085 files changed, 14215 insertions, 9705 deletions
diff --git a/docs/man/mame.6 b/docs/man/mame.6 index 3d83084e4c0..5d0123f486f 100644 --- a/docs/man/mame.6 +++ b/docs/man/mame.6 @@ -944,7 +944,7 @@ the audio output is overdriven. The default is ON (\-compressor). .TP .B \-volume, \-vol \fIvalue Sets the startup volume. It can later be changed with the user interface -(see Keys section). The volume is an attenuation in dB: e.g., +(see Keys section). The volume is in dB: e.g., "\-volume \-12" will start with \-12dB attenuation. The default is 0. .\" +++++++++++++++++++++++++++++++++++++++++++++++++++++++ .\" SDL specific diff --git a/docs/source/commandline/commandline-all.rst b/docs/source/commandline/commandline-all.rst index d83b401cc32..9f058e10dff 100644 --- a/docs/source/commandline/commandline-all.rst +++ b/docs/source/commandline/commandline-all.rst @@ -2969,7 +2969,7 @@ Core Sound Options **-volume** / **-vol** *<value>* Sets the initial sound volume. It can be changed later with the user - interface (see Keys section). The volume is an attenuation in decibels: + interface (see Keys section). The volume is in decibels: e.g. "**-volume -12**" will start with -12 dB attenuation. Note that if the volume is changed in the user interface it will be saved to the configuration file for the system. The value from the configuration file diff --git a/docs/source/luascript/ref-core.rst b/docs/source/luascript/ref-core.rst index 7b72d90ebdb..ad6dc24d330 100644 --- a/docs/source/luascript/ref-core.rst +++ b/docs/source/luascript/ref-core.rst @@ -404,9 +404,8 @@ sound.debugger_mute (read/write) sound.system_mute (read/write) A Boolean indicating whether sound output is muted at the request of the emulated system. -sound.attenuation (read/write) - The output volume attenuation in decibels. Should generally be a negative - integer or zero. +sound.volume (read/write) + The output volume in decibels. Should generally be a negative or zero. sound.recording (read-only) A Boolean indicating whether sound output is currently being recorded to a WAV file. diff --git a/docs/source/techspecs/audio_effects.rst b/docs/source/techspecs/audio_effects.rst new file mode 100644 index 00000000000..92e2393af8e --- /dev/null +++ b/docs/source/techspecs/audio_effects.rst @@ -0,0 +1,147 @@ +Audio effects +============= + +.. contents:: :local: + + +1. Generalities +--------------- + +The audio effects are effects that are applied to the sound between +the speaker devices and the actual sound output. In the current +implementation the effect chain is fixed (but not the effect +parameters), and the parameters are stored in the cfg files. They are +honestly not really designed for extensibility yet, if ever. + +Adding an effect requires working on four parts: + +* audio_effects/aeffects.* for effect object creation and "publishing" +* audio_effects/youreffect.* for the effect implementation +* frontend/mame/ui/audioeffects.cpp to be able to instantiate the effect configuration menu +* frontend/mame/ui/audioyoureffect.* to implement the effect configuration menu + +2. audio_effects/aeffects.* +--------------------------- + +The audio_effect class in the aeffect sources provides three things: + +* an enum value to designate the effect type and which much match its + position in the chain (iow, the effect chain follows the enum order), + in the .h +* the effect name in the audio_effect::effect_names array in the .cpp +* the creation of a correct effect object in audio_effect::create in the .cpp + + + +3. audio_effects/youreffect.* +----------------------------- + +This is where you implement the effect. It takes the shape of a +audio_effect_youreffect class which derives from audio_effect. + +The methods to implement are: + +.. code-block:: C++ + + audio_effect_youreffect(u32 sample_rate, audio_effect *def); + + virtual int type() const override; + virtual void config_load(util::xml::data_node const *ef_node) override; + virtual void config_save(util::xml::data_node *ef_node) const override; + virtual void default_changed() override; + virtual u32 history_size() const; // optional + +The constructor must pass the parameters to ``audio_effect`` and +initialize the effect parameters. ``type`` must return the enum value +for the effect. ``config_load`` and ``config_save`` should load or +save the effect parameters from/to the cfg file xml tree. +``default_changed`` is called when the parameters in ``m_default`` are +changed and the parameters may need to be updated. ``history_size`` +allows to tell how many samples should still be available of the +previous input frame. Note that this number must not depend on the +parameters and only on the sample rate. + +An effect have a number of parameters that can come from three sources: + +* fixed default value +* equivalent effect object from the default effect chain +* user setting through the UI + +The first two are recognized through the value of ``m_default`` which +gets the value of ``def`` in the constructor. When it's nullptr, the +value to use when not set by the user is the fixed one, otherwise it's +the one in ``m_default``. + +At a minimum an effect should have a parameter allowing to bypass it. + +Managing a parameter uses four methods: + +* ``type param() const;`` returns the current parameter value +* ``void set_param(type value);`` sets the current parameter value and marks it as set by the user +* ``bool isset_param() const;`` returns true is the parameter was set by the user +* ``void reset_param();`` resets the parameter to the default value (from m_default or fixed) and marks it as not set by the user + +``config_save`` must only save the user-set parameters. +``config_load`` must retrieve the parameters that are present and mark +them as set by the user and reset all the others. + +Finally the actual implementation goes into the ``apply`` method: + +.. code-block:: C++ + + virtual void apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) override; + +That method takes two buffers with the same number of channels and has +to apply the effect to ``src`` to produce ``dest``. The +``output_buffer_flat`` is non-interleaved with independant per-channel +buffers. + +To make bypassing easier, the ``copy(src, dest)`` method of +audio_effect allows to copy the samples from ``src`` to ``dest`` +without changing them. + +The effect application part should looks like: + +.. code-block:: C++ + + u32 samples = src.available_samples(); + dest.prepare_space(samples); + u32 channels = src.channels(); + + // generate channels * samples results and put them in dest + + dest.commit(samples); + +To get pointers to the buffers, one uses: + +.. code-block:: C++ + + const sample_t *source = src.ptrs(channel, source_index); // source_index must be in [-history_size()..samples-1] + sample_t *destination = dest.ptrw(channel, destination_index); // destination_index must be in [0..samples-1] + +The samples pointed by source and destination are contiguous. The +number of channels will not change from one apply call to another, the +number of samples will vary though. Also the call happens in a +different thread than the main thread and also in a different thread +than the parameter setting calls are made from. + + + + +4. frontend/mame/ui/audioeffects.cpp +------------------------------------ + +There it suffices to add a creation of the menu +menu_audio_effect_youreffect in menu_audio_effects::handle. The menu +effect will pick the effect names from audio_effect (in aeffect.*). + + +5. frontend/mame/ui/audioyoureffect.* +------------------------------------- + +This is used to implement the configuration menu for the effect. It's +a little complicated because it needs to generate the list of +parameters and their values, set left or right arrow flags depending +on the possible modifications, dim them (FLAG_INVERT) when not set by +the user, and manage the arrows and clear keys to change them. Just +copy an existing one and change it as needed. diff --git a/docs/source/techspecs/device_sound_interface.rst b/docs/source/techspecs/device_sound_interface.rst new file mode 100644 index 00000000000..88bfbf86d35 --- /dev/null +++ b/docs/source/techspecs/device_sound_interface.rst @@ -0,0 +1,286 @@ +The device_sound_interface +========================== + +.. contents:: :local: + + +1. The sound system +------------------- + +The device sound interface is the entry point for devices that handle +sound input and/or output. The sound system is built on the concept +of *streams* which connect devices together with resampling and mixing +applied transparently as needed. Microphones (audio input) and +speakers (audio output) are specific known devices which use the same +interface. + +2. Devices using device_sound_interface +--------------------------------------- + +2.1 Initialisation +~~~~~~~~~~~~~~~~~~ + +Sound streams must be created in the device_start (or +interface_pre_start) method. + +.. code-block:: C++ + + sound_stream *stream_alloc(int inputs, int outputs, int sample_rate, sound_stream_flags flags = STREAM_DEFAULT_FLAGS); + +A stream is created with ``stream_alloc``. It takes the number of +input and output channels, the sample rate and optionally flags. + +The sample rate can be SAMPLE_RATE_INPUT_ADAPTIVE, +SAMPLE_RATE_OUTPUT_ADAPTIVE or SAMPLE_RATE_ADAPTIVE. In that case the +chosen sample rate is the highest one amongs the inputs, outputs or +both respectively. In case of loop, the chosen sample rate is the +configured global sample rate. + +The only available non-default flag is STREAM_SYNCHRONOUS. When set, +the sound generation method will be called for every sample +individually. It's necessary for dsps that run a program on every +sample. but on the other hand it's expensive, so only to be used when +required. + +Devices can create multiple streams. It's rare though. Some yamaha +chips should but don't. Inputs and outputs are numbered from 0 and +collate all streams in the order they are created. + + +2.2 Sound input/output +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + virtual void sound_stream_update(sound_stream &stream); + +This method is required to be implemented to consume the input samples +and/or compute the output ones. The stream to update for is passed as +the parameter. See the streams section, specifically sample access, +to see how to write the method. + + +2.3 Stream information +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + int inputs() const; + int outputs() const; + std::pair<sound_stream *, int> input_to_stream_input(int inputnum) const; + std::pair<sound_stream *, int> output_to_stream_output(int outputnum) const; + +The method ``inputs`` returns the total number of inputs in the +streams created by the device. The method ``outputs`` similarly +counts the outputs. The other two methods allow to grab the stream +and channel number for the device corresponding to the global input or +output number. + + +2.4 Gain management +~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + float input_gain(int inputnum) const; + float output_gain(int outputnum) const; + void set_input_gain(int inputnum, float gain); + void set_output_gain(int outputnum, float gain); + void set_route_gain(int source_channel, device_sound_interface *target, int target_channel, float gain); + + float user_output_gain() const; + float user_output_gain(int outputnum) const; + void set_user_output_gain(float gain); + void set_user_output_gain(int outputnum, float gain); + +Those methods allow to set the gain on every step of the routes +between streams. All gains are multipliers, with default value 1.0. +The steps are, from samples output in ``sound_stream_update`` to +samples read in the next device's ``sound_stream_update``: + +* Per-channel output gain +* Per-channel user output gain +* Per-device user output gain +* Per-route gain +* Per-channel input gain + +The user gains must not be set from the driver, they're for use by the +user interface (the sliders) and are saved in the game configuration. +The other gains are for driver/device use, and are saved in save +states. + + +2.5 Routing setup +~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + device_sound_interface &add_route(u32 output, const device_finder<T, R> &target, double gain, u32 channel = 0) + device_sound_interface &add_route(u32 output, const char *target, double gain, u32 channel = 0); + device_sound_interface &add_route(u32 output, device_sound_interface &target, double gain, u32 channel = 0); + + device_sound_interface &reset_routes(); + +Routes between devices, e.g. between streams, are set at configuration +time. The method ``add_route`` must be called on the source device +and gives the channel on the source device, the target device, the +gain, and optionally the channel on the target device. The constant +``ALL_OUTPUTS`` can be used to add a route from every channel of the +source to a given channel of the destination. + +The method ``reset_routes`` is used to remove all the routes setup on +a given source device. + + +.. code-block:: C++ + + u32 get_sound_requested_inputs() const; + u32 get_sound_requested_outputs() const; + u64 get_sound_requested_inputs_mask() const; + u64 get_sound_requested_outputs_mask() const; + +Those methods are useful for devices which want to behave differently +depending on what routes are setup on them. You get either the max +number of requested channel plus one (which is the number of channels +when all channels are routed, but is more useful when there are gaps) +or a mask of use for channels 0-63. Note that ``ALL_OUTPUTS`` does +not register any specific output or output count. + + + +3. Streams +---------- + +3.1 Generalities +~~~~~~~~~~~~~~~~ + +Streams are endpoints associated with devices and, when connected +together, ensure the transmission of audio data between them. A +stream has a number of inputs (which can be zero) and outputs (same) +and one sample rate which is common to all inputs and outputs. The +connections are setup at the machine configuration level and the sound +system ensures mixing and resampling is done transparently. + +Samples in streams are encoded as sample_t. In the current +implementation, this is a float. Nominal values are between -1 and 1, +but clamping at the device level is not recommended (unless that's +what happens in hardware of course) because the gain values, volume +and effects can easily avoid saturation. + +They are implemented in the class ``sound_stream``. + + +3.2 Characteristics +~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + device_t &device() const; + bool input_adaptive() const; + bool output_adaptive() const; + bool synchronous() const; + u32 input_count() const; + u32 output_count() const; + u32 sample_rate() const; + attotime sample_period() const; + + +3.3 Sample access +~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + s32 samples() const; + + void put(s32 output, s32 index, sample_t sample); + void put_clamp(s32 output, s32 index, sample_t sample, sample_t clamp = 1.0); + void put_int(s32 output, s32 index, s32 sample, s32 max); + void put_int_clamp(s32 output, s32 index, s32 sample, s32 maxclamp); + void add(s32 output, s32 index, sample_t sample); + void add_int(s32 output, s32 index, s32 sample, s32 max); + void fill(s32 output, sample_t value, s32 start, s32 count); + void fill(s32 output, sample_t value, s32 start); + void fill(s32 output, sample_t value); + void copy(s32 output, s32 input, s32 start, s32 count); + void copy(s32 output, s32 input, s32 start); + void copy(s32 output, s32 input); + sample_t get(s32 input, s32 index) const; + sample_t get_output(s32 output, s32 index) const; + +Those are the methods used to implement ``sound_stream_update``. +First ``samples`` tells how many samples to consume and/or generate. +The to-generate samples, if any, are pre-cleared (e.g. set to zero). + +Input samples are retrieved with ``get``, where ``input`` is the +stream channel number and ``index`` the sample number. + +Generated samples are written with the put variants. ``put`` sets a +sample_t in channel ``output`` at position ``index``. ``put_clamp`` +does the same but first clamps the value to +/-``clamp``. ``put_int`` +does it with an integer ``sample`` but pre-divides it by ``max``. +``put_int_clamp`` does the same but also pre-clamps within +-``maxclamp`` and ``maxclamp``-1, which is the normal range for a +2-complement value. + +``add`` and ``add_int`` are similar but add the value of the sample to +what's there instead of replacing. ``get_output`` gets the currently +stored output value. + +``fill`` sets a range of the an output channel to a given ``value``. +``start`` tells where to start (default index 0), ``count`` how many +(default up to the end of the buffer). + +``copy`` does the same as fill but gets its value from the indentical +position in an input channel. + +Note that clamping should not be used unless it actually happens in +hardware. Between gains and effects there is a fair chance saturation +can be avoided later in the chain. + + + +3.4 Gain management +~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + float user_output_gain() const; + void set_user_output_gain(float gain); + float user_output_gain(s32 output) const; + void set_user_output_gain(s32 output, float gain); + + float input_gain(s32 input) const; + void set_input_gain(s32 input, float gain); + void apply_input_gain(s32 input, float gain); + float output_gain(s32 output) const; + void set_output_gain(s32 output, float gain); + void apply_output_gain(s32 output, float gain); + + +This is similar to the device gain control, with a twist: apply +multiplies the current gain by the given value. + + +3.5 Misc. actions +~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + void set_sample_rate(u32 sample_rate); + void update(); + +The method ``set_sample_rate`` allows to change the sample rate of the +stream. The method ``update`` triggers a call of +``sound_stream_update`` on the stream and the ones it depends on to +reach the current time in terms of samples. + + +4. Devices using device_mixer_interface +--------------------------------------- + +The device mixer interface is used for devices that want to relay +sound in the device tree without acting on it. It's very useful on +for instance slot devices connectors, where the slot device may have +an audio connection with the main system. They are routed like every +other sound device, create the streams automatically and copy input to +output. Nothing needs to be done in the device. diff --git a/docs/source/techspecs/index.rst b/docs/source/techspecs/index.rst index 71f74618965..72c678b4ca6 100644 --- a/docs/source/techspecs/index.rst +++ b/docs/source/techspecs/index.rst @@ -15,6 +15,7 @@ MAME’s source or working on scripts that run within the MAME framework. device_memory_interface device_rom_interface device_disasm_interface + device_sound_interface memory cpu_device floppy @@ -22,3 +23,5 @@ MAME’s source or working on scripts that run within the MAME framework. m6502 uml_instructions poly_manager + audio_effects + osd_audio diff --git a/docs/source/techspecs/osd_audio.rst b/docs/source/techspecs/osd_audio.rst new file mode 100644 index 00000000000..e6f1492f8f0 --- /dev/null +++ b/docs/source/techspecs/osd_audio.rst @@ -0,0 +1,334 @@ +OSD audio support +================= + +Introduction +------------ + +The audio support in Mame tries to allow the user to freely map +between the emulated system audio outputs (called speakers) and the +host system audio. A part of it is the OSD support, where a +host-specific module ensures the interface between Mame and the host. +This is the documentation for that module. + +Note: this is currenty output-only, but input should follow. + + +Capabitilies +------------ + +The OSD interface is designed to allow three levels of support, +depending on what the API allows and the amount of effort to expend. +Those are: + +* Level 1: One or more audio targets, only one stream allowed per target (aka exclusive mode) +* Level 2: One or more audio targets, multiple streams per target +* Level 3: One or more audio targets, multiple streams per target, user-visible per-stream-channel volume control + +In any case we support having the user use an external interface to +change the target of a stream and, in level 3, change the volumes. By +support we mean storing the information in the per-game configuration +and keeping in the internal UI in sync. + + +Terminology +----------- + +For this module, we use the terms: + +* node: some object we can send audio to. Can be physical, like speakers, or virtual, like an effect system. It should have a unique, user-presentable name for the UI. +* port: a channel of a node, has a name (non-unique, like "front left") and a 3D position +* stream: a connection to a node with allows to send audio to it + + +Reference documentation +----------------------- + +Adding a module +~~~~~~~~~~~~~~~ + +Adding a module is done by adding a cpp file to src/osd/modules/sound +which follows this structure, + +.. code-block:: C++ + + // License/copyright + #include "sound_module.h" + #include "modules/osdmodules.h" + + #ifdef MODULE_SUPPORT_KEY + + #include "modules/lib/osdobj_common.h" + + // [...] + namespace osd { + namespace { + + class sound_module_class : public osd_module, public sound_module + { + sound_module_class() : osd_module(OSD_SOUND_PROVIDER, "module_name"), + sound_module() + // ... + }; + + } + } + #else + namespace osd { namespace { + MODULE_NOT_SUPPORTED(sound_module_class, OSD_SOUND_PROVIDER, "module_name") + }} + #endif + + MODULE_DEFINITION(SOUND_MODULE_KEY, osd::sound_module_class) + +In that code, four names must be chosen: + +* MODULE_SUPPORT_KEY some #define coming from the genie scripts to tell that this particular module can be compiled (like NO_USE_PIPEWIRE or SDLMAME_MACOSX) +* sound_module_class is the name of the class which makes up the module (like sound_coreaudio) +* module_name is the name to be used in -sound <xxx> to select that particular module (like coreaudio) +* SOUND_MODULE_KEY is a symbol that represents the module internally (like SOUND_COREAUDIO) + +The file path needs to be added to scripts/src/osd/modules.lua in +osdmodulesbuild() and the module reference to +src/osd/modules/lib/osdobj_common.cpp in +osd_common_t::register_options with the line: + +.. code-block:: C++ + + REGISTER_MODULE(m_mod_man, SOUND_MODULE_KEY); + +This should ensure that the module is reachable through -sound <xxx> +on the appropriate hosts. + + +Interface +~~~~~~~~~ + +The full interface is: + +.. code-block:: C++ + + virtual bool split_streams_per_source() const override; + virtual bool external_per_channel_volume() const override; + + virtual int init(osd_interface &osd, osd_options const &options) override; + virtual void exit() override; + + virtual uint32_t get_generation() override; + virtual osd::audio_info get_information() override; + virtual uint32_t stream_sink_open(uint32_t node, std::string name, uint32_t rate) override; + virtual uint32_t stream_source_open(uint32_t node, std::string name, uint32_t rate) override; + virtual void stream_set_volumes(uint32_t id, const std::vector<float> &db) override; + virtual void stream_close(uint32_t id) override; + virtual void stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) override; + virtual void stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) override; + + +The class sound_module provides default for minimum capabilities: one +stereo target and stream at default sample rate. To support that, +only *init*, *exit* and *stream_update* need to be implemented. +*init* is called at startup and *exit* when quitting and can do +whatever they need to do. *stream_sink_update* will be called on a +regular basis with a buffer of sample_this_frame*2*int16_t with the +audio to play. From this point in the documentation we'll assume more +than a single stereo channel is wanted. + + +Capabilities +~~~~~~~~~~~~ + +Two methods are used by the module to indicate the level of capability +of the module: + +* split_streams_per_source() should return true when having multiple streams for one target is expected (e.g. Level 2 or 3) +* external_per_channel_volume() should return true when the streams have per-channel volume control that can be externally controlled (e.g. Level 3) + + +Hardware information and generations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The core runs on the assumption that the host hardware capabilities +can change at any time (bluetooth devices coming and going, usb +hot-plugging...) and that the module has some way to keep tabs on what +is happening, possibly using multi-threading. To keep it +lightweight-ish, we use the concept of a *generation* which is a +32-bits number that is incremented by the module every time something +changes. The core checks the current generation value at least once +every update (once per frame, usually) and if it changed asks for the +new state and detects and handles the differences. *generation* +should be "eventually stable", e.g. it eventually stops changing when +the user stops changing things all the time. A systematic increment +every frame would be a bad idea. + +.. code-block:: C++ + + virtual uint32_t get_generation() override; + +That method returns the current generation number. It's called at a +minimum once per update, which usually means per frame. It whould be +reasonably lightweight when nothing special happens. + +.. code-block: C++ + + virtual osd::audio_info get_information() override; + + struct audio_rate_range { + uint32_t m_default_rate; + uint32_t m_min_rate; + uint32_t m_max_rate; + }; + + struct audio_info { + struct node_info { + std::string m_name; + uint32_t m_id; + audio_rate_range m_rate; + std::vector<std::string> m_port_names; + std::vector<std::array<double, 3>> m_port_positions; + uint32_t m_sinks; + uint32_t m_sources; + }; + + struct stream_info { + uint32_t m_id; + uint32_t m_node; + std::vector<float> m_volumes; + }; + + uint32_t m_generation; + uint32_t m_default_sink; + uint32_t m_default_source; + std::vector<node_info> m_nodes; + std::vector<stream_info> m_streams; + }; + +This method must provide all the information about the current state +of the host and the module. This state is: + +* m_generation: The current generation number +* m_nodes: The vector available nodes (*node_info*) + + * m_name: The name of the node + * m_id: The numeric ID of the node + * m_rate: The minimum, maximum and preferred sample rate for the node + * m_port_names: The vector of port names + * m_port_positions: The vector of 3D position of the ports. Refer to src/emu/speaker.h for the "standard" positions + * m_sinks: Number of sinks (inputs) + * m_sources: Number of sources (outputs) + +* m_default_sink: ID of the node that is the current "system default" for audio output, 0 if there's no such concept +* m_default_source: same for audio input (currently unused) +* m_streams: The vector of active streams (*stream_info*) + + * m_id: The numeric ID of the stream + * m_node: The target node of the stream + * m_volumes: empty if *external_per_channel_volume* is false, current volume value per-channel otherwise + +IDs, for nodes and streams, are (independant) 32-bit unsigned non-zero +values associated to respectively nodes and streams. IDs should not +be reused. A node that goes away then comes back should get a new ID. +A stream closing does not allow reuse of its ID. + +If a node has both sources and sinks, the sources are *monitors* of +the sinks, e.g. they're loopbacks. They should have the same count in +such a case. + +When external control exists, a module should change the value of +*stream_info::m_node* when the user changes it, and same for +*stream_info::m_volumes*. Generation number should be incremented +when this happens, so that the core knows to look for changes. + +Volumes are floats in dB, where 0 means 100% and -96 means no sound. +audio.h provides osd::db_to_linear and osd::linear_to_db if such a +conversion is needed. + +There is an inherent race condition with this system, because things +can change at any point after returning for the method. The idea is +that the information returned must be internally consistent (a stream +should not point to a node ID that does not exist in the structure, +same for default sink) and that any external change from that state +should increment the generation number, but that's it. Through the +generation system the core will eventually be in sync with reality. + + +Input and output streams +~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + virtual uint32_t stream_sink_open(uint32_t node, std::string name, uint32_t rate) override; + virtual uint32_t stream_source_open(uint32_t node, std::string name, uint32_t rate) override; + virtual void stream_set_volumes(uint32_t id, const std::vector<float> &db) override; + virtual void stream_close(uint32_t id) override; + virtual void stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) override; + virtual void stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) override; + +Streams are the concept used to send or recieve audio from/to the host +audio system. A stream is first opened through *stream_sink_open* for +speakers and *stream_source_open* for microphones and targets a +specific node at a specific sample rate. It is given a name for use +by the host sound services for user UI purposes (currently the game +name if split_streams_per_source is false, the +speaker_device/microphone_device tag if true). The returned ID must +be a non-zero, never-used-before for streams value in case of success. +Failures, like when the node went away between the get_information +call and the open one, should be silent and return zero. + +*stream_set_volumes* is used only when *external_per_channel_volume* +is true and is used by the core to set the per-channel volume. The +call should just be ignored if the stream ID does not exist (or is +zero). Do not try to apply volumes in the module if the host API +doesn't provide for it, let the core handle it. + +*stream_close* closes a stream, The call should just be ignored if the +stream ID does not exist (or is zero). + +Opening a stream, closing a stream or changing the volume does not +need to touch the generation number. + +*stream_sink_update* is the method used to send data to the node +through a given stream. It provides a buffer of *samples_this_frame* +* *node channel count* channel-interleaved int16_t values. The +lifetime of the data in the buffer or the buffer pointer itself is +undefined after return from the method call. The call should just be +ignored if the stream ID does not exist (or is zero). + +*stream_source_update* is the equivalent to retrieve data from a node, +writing to the buffer instead of reading from it. The constraints are +identical. + +When a stream goes away because the target node is lost it should just +be removed from the information, and the core will pick up the node +departure and close the stream. + +Given the assumed raceness of the interface, all the methods should be +tolerant of obsolete or zero IDs being used by the core, and that is +why ID reuse must be avoided. Also the update methods and the +open/close/volume ones may be called at the same time in different +threads. + + +Helper class *abuffer* +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: C++ + + class abuffer { + public: + abuffer(uint32_t channels); + void get(int16_t *data, uint32_t samples); + void push(const int16_t *data, uint32_t samples); + uint32_t channels() const; + }; + +The class *abuffer* is a helper provided by *sound_module* to buffer +audio in output or output. It automatically drops data when there is +an overflow and duplicates the last sample on underflow. It must +first be initialized with the number of channels, which can be +retrieved with *channels()* if needed. *push* sends +*samples* * *channels* 16-bits samples in the buffer. *get* retrieves +*samples* * *channels* 16-bits samples from the buffer, on a fifo basis. + +It is not protected against multithreading, but uses no class +variables. So just don't read and write from one specific abuffer +instance at the same time. The system sound interface mandated +locking should be enough to ensure that. diff --git a/docs/source/usingmame/mamemenus.rst b/docs/source/usingmame/mamemenus.rst index ebade1e5188..52745b6ff77 100644 --- a/docs/source/usingmame/mamemenus.rst +++ b/docs/source/usingmame/mamemenus.rst @@ -110,6 +110,14 @@ Network Devices Shows the Network Devices menu, where you can set up emulated network adapters that support bridging to a host network. This item is not shown if there are no network adaptors that support bridging in the running system. +Audio Mixer + Shows the :ref:`Audio Mixer <menus-audiomixer>` menu, where you + decide how to connect your system audio inputs and outputs to the + emulated system's microphones and speakers. +Audio Effects + Shows the :ref:`Audio Effects <menus-audioeffects>` menu, which + allows to configure the audio effects applied between the emulated + system's speakers and the actual system audio outputs. Slider Controls Shows the Slider Controls menu, where you can adjust various settings, including video adjustments and individual sound channel levels. @@ -285,3 +293,101 @@ graphical form below the menu. Digital control states are either zero ID** to copy the device’s ID to the clipboard. This is useful for setting up :ref:`stable controller IDs <devicemap>` in :ref:`controller configuration files <ctrlrcfg>`. + + +.. _menus-audiomixer: + +Audio Mixer menu +---------------- + +The Audio Mixer menu allows to establish connections between emulated +speakers and microphones, and system audio inputs and outputs. It +uses the standard up/down arrows to select a device and/or current +mapping, left/right arrows to change a value (system audio port, +level, channel...) and [ ] to change column. In addition the (by +default) F key adds a full mapping, C a channel mapping, and Delete +clears a mapping. + +A full mapping sends all channels of a speaker to the appropriate(s) +channel(s) of the system output, and similarly retrieves all channels +of a microphone from the appropriate(s) input(s) of a system input. +For instance a mono speaker will send audio to both channels of a +stereo system output. + +A channel mapping maps between one channel of speaker or a microphone +and one channel of a system input or output. It can be a little +tedious, but it allows for instance to take two mono speakers and turn +it into the left and right channels of a system output, whcih is +useful for some cabinets. + +Every mapping has a configurable volume associated. + +The mapping configuration is saved in the system cfg file. + +Some OSes propose an external interface to change mappings and volumes +dynamically, for instance pipewire on linux. Mame does its best to +follow that and keep the information in the cfg file for future runs. + + +.. _menus-audioeffects: + +Audio Effects menu +------------------ + +This menu allows to configure the audio effects that are applied to +the speaker outputs between the speaker device and the audio mixer. +In other words, the output channels as seen in the audio mixer are the +outputs of the effect chains. Each speaker has an independant effect +chain applied. + +The chain itself is not configurable it is always in order: + +* Filter +* Compressor +* Reverb +* EQ + +The parameters of each are fully configurable though. A configured +parameter shows as white, a default as grey, and Clear allows to go +back to the default value. The default parameters for the chain of a +given speaker are the parameters of the Default chain, and the default +parameters of the Default chain are fixed. The default chain allows +to create a global setup that one likes and have it applied everywhere +by default. + +Filter effect +~~~~~~~~~~~~~ + +This effect proposes an order-2 high-pass and order-2 low-pass filter. +The high-pass filter allows to remove the DC offset some emulated +hardware has which can create saturation when not needed. The +low-pass filter (defaulting to off) allows to reproduce how muffled +the sound of a number of cabinets and TVs were. + +The Q factor defines how sharp the transition is, the higher the +sharper. Over 0.7 the filter starts amplifying the frequencies arount +the cutoff though, which can be surprising. + + +Compression effect +~~~~~~~~~~~~~~~~~~ + +Not implemented yet. + + +Reverb effect +~~~~~~~~~~~~~ + +Not implemented yet. + + +EQ effect +~~~~~~~~~ + +The 5-band parametric equalizer allows to amplify or reduce certains +bands of frequency in the spectrum. The three middle filters, and +also the extreme ones if configured as "Peak", change frequencies +around the cutoff. The Q factor selects the sharpness of the peak, +the higher the sharper. The extreme filters in "Shelf" mode move all +the frequencies under (or over) the cutoff frequency. + @@ -34,6 +34,7 @@ # NO_USE_MIDI = 1 # NO_USE_PORTAUDIO = 1 # NO_USE_PULSEAUDIO = 1 +# NO_USE_PIPEWIRE = 1 # USE_TAPTUN = 1 # USE_PCAP = 1 # USE_QTDEBUG = 1 @@ -781,6 +782,10 @@ ifdef NO_USE_PULSEAUDIO PARAMS += --NO_USE_PULSEAUDIO='$(NO_USE_PULSEAUDIO)' endif +ifdef NO_USE_PIPEWIRE +PARAMS += --NO_USE_PIPEWIRE='$(NO_USE_PIPEWIRE)' +endif + ifdef USE_QTDEBUG PARAMS += --USE_QTDEBUG='$(USE_QTDEBUG)' endif diff --git a/scripts/src/bus.lua b/scripts/src/bus.lua index 1ef192b9890..f1abcead795 100644 --- a/scripts/src/bus.lua +++ b/scripts/src/bus.lua @@ -5863,3 +5863,17 @@ if (BUSES["AMIGA_CPUSLOT"]~=null) then MAME_DIR .. "src/devices/bus/amiga/cpuslot/megamix500.h", } end + +--------------------------------------------------- +-- +--@src/devices/bus/st/stcart.h,BUSES["STCART_CONNECTOR"] = true +--------------------------------------------------- + +if (BUSES["STCART_CONNECTOR"]~=null) then + files { + MAME_DIR .. "src/devices/bus/st/stcart.cpp", + MAME_DIR .. "src/devices/bus/st/stcart.h", + MAME_DIR .. "src/devices/bus/st/replay.cpp", + MAME_DIR .. "src/devices/bus/st/replay.h", + } +end diff --git a/scripts/src/emu.lua b/scripts/src/emu.lua index 07ec7180412..b73d2cc61a6 100644 --- a/scripts/src/emu.lua +++ b/scripts/src/emu.lua @@ -194,6 +194,8 @@ files { MAME_DIR .. "src/emu/rendlay.h", MAME_DIR .. "src/emu/rendutil.cpp", MAME_DIR .. "src/emu/rendutil.h", + MAME_DIR .. "src/emu/resampler.cpp", + MAME_DIR .. "src/emu/resampler.h", MAME_DIR .. "src/emu/romload.cpp", MAME_DIR .. "src/emu/romload.h", MAME_DIR .. "src/emu/romentry.h", @@ -272,6 +274,16 @@ files { MAME_DIR .. "src/emu/video/rgbsse.h", MAME_DIR .. "src/emu/video/rgbvmx.cpp", MAME_DIR .. "src/emu/video/rgbvmx.h", + MAME_DIR .. "src/emu/audio_effects/aeffect.h", + MAME_DIR .. "src/emu/audio_effects/aeffect.cpp", + MAME_DIR .. "src/emu/audio_effects/filter.h", + MAME_DIR .. "src/emu/audio_effects/filter.cpp", + MAME_DIR .. "src/emu/audio_effects/compressor.h", + MAME_DIR .. "src/emu/audio_effects/compressor.cpp", + MAME_DIR .. "src/emu/audio_effects/reverb.h", + MAME_DIR .. "src/emu/audio_effects/reverb.cpp", + MAME_DIR .. "src/emu/audio_effects/eq.h", + MAME_DIR .. "src/emu/audio_effects/eq.cpp", } pchsource(MAME_DIR .. "src/emu/main.cpp") diff --git a/scripts/src/mame/frontend.lua b/scripts/src/mame/frontend.lua index 7e1653a10fa..749b46a3679 100644 --- a/scripts/src/mame/frontend.lua +++ b/scripts/src/mame/frontend.lua @@ -89,6 +89,14 @@ files { MAME_DIR .. "src/frontend/mame/ui/about.h", MAME_DIR .. "src/frontend/mame/ui/analogipt.cpp", MAME_DIR .. "src/frontend/mame/ui/analogipt.cpp", + MAME_DIR .. "src/frontend/mame/ui/audioeffects.cpp", + MAME_DIR .. "src/frontend/mame/ui/audioeffects.h", + MAME_DIR .. "src/frontend/mame/ui/audiomix.cpp", + MAME_DIR .. "src/frontend/mame/ui/audiomix.h", + MAME_DIR .. "src/frontend/mame/ui/audio_effect_eq.cpp", + MAME_DIR .. "src/frontend/mame/ui/audio_effect_eq.h", + MAME_DIR .. "src/frontend/mame/ui/audio_effect_filter.cpp", + MAME_DIR .. "src/frontend/mame/ui/audio_effect_filter.h", MAME_DIR .. "src/frontend/mame/ui/auditmenu.cpp", MAME_DIR .. "src/frontend/mame/ui/auditmenu.h", MAME_DIR .. "src/frontend/mame/ui/barcode.cpp", diff --git a/scripts/src/osd/modules.lua b/scripts/src/osd/modules.lua index 0dd3e561731..ccedfe070b0 100644 --- a/scripts/src/osd/modules.lua +++ b/scripts/src/osd/modules.lua @@ -54,6 +54,7 @@ function osdmodulesbuild() MAME_DIR .. "src/osd/osdnet.h", MAME_DIR .. "src/osd/watchdog.cpp", MAME_DIR .. "src/osd/watchdog.h", + MAME_DIR .. "src/osd/interface/audio.h", MAME_DIR .. "src/osd/interface/inputcode.h", MAME_DIR .. "src/osd/interface/inputdev.h", MAME_DIR .. "src/osd/interface/inputfwd.h", @@ -134,7 +135,9 @@ function osdmodulesbuild() MAME_DIR .. "src/osd/modules/sound/none.cpp", MAME_DIR .. "src/osd/modules/sound/pa_sound.cpp", MAME_DIR .. "src/osd/modules/sound/pulse_sound.cpp", + MAME_DIR .. "src/osd/modules/sound/pipewire_sound.cpp", MAME_DIR .. "src/osd/modules/sound/sdl_sound.cpp", + MAME_DIR .. "src/osd/modules/sound/sound_module.cpp", MAME_DIR .. "src/osd/modules/sound/sound_module.h", MAME_DIR .. "src/osd/modules/sound/xaudio2_sound.cpp", } @@ -302,6 +305,22 @@ function osdmodulesbuild() } end + err = os.execute(pkgconfigcmd() .. " --exists libpipewire-0.3") + if not err then + _OPTIONS["NO_USE_PIPEWIRE"] = "1" + end + + if _OPTIONS["NO_USE_PIPEWIRE"]=="1" then + defines { + "NO_USE_PIPEWIRE", + } + else + buildoptions { + backtick(pkgconfigcmd() .. " --cflags libpipewire-0.3"), + } + end + + if _OPTIONS["NO_USE_MIDI"]=="1" then defines { "NO_USE_MIDI", @@ -564,6 +583,12 @@ function osdmodulestargetconf() ext_lib("pulse"), } end + + if _OPTIONS["NO_USE_PIPEWIRE"]=="0" then + local str = backtick(pkgconfigcmd() .. " --libs libpipewire-0.3") + addlibfromstring(str) + addoptionsfromstring(str) + end end @@ -667,6 +692,23 @@ if not _OPTIONS["NO_USE_PULSEAUDIO"] then end newoption { + trigger = "NO_USE_PIPEWIRE", + description = "Disable Pipewire interface", + allowed = { + { "0", "Enable Pipewire" }, + { "1", "Disable Pipewire" }, + }, +} + +if not _OPTIONS["NO_USE_PIPEWIRE"] then + if _OPTIONS["targetos"]=="linux" then + _OPTIONS["NO_USE_PIPEWIRE"] = "0" + else + _OPTIONS["NO_USE_PIPEWIRE"] = "1" + end +end + +newoption { trigger = "MODERN_WIN_API", description = "Use Modern Windows APIs", allowed = { diff --git a/scripts/src/sound.lua b/scripts/src/sound.lua index 53d5d6b7925..32c0d366a60 100644 --- a/scripts/src/sound.lua +++ b/scripts/src/sound.lua @@ -1811,3 +1811,15 @@ if (SOUNDS["MMC5"]~=null) then MAME_DIR .. "src/devices/sound/mmc5.h", } end + +--------------------------------------------------- +-- ADCs +--@src/devices/sound/adc.h,SOUNDS["ADC"] = true +--------------------------------------------------- + +if (SOUNDS["ADC"]~=null) then + files { + MAME_DIR .. "src/devices/sound/adc.cpp", + MAME_DIR .. "src/devices/sound/adc.h", + } +end diff --git a/src/devices/bus/a2bus/a2mcms.cpp b/src/devices/bus/a2bus/a2mcms.cpp index 3455fa3d8fc..7ccf96376fa 100644 --- a/src/devices/bus/a2bus/a2mcms.cpp +++ b/src/devices/bus/a2bus/a2mcms.cpp @@ -249,19 +249,16 @@ TIMER_CALLBACK_MEMBER(mcms_device::clr_irq_tick) m_write_irq(CLEAR_LINE); } -void mcms_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mcms_device::sound_stream_update(sound_stream &stream) { int i, v; uint16_t wptr; int8_t sample; int32_t mixL, mixR; - auto &outL = outputs[1]; - auto &outR = outputs[0]; - if (m_enabled) { - for (i = 0; i < outL.samples(); i++) + for (i = 0; i < stream.samples(); i++) { mixL = mixR = 0; @@ -282,15 +279,10 @@ void mcms_device::sound_stream_update(sound_stream &stream, std::vector<read_str } } - outL.put_int(i, mixL * m_mastervol, 32768 << 9); - outR.put_int(i, mixR * m_mastervol, 32768 << 9); + stream.put_int(0, i, mixL * m_mastervol, 32768 << 9); + stream.put_int(1, i, mixR * m_mastervol, 32768 << 9); } } - else - { - outL.fill(0); - outR.fill(0); - } } void mcms_device::voiceregs_w(offs_t offset, uint8_t data) diff --git a/src/devices/bus/a2bus/a2mcms.h b/src/devices/bus/a2bus/a2mcms.h index e05ad64f18e..0f8cd2e72fb 100644 --- a/src/devices/bus/a2bus/a2mcms.h +++ b/src/devices/bus/a2bus/a2mcms.h @@ -41,7 +41,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(set_irq_tick); TIMER_CALLBACK_MEMBER(clr_irq_tick); diff --git a/src/devices/bus/a2bus/a2mockingboard.cpp b/src/devices/bus/a2bus/a2mockingboard.cpp index f002e129136..635ceb980f0 100644 --- a/src/devices/bus/a2bus/a2mockingboard.cpp +++ b/src/devices/bus/a2bus/a2mockingboard.cpp @@ -154,14 +154,13 @@ void a2bus_ayboard_device::single_via_devices(machine_config &config) m_via1->writepb_handler().set(FUNC(a2bus_ayboard_device::via1_out_b)); m_via1->irq_handler().set(FUNC(a2bus_ayboard_device::via1_irq_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8913(config, m_ay1, 1022727); - m_ay1->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_ay1->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); AY8913(config, m_ay2, 1022727); - m_ay2->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_ay2->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } void a2bus_ayboard_device::device_add_mconfig(machine_config &config) @@ -184,8 +183,8 @@ void a2bus_mockingboard_device::device_add_mconfig(machine_config &config) VOTRAX_SC01A(config, m_sc01, 1022727); m_sc01->ar_callback().set(m_via1, FUNC(via6522_device::write_cb1)); - m_sc01->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_sc01->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_sc01->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_sc01->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void a2bus_phasor_device::device_add_mconfig(machine_config &config) @@ -195,16 +194,15 @@ void a2bus_phasor_device::device_add_mconfig(machine_config &config) m_via1->writepb_handler().set(FUNC(a2bus_phasor_device::via1_out_b)); m_via2->writepb_handler().set(FUNC(a2bus_phasor_device::via2_out_b)); - SPEAKER(config, "lspeaker2").front_left(); - SPEAKER(config, "rspeaker2").front_right(); + SPEAKER(config, "speaker2").front(); - m_ay2->reset_routes().add_route(ALL_OUTPUTS, "lspeaker2", 0.5); + m_ay2->reset_routes().add_route(ALL_OUTPUTS, "speaker2", 0.5, 0); AY8913(config, m_ay3, 1022727); - m_ay3->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_ay3->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); AY8913(config, m_ay4, 1022727); - m_ay4->add_route(ALL_OUTPUTS, "rspeaker2", 0.5); + m_ay4->add_route(ALL_OUTPUTS, "speaker2", 0.5, 1); } void a2bus_echoplus_device::device_add_mconfig(machine_config &config) diff --git a/src/devices/bus/a2bus/a2scsi.cpp b/src/devices/bus/a2bus/a2scsi.cpp index cebfbd31565..53aff96effa 100644 --- a/src/devices/bus/a2bus/a2scsi.cpp +++ b/src/devices/bus/a2bus/a2scsi.cpp @@ -68,16 +68,15 @@ void a2bus_scsi_device::device_add_mconfig(machine_config &config) { // These machines were strictly external CD-ROMs so sound didn't route back into them; the AppleCD SC had // RCA jacks for connection to speakers/a stereo. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); NSCSI_BUS(config, m_scsibus); NSCSI_CONNECTOR(config, "scsibus:0", default_scsi_devices, nullptr, false); NSCSI_CONNECTOR(config, "scsibus:1").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsibus:2", default_scsi_devices, nullptr, false); NSCSI_CONNECTOR(config, "scsibus:3", default_scsi_devices, nullptr, false); diff --git a/src/devices/bus/amiga/cpuslot/a570.cpp b/src/devices/bus/amiga/cpuslot/a570.cpp index 4e134004580..abd42370380 100644 --- a/src/devices/bus/amiga/cpuslot/a570.cpp +++ b/src/devices/bus/amiga/cpuslot/a570.cpp @@ -120,8 +120,8 @@ void a570_device::device_add_mconfig(machine_config &config) m_tpi->out_pb_cb().set(FUNC(a570_device::tpi_portb_w)); CR511B(config, m_drive, 0); - m_drive->add_route(0, "lspeaker", 1.0); - m_drive->add_route(1, "rspeaker", 1.0); + m_drive->add_route(0, "speaker", 1.0, 0); + m_drive->add_route(1, "speaker", 1.0, 1); m_drive->scor_cb().set(m_tpi, FUNC(tpi6525_device::i1_w)).invert(); m_drive->stch_cb().set(m_tpi, FUNC(tpi6525_device::i2_w)).invert(); m_drive->sten_cb().set(m_tpi, FUNC(tpi6525_device::i3_w)); @@ -129,8 +129,7 @@ void a570_device::device_add_mconfig(machine_config &config) m_drive->drq_cb().set(m_tpi, FUNC(tpi6525_device::i4_w)); m_drive->drq_cb().append(FUNC(a570_device::drq_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: Add stereo input for Amiga sound } diff --git a/src/devices/bus/bbc/1mhzbus/m5000.cpp b/src/devices/bus/bbc/1mhzbus/m5000.cpp index ae3fd948969..758e3311491 100644 --- a/src/devices/bus/bbc/1mhzbus/m5000.cpp +++ b/src/devices/bus/bbc/1mhzbus/m5000.cpp @@ -63,12 +63,11 @@ DEFINE_DEVICE_TYPE(BBC_M87, bbc_m87_device, "bbc_m87", "Peartree Music 87 void bbc_m500_device::add_common_devices(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); HTMUSIC(config, m_hybrid, 12_MHz_XTAL / 2); - m_hybrid->add_route(0, "lspeaker", 1.0); - m_hybrid->add_route(1, "rspeaker", 1.0); + m_hybrid->add_route(0, "speaker", 1.0, 0); + m_hybrid->add_route(1, "speaker", 1.0, 1); BBC_1MHZBUS_SLOT(config, m_1mhzbus, DERIVED_CLOCK(1, 1), bbc_1mhzbus_devices, nullptr); m_1mhzbus->irq_handler().set(DEVICE_SELF_OWNER, FUNC(bbc_1mhzbus_slot_device::irq_w)); @@ -417,19 +416,15 @@ TIMER_CALLBACK_MEMBER(htmusic_device::dsp_tick) // sound_stream_update - handle a stream update //------------------------------------------------- -void htmusic_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void htmusic_device::sound_stream_update(sound_stream &stream) { - // reset the output streams - outputs[0].fill(0); - outputs[1].fill(0); - // iterate over channels and accumulate sample data for (int channel = 0; channel < 16; channel++) { - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - outputs[0].add_int(sampindex, m_sam_l[channel], 8031 * 16); - outputs[1].add_int(sampindex, m_sam_r[channel], 8031 * 16); + stream.add_int(0, sampindex, m_sam_l[channel], 8031 * 16); + stream.add_int(1, sampindex, m_sam_r[channel], 8031 * 16); } } } diff --git a/src/devices/bus/bbc/1mhzbus/m5000.h b/src/devices/bus/bbc/1mhzbus/m5000.h index 02b99fd12e3..44704a2b492 100644 --- a/src/devices/bus/bbc/1mhzbus/m5000.h +++ b/src/devices/bus/bbc/1mhzbus/m5000.h @@ -47,7 +47,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(dsp_tick); diff --git a/src/devices/bus/cbus/pc9801_118.cpp b/src/devices/bus/cbus/pc9801_118.cpp index c1326270ffc..7cd2477b0fe 100644 --- a/src/devices/bus/cbus/pc9801_118.cpp +++ b/src/devices/bus/cbus/pc9801_118.cpp @@ -52,8 +52,7 @@ void pc9801_118_device::device_add_mconfig(machine_config &config) // TODO: "ANCHOR" & "MAZE" custom NEC chips // sourced by 5D clock - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // actually YMF297-F (YMF288 + OPL3 compatible FM sources), unknown clock / divider // 5B is near both CS-4232 and this @@ -63,8 +62,8 @@ void pc9801_118_device::device_add_mconfig(machine_config &config) //m_opn3->port_b_read_callback().set(FUNC(pc8801_state::opn_portb_r)); //m_opn3->port_a_write_callback().set(FUNC(pc8801_state::opn_porta_w)); m_opn3->port_b_write_callback().set(FUNC(pc9801_118_device::opn_portb_w)); - m_opn3->add_route(ALL_OUTPUTS, "lspeaker", 1.00); - m_opn3->add_route(ALL_OUTPUTS, "rspeaker", 1.00); + m_opn3->add_route(ALL_OUTPUTS, "speaker", 1.00, 0); + m_opn3->add_route(ALL_OUTPUTS, "speaker", 1.00, 1); } diff --git a/src/devices/bus/cbus/pc9801_86.cpp b/src/devices/bus/cbus/pc9801_86.cpp index ffb595cba4b..eef4f353fa2 100644 --- a/src/devices/bus/cbus/pc9801_86.cpp +++ b/src/devices/bus/cbus/pc9801_86.cpp @@ -70,8 +70,7 @@ void pc9801_86_device::pc9801_86_config(machine_config &config) INPUT_MERGER_ANY_HIGH(config, m_irqs).output_handler().set([this](int state) { m_bus->int_w<5>(state); }); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2608(config, m_opna, 7.987_MHz_XTAL); // actually YM2608B // shouldn't have one // m_opna->set_addrmap(0, &pc9801_86_device::opna_map); @@ -80,13 +79,13 @@ void pc9801_86_device::pc9801_86_config(machine_config &config) //m_opna->port_b_read_callback().set(FUNC(pc8801_state::opn_portb_r)); //m_opna->port_a_write_callback().set(FUNC(pc8801_state::opn_porta_w)); m_opna->port_b_write_callback().set(FUNC(pc9801_86_device::opn_portb_w)); - m_opna->add_route(0, "lspeaker", 1.00); - m_opna->add_route(0, "rspeaker", 1.00); - m_opna->add_route(1, "lspeaker", 1.00); - m_opna->add_route(2, "rspeaker", 1.00); + m_opna->add_route(0, "speaker", 1.00, 0); + m_opna->add_route(0, "speaker", 1.00, 1); + m_opna->add_route(1, "speaker", 1.00, 0); + m_opna->add_route(2, "speaker", 1.00, 1); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // burr brown pcm61p - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // burr brown pcm61p + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // burr brown pcm61p + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // burr brown pcm61p } void pc9801_86_device::device_add_mconfig(machine_config &config) @@ -98,10 +97,10 @@ void pc9801_86_device::device_add_mconfig(machine_config &config) void pc9801_86_device::opna_reset_routes_config(machine_config &config) { m_opna->reset_routes(); - m_opna->add_route(0, "lspeaker", 0.50); - m_opna->add_route(0, "rspeaker", 0.50); - m_opna->add_route(1, "lspeaker", 0.50); - m_opna->add_route(2, "rspeaker", 0.50); + m_opna->add_route(0, "speaker", 0.50, 0); + m_opna->add_route(0, "speaker", 0.50, 1); + m_opna->add_route(1, "speaker", 0.50, 0); + m_opna->add_route(2, "speaker", 0.50, 1); } // to load a different bios for slots: @@ -527,10 +526,10 @@ void pc9801_speakboard_device::device_add_mconfig(machine_config &config) YM2608(config, m_opna_slave, 7.987_MHz_XTAL); m_opna_slave->set_addrmap(0, &pc9801_speakboard_device::opna_map); - m_opna_slave->add_route(0, "lspeaker", 0.50); - m_opna_slave->add_route(0, "rspeaker", 0.50); - m_opna_slave->add_route(1, "lspeaker", 0.50); - m_opna_slave->add_route(2, "rspeaker", 0.50); + m_opna_slave->add_route(0, "speaker", 0.50, 0); + m_opna_slave->add_route(0, "speaker", 0.50, 1); + m_opna_slave->add_route(1, "speaker", 0.50, 0); + m_opna_slave->add_route(2, "speaker", 0.50, 1); } void pc9801_speakboard_device::device_start() @@ -598,8 +597,8 @@ void otomichan_kai_device::device_add_mconfig(machine_config &config) m_opna->set_addrmap(0, &otomichan_kai_device::opna_map); YM3438(config, m_opn2c, 7.987_MHz_XTAL); - m_opn2c->add_route(0, "lspeaker", 0.50); - m_opn2c->add_route(1, "rspeaker", 0.50); + m_opn2c->add_route(0, "speaker", 0.50, 0); + m_opn2c->add_route(1, "speaker", 0.50, 1); } u8 otomichan_kai_device::id_r() diff --git a/src/devices/bus/cbus/sb16_ct2720.cpp b/src/devices/bus/cbus/sb16_ct2720.cpp index 3f77a83698c..cbe417c9960 100644 --- a/src/devices/bus/cbus/sb16_ct2720.cpp +++ b/src/devices/bus/cbus/sb16_ct2720.cpp @@ -39,15 +39,14 @@ sb16_ct2720_device::sb16_ct2720_device(const machine_config &mconfig, const char void sb16_ct2720_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); CT1745(config, m_mixer); m_mixer->set_fm_tag(m_opl3); m_mixer->set_ldac_tag(m_ldac); m_mixer->set_rdac_tag(m_rdac); - m_mixer->add_route(0, "lspeaker", 1.0); - m_mixer->add_route(1, "rspeaker", 1.0); + m_mixer->add_route(0, "speaker", 1.0, 0); + m_mixer->add_route(1, "speaker", 1.0, 1); m_mixer->irq_status_cb().set([this] () { (void)this; return 0; @@ -59,14 +58,14 @@ void sb16_ct2720_device::device_add_mconfig(machine_config &config) // MIDI_PORT(config, "mdin", midiin_slot, "midiin").rxd_handler().set(FUNC(sb_device::midi_rx_w)); // MIDI_PORT(config, "mdout", midiout_slot, "midiout"); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 1); // unknown DAC YMF262(config, m_opl3, XTAL(14'318'181)); - m_opl3->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_opl3->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_opl3->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_opl3->add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_opl3->add_route(0, m_mixer, 1.00, 0); + m_opl3->add_route(1, m_mixer, 1.00, 1); + m_opl3->add_route(2, m_mixer, 1.00, 0); + m_opl3->add_route(3, m_mixer, 1.00, 1); } void sb16_ct2720_device::device_start() diff --git a/src/devices/bus/centronics/covox.cpp b/src/devices/bus/centronics/covox.cpp index 4b3521b5955..9989308f593 100644 --- a/src/devices/bus/centronics/covox.cpp +++ b/src/devices/bus/centronics/covox.cpp @@ -92,10 +92,9 @@ centronics_covox_stereo_device::centronics_covox_stereo_device(const machine_con void centronics_covox_stereo_device::device_add_mconfig(machine_config &config) { /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } void centronics_covox_stereo_device::device_start() diff --git a/src/devices/bus/centronics/samdac.cpp b/src/devices/bus/centronics/samdac.cpp index 46a7682f4ba..90afc8e8a7c 100644 --- a/src/devices/bus/centronics/samdac.cpp +++ b/src/devices/bus/centronics/samdac.cpp @@ -23,11 +23,10 @@ DEFINE_DEVICE_TYPE(CENTRONICS_SAMDAC, centronics_samdac_device, "centronics_samd void centronics_samdac_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_8BIT_R2R(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); - DAC_8BIT_R2R(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); + DAC_8BIT_R2R(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + DAC_8BIT_R2R(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } diff --git a/src/devices/bus/coco/coco_orch90.cpp b/src/devices/bus/coco/coco_orch90.cpp index 83595798916..33151fb5d73 100644 --- a/src/devices/bus/coco/coco_orch90.cpp +++ b/src/devices/bus/coco/coco_orch90.cpp @@ -116,10 +116,9 @@ namespace void coco_orch90_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // ls374.ic5 + r7 (8x20k) + r9 (8x10k) - DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // ls374.ic4 + r6 (8x20k) + r8 (8x10k) + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // ls374.ic5 + r7 (8x20k) + r9 (8x10k) + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // ls374.ic4 + r6 (8x20k) + r8 (8x10k) } //------------------------------------------------- diff --git a/src/devices/bus/coco/coco_ssc.cpp b/src/devices/bus/coco/coco_ssc.cpp index 6f5ff8443a6..d6a0140d293 100644 --- a/src/devices/bus/coco/coco_ssc.cpp +++ b/src/devices/bus/coco/coco_ssc.cpp @@ -135,7 +135,7 @@ namespace virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // Power of 2 static constexpr int BUFFER_SIZE = 4; @@ -499,21 +499,18 @@ void cocossc_sac_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void cocossc_sac_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cocossc_sac_device::sound_stream_update(sound_stream &stream) { - auto &src = inputs[0]; - auto &dst = outputs[0]; - - int count = dst.samples(); + int count = stream.samples(); m_rms[m_index] = 0; if( count > 0 ) { for( int sampindex = 0; sampindex < count; sampindex++ ) { - auto source_sample = src.get(sampindex); + auto source_sample = stream.get(0, sampindex); m_rms[m_index] += source_sample * source_sample; - dst.put(sampindex, source_sample); + stream.put(0, sampindex, source_sample); } m_rms[m_index] = m_rms[m_index] / count; diff --git a/src/devices/bus/coco/coco_stecomp.cpp b/src/devices/bus/coco/coco_stecomp.cpp index 83477fd41fb..93b4b63908b 100644 --- a/src/devices/bus/coco/coco_stecomp.cpp +++ b/src/devices/bus/coco/coco_stecomp.cpp @@ -68,10 +68,9 @@ namespace void coco_stereo_composer_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "sc_lspeaker").front_left(); - SPEAKER(config, "sc_rspeaker").front_right(); - DAC_8BIT_R2R(config, m_ldac).add_route(ALL_OUTPUTS, "sc_lspeaker", 0.5); - DAC_8BIT_R2R(config, m_rdac).add_route(ALL_OUTPUTS, "sc_rspeaker", 0.5); + SPEAKER(config, "sc_speaker").front(); + DAC_8BIT_R2R(config, m_ldac).add_route(ALL_OUTPUTS, "sc_speaker", 0.5, 0); + DAC_8BIT_R2R(config, m_rdac).add_route(ALL_OUTPUTS, "sc_speaker", 0.5, 1); pia6821_device &pia(PIA6821(config, "sc_pia")); pia.writepa_handler().set("sc_ldac", FUNC(dac_byte_interface::data_w)); diff --git a/src/devices/bus/cpc/playcity.cpp b/src/devices/bus/cpc/playcity.cpp index c6abaeed14e..a2429242f43 100644 --- a/src/devices/bus/cpc/playcity.cpp +++ b/src/devices/bus/cpc/playcity.cpp @@ -31,12 +31,11 @@ void cpc_playcity_device::device_add_mconfig(machine_config &config) m_ctc->zc_callback<2>().set(m_ctc, FUNC(z80ctc_device::trg3)); m_ctc->intr_callback().set(FUNC(cpc_playcity_device::ctc_intr_cb)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ294(config, m_ymz1, DERIVED_CLOCK(1, 1)); // when timer is not set, operates at 4MHz (interally divided by 2, so equivalent to the ST) - m_ymz1->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_ymz1->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); YMZ294(config, m_ymz2, DERIVED_CLOCK(1, 1)); - m_ymz2->add_route(ALL_OUTPUTS, "lspeaker", 0.30); + m_ymz2->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); // pass-through cpc_expansion_slot_device &exp(CPC_EXPANSION_SLOT(config, "exp", DERIVED_CLOCK(1, 1), cpc_exp_cards, nullptr)); diff --git a/src/devices/bus/isa/gblaster.cpp b/src/devices/bus/isa/gblaster.cpp index 1cbd9458c04..3b6d66adb14 100644 --- a/src/devices/bus/isa/gblaster.cpp +++ b/src/devices/bus/isa/gblaster.cpp @@ -70,14 +70,13 @@ DEFINE_DEVICE_TYPE(ISA8_GAME_BLASTER, isa8_gblaster_device, "isa_gblaster", "Gam void isa8_gblaster_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAA1099(config, m_saa1099_1, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_1->add_route(0, "lspeaker", 0.50); - m_saa1099_1->add_route(1, "rspeaker", 0.50); + m_saa1099_1->add_route(0, "speaker", 0.50, 0); + m_saa1099_1->add_route(1, "speaker", 0.50, 1); SAA1099(config, m_saa1099_2, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_2->add_route(0, "lspeaker", 0.50); - m_saa1099_2->add_route(1, "rspeaker", 0.50); + m_saa1099_2->add_route(0, "speaker", 0.50, 0); + m_saa1099_2->add_route(1, "speaker", 0.50, 1); } //************************************************************************** diff --git a/src/devices/bus/isa/gus.cpp b/src/devices/bus/isa/gus.cpp index 2017482fc96..3d9fd1c073f 100644 --- a/src/devices/bus/isa/gus.cpp +++ b/src/devices/bus/isa/gus.cpp @@ -242,26 +242,19 @@ TIMER_CALLBACK_MEMBER(gf1_device::dma_tick) m_drq1_handler(1); } -void gf1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gf1_device::sound_stream_update(sound_stream &stream) { int x; - //uint32_t count; - - auto &outputl = outputs[0]; - auto &outputr = outputs[1]; - - outputl.fill(0); - outputr.fill(0); for(x=0;x<32;x++) // for each voice { uint16_t vol = (m_volume_table[(m_voice[x].current_vol & 0xfff0) >> 4]); - for (int sampindex = 0; sampindex < outputl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { uint32_t current = m_voice[x].current_addr >> 9; // TODO: implement proper panning - outputl.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192); - outputr.add_int(sampindex, m_voice[x].sample * vol, 32768 * 8192); + stream.add_int(0, sampindex, m_voice[x].sample * vol, 32768 * 8192); + stream.add_int(1, sampindex, m_voice[x].sample * vol, 32768 * 8192); if((!(m_voice[x].voice_ctrl & 0x40)) && (m_voice[x].current_addr >= m_voice[x].end_addr) && !m_voice[x].rollover && !(m_voice[x].voice_ctrl & 0x01)) { if(m_voice[x].vol_ramp_ctrl & 0x04) @@ -1238,11 +1231,10 @@ INPUT_PORTS_END void isa16_gus_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GGF1(config, m_gf1, GF1_CLOCK); - m_gf1->add_route(0, "lspeaker", 0.50); - m_gf1->add_route(1, "rspeaker", 0.50); + m_gf1->add_route(0, "speaker", 0.50, 0); + m_gf1->add_route(1, "speaker", 0.50, 1); m_gf1->txd_handler().set("mdout", FUNC(midi_port_device::write_txd)); m_gf1->txirq_handler().set(FUNC(isa16_gus_device::midi_txirq)); diff --git a/src/devices/bus/isa/gus.h b/src/devices/bus/isa/gus.h index cc86b2f088c..e58fea6c9fa 100644 --- a/src/devices/bus/isa/gus.h +++ b/src/devices/bus/isa/gus.h @@ -122,7 +122,7 @@ public: void eop_w(int state); // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; protected: // device-level overrides diff --git a/src/devices/bus/isa/sb16.cpp b/src/devices/bus/isa/sb16.cpp index 30d0a6f8950..b260edca7b9 100644 --- a/src/devices/bus/isa/sb16.cpp +++ b/src/devices/bus/isa/sb16.cpp @@ -434,27 +434,26 @@ void sb16_lle_device::device_add_mconfig(machine_config &config) m_cpu->port_in_cb<2>().set(FUNC(sb16_lle_device::p2_r)); m_cpu->port_out_cb<2>().set(FUNC(sb16_lle_device::p2_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); CT1745(config, m_mixer); m_mixer->set_fm_tag("ymf262"); m_mixer->set_ldac_tag(m_ldac); m_mixer->set_rdac_tag(m_rdac); - m_mixer->add_route(0, "lspeaker", 1.0); - m_mixer->add_route(1, "rspeaker", 1.0); + m_mixer->add_route(0, "speaker", 1.0, 0); + m_mixer->add_route(1, "speaker", 1.0, 1); m_mixer->irq_status_cb().set([this] () { return (m_irq8 << 0) | (m_irq16 << 1) | (m_irq_midi << 2) | (0x8 << 4); }); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, m_mixer, 0.5, 1); // unknown DAC ymf262_device &ymf262(YMF262(config, "ymf262", XTAL(14'318'181))); - ymf262.add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - ymf262.add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - ymf262.add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - ymf262.add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + ymf262.add_route(0, m_mixer, 1.00, 0); + ymf262.add_route(1, m_mixer, 1.00, 1); + ymf262.add_route(2, m_mixer, 1.00, 0); + ymf262.add_route(3, m_mixer, 1.00, 1); PC_JOY(config, m_joy); } diff --git a/src/devices/bus/isa/sblaster.cpp b/src/devices/bus/isa/sblaster.cpp index 0f73dc7ec9f..a17d808cebd 100644 --- a/src/devices/bus/isa/sblaster.cpp +++ b/src/devices/bus/isa/sblaster.cpp @@ -1152,11 +1152,10 @@ DEFINE_DEVICE_TYPE(ISA16_SOUND_BLASTER_16, isa16_sblaster16_device, "isa_sblaste void sb_device::common(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC PC_JOY(config, m_joy); @@ -1169,16 +1168,16 @@ void isa8_sblaster1_0_device::device_add_mconfig(machine_config &config) common(config); YM3812(config, m_ym3812, ym3812_StdClock); - m_ym3812->add_route(ALL_OUTPUTS, "lspeaker", 3.0); - m_ym3812->add_route(ALL_OUTPUTS, "rspeaker", 3.0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 3.0, 0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 3.0, 1); SAA1099(config, m_saa1099_1, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_1->add_route(0, "lspeaker", 0.5); - m_saa1099_1->add_route(1, "rspeaker", 0.5); + m_saa1099_1->add_route(0, "speaker", 0.5, 0); + m_saa1099_1->add_route(1, "speaker", 0.5, 1); SAA1099(config, m_saa1099_2, XTAL(14'318'181) / 2); // or CMS-301, from OSC pin in ISA bus - m_saa1099_2->add_route(0, "lspeaker", 0.5); - m_saa1099_2->add_route(1, "rspeaker", 0.5); + m_saa1099_2->add_route(0, "speaker", 0.5, 0); + m_saa1099_2->add_route(1, "speaker", 0.5, 1); } void isa8_sblaster1_5_device::device_add_mconfig(machine_config &config) @@ -1186,8 +1185,8 @@ void isa8_sblaster1_5_device::device_add_mconfig(machine_config &config) common(config); YM3812(config, m_ym3812, ym3812_StdClock); - m_ym3812->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_ym3812->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_ym3812->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); /* no CM/S support (empty sockets) */ } @@ -1196,10 +1195,10 @@ void isa16_sblaster16_device::device_add_mconfig(machine_config &config) common(config); ymf262_device &ymf262(YMF262(config, "ymf262", ymf262_StdClock)); - ymf262.add_route(0, "lspeaker", 1.0); - ymf262.add_route(1, "rspeaker", 1.0); - ymf262.add_route(2, "lspeaker", 1.0); - ymf262.add_route(3, "rspeaker", 1.0); + ymf262.add_route(0, "speaker", 1.0, 0); + ymf262.add_route(1, "speaker", 1.0, 1); + ymf262.add_route(2, "speaker", 1.0, 0); + ymf262.add_route(3, "speaker", 1.0, 1); } //************************************************************************** diff --git a/src/devices/bus/isa/stereo_fx.cpp b/src/devices/bus/isa/stereo_fx.cpp index 70f3c5160c7..bfd6eb6cfe5 100644 --- a/src/devices/bus/isa/stereo_fx.cpp +++ b/src/devices/bus/isa/stereo_fx.cpp @@ -124,15 +124,14 @@ void stereo_fx_device::device_add_mconfig(machine_config &config) m_cpu->port_in_cb<3>().set(FUNC(stereo_fx_device::p3_r)); m_cpu->port_out_cb<3>().set(FUNC(stereo_fx_device::p3_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3812_device &ym3812(YM3812(config, "ym3812", XTAL(3'579'545))); - ym3812.add_route(ALL_OUTPUTS, "lspeaker", 1.00); - ym3812.add_route(ALL_OUTPUTS, "rspeaker", 1.00); + ym3812.add_route(ALL_OUTPUTS, "speaker", 1.00, 0); + ym3812.add_route(ALL_OUTPUTS, "speaker", 1.00, 1); /* no CM/S support (empty sockets) */ - DAC_8BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_8BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC PC_JOY(config, m_joy); } diff --git a/src/devices/bus/msx/cart/moonsound.cpp b/src/devices/bus/msx/cart/moonsound.cpp index 2251e0ac788..ba03a17d4d3 100644 --- a/src/devices/bus/msx/cart/moonsound.cpp +++ b/src/devices/bus/msx/cart/moonsound.cpp @@ -57,18 +57,17 @@ void msx_cart_moonsound_device::ymf278b_map(address_map &map) void msx_cart_moonsound_device::device_add_mconfig(machine_config &config) { // The moonsound cartridge has a separate stereo output. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMF278B(config, m_ymf278b, 33.8688_MHz_XTAL); m_ymf278b->set_addrmap(0, &msx_cart_moonsound_device::ymf278b_map); m_ymf278b->irq_handler().set(FUNC(msx_cart_moonsound_device::irq_w)); - m_ymf278b->add_route(0, "lspeaker", 0.50); - m_ymf278b->add_route(1, "rspeaker", 0.50); - m_ymf278b->add_route(2, "lspeaker", 0.40); - m_ymf278b->add_route(3, "rspeaker", 0.40); - m_ymf278b->add_route(4, "lspeaker", 0.50); - m_ymf278b->add_route(5, "rspeaker", 0.50); + m_ymf278b->add_route(0, "speaker", 0.50, 0); + m_ymf278b->add_route(1, "speaker", 0.50, 1); + m_ymf278b->add_route(2, "speaker", 0.40, 0); + m_ymf278b->add_route(3, "speaker", 0.40, 1); + m_ymf278b->add_route(4, "speaker", 0.50, 0); + m_ymf278b->add_route(5, "speaker", 0.50, 1); } ROM_START(msx_cart_moonsound) diff --git a/src/devices/bus/msx/module/sfg.cpp b/src/devices/bus/msx/module/sfg.cpp index 34657e59738..a9ba98068a5 100644 --- a/src/devices/bus/msx/module/sfg.cpp +++ b/src/devices/bus/msx/module/sfg.cpp @@ -63,12 +63,11 @@ void msx_cart_sfg_device::device_add_mconfig(machine_config &config) // YM3012 (DAC) // YM2148 (MKS) - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ym2151(YM2151(config, m_ym2151, DERIVED_CLOCK(1, 1))); // The SFG01 uses a YM2151, the SFG05 uses a YM2164, input clock comes from the main cpu frequency ym2151.irq_handler().set(FUNC(msx_cart_sfg_device::ym2151_irq_w)); - ym2151.add_route(0, "lspeaker", 0.80); - ym2151.add_route(1, "rspeaker", 0.80); + ym2151.add_route(0, "speaker", 0.80, 0); + ym2151.add_route(1, "speaker", 0.80, 1); YM2148(config, m_ym2148, XTAL(4'000'000)); m_ym2148->txd_handler().set("mdout", FUNC(midi_port_device::write_txd)); @@ -186,8 +185,8 @@ void msx_cart_sfg05_device::device_add_mconfig(machine_config &config) ym2164_device &ym2164(YM2164(config.replace(), m_ym2151, DERIVED_CLOCK(1, 1))); ym2164.irq_handler().set(FUNC(msx_cart_sfg05_device::ym2151_irq_w)); - ym2164.add_route(0, "lspeaker", 0.80); - ym2164.add_route(1, "rspeaker", 0.80); + ym2164.add_route(0, "speaker", 0.80, 0); + ym2164.add_route(1, "speaker", 0.80, 1); } ROM_START(msx_sfg05) diff --git a/src/devices/bus/pc8801/gsx8800.cpp b/src/devices/bus/pc8801/gsx8800.cpp index 2e28c298136..df630cf83bf 100644 --- a/src/devices/bus/pc8801/gsx8800.cpp +++ b/src/devices/bus/pc8801/gsx8800.cpp @@ -44,10 +44,10 @@ void gsx8800_device::device_add_mconfig(machine_config &config) // it's just known that one goes to the left and the other to the right // cfr. http://mydocuments.g2.xrea.com/html/p8/soundinfo.html YM2149(config, m_psg[0], psg_x1_clock); - m_psg[0]->add_route(ALL_OUTPUTS, "^^lspeaker", 0.50); + m_psg[0]->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 0); YM2149(config, m_psg[1], psg_x1_clock); - m_psg[1]->add_route(ALL_OUTPUTS, "^^rspeaker", 0.50); + m_psg[1]->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 1); // ...->irq_handler().set(FUNC(gsx8800_device::int3_w)); diff --git a/src/devices/bus/pc8801/hmb20.cpp b/src/devices/bus/pc8801/hmb20.cpp index 82fd4081f48..6da14585d6e 100644 --- a/src/devices/bus/pc8801/hmb20.cpp +++ b/src/devices/bus/pc8801/hmb20.cpp @@ -37,6 +37,6 @@ void hmb20_device::device_add_mconfig(machine_config &config) // TODO: OPM mixing YM2151(config, m_opm, hmb20_x1_clock); // m_opm->irq_handler().set(FUNC(hmb20_device::int4_w)); - m_opm->add_route(ALL_OUTPUTS, "^^lspeaker", 0.50); - m_opm->add_route(ALL_OUTPUTS, "^^rspeaker", 0.50); + m_opm->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 0); + m_opm->add_route(ALL_OUTPUTS, "^^speaker", 0.50, 1); } diff --git a/src/devices/bus/pc8801/jmbx1.cpp b/src/devices/bus/pc8801/jmbx1.cpp index c868a7e2c7b..a5beb667a31 100644 --- a/src/devices/bus/pc8801/jmbx1.cpp +++ b/src/devices/bus/pc8801/jmbx1.cpp @@ -44,15 +44,15 @@ void jmbx1_device::device_add_mconfig(machine_config &config) // doesn't seem to have irq mask YM2151(config, m_opm1, jmb_x1_clock / 2); m_opm1->irq_handler().set(FUNC(jmbx1_device::int4_w)); - m_opm1->add_route(ALL_OUTPUTS, "^^lspeaker", 0.25); - m_opm1->add_route(ALL_OUTPUTS, "^^rspeaker", 0.25); + m_opm1->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 0); + m_opm1->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 1); YM2151(config, m_opm2, jmb_x1_clock / 2); - m_opm2->add_route(ALL_OUTPUTS, "^^lspeaker", 0.25); - m_opm2->add_route(ALL_OUTPUTS, "^^rspeaker", 0.25); + m_opm2->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 0); + m_opm2->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 1); YM2149(config, m_ssg, jmb_x1_clock / 4); // TODO: adds a non-negligible DC offset, likely needs high pass filter - m_ssg->add_route(ALL_OUTPUTS, "^^lspeaker", 0.20); - m_ssg->add_route(ALL_OUTPUTS, "^^rspeaker", 0.20); + m_ssg->add_route(ALL_OUTPUTS, "^^speaker", 0.20, 0); + m_ssg->add_route(ALL_OUTPUTS, "^^speaker", 0.20, 1); } diff --git a/src/devices/bus/pc8801/pc8801_23.cpp b/src/devices/bus/pc8801/pc8801_23.cpp index 507f4e49c7b..74cfdc9881d 100644 --- a/src/devices/bus/pc8801/pc8801_23.cpp +++ b/src/devices/bus/pc8801/pc8801_23.cpp @@ -50,10 +50,10 @@ void pc8801_23_device::device_add_mconfig(machine_config &config) // m_opna->port_a_read_callback().set(FUNC(pc8801_23_device::opn_porta_r)); // m_opna->port_b_read_callback().set_ioport("OPN_PB"); // TODO: per-channel mixing is unconfirmed - m_opna->add_route(0, "^^lspeaker", 0.25); - m_opna->add_route(0, "^^rspeaker", 0.25); - m_opna->add_route(1, "^^lspeaker", 0.75); - m_opna->add_route(2, "^^rspeaker", 0.75); + m_opna->add_route(0, "^^speaker", 0.25, 0); + m_opna->add_route(0, "^^speaker", 0.25, 1); + m_opna->add_route(1, "^^speaker", 0.75, 0); + m_opna->add_route(2, "^^speaker", 0.75, 1); } void pc8801_23_device::device_start() diff --git a/src/devices/bus/pc8801/pcg8100.cpp b/src/devices/bus/pc8801/pcg8100.cpp index c2bf07c7f73..f97c6a36d9f 100644 --- a/src/devices/bus/pc8801/pcg8100.cpp +++ b/src/devices/bus/pc8801/pcg8100.cpp @@ -46,8 +46,8 @@ void pcg8100_device::device_add_mconfig(machine_config &config) for (auto &dac1bit : m_dac1bit) { SPEAKER_SOUND(config, dac1bit); - dac1bit->add_route(ALL_OUTPUTS, "^^lspeaker", 0.25); - dac1bit->add_route(ALL_OUTPUTS, "^^rspeaker", 0.25); + dac1bit->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 0); + dac1bit->add_route(ALL_OUTPUTS, "^^speaker", 0.25, 1); } } diff --git a/src/devices/bus/pci/sonicvibes.cpp b/src/devices/bus/pci/sonicvibes.cpp index 6b1f0398824..e17a6abe582 100644 --- a/src/devices/bus/pci/sonicvibes.cpp +++ b/src/devices/bus/pci/sonicvibes.cpp @@ -62,18 +62,17 @@ sonicvibes_device::sonicvibes_device(const machine_config &mconfig, const char * void sonicvibes_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: (barely visible) only 24'576 xtal on a Turtle Beach PCB, is it really 12-ish MHz? YMF262(config, m_opl3, XTAL(14'318'181)); - m_opl3->add_route(0, "lspeaker", 1.0); - m_opl3->add_route(1, "rspeaker", 1.0); - m_opl3->add_route(2, "lspeaker", 1.0); - m_opl3->add_route(3, "rspeaker", 1.0); + m_opl3->add_route(0, "speaker", 1.0, 0); + m_opl3->add_route(1, "speaker", 1.0, 1); + m_opl3->add_route(2, "speaker", 1.0, 0); + m_opl3->add_route(3, "speaker", 1.0, 1); -// DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC -// DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC +// DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5); // unknown DAC +// DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5); // unknown DAC PC_JOY(config, m_joy); diff --git a/src/devices/bus/pci/sw1000xg.cpp b/src/devices/bus/pci/sw1000xg.cpp index 99255915915..6b91069db92 100644 --- a/src/devices/bus/pci/sw1000xg.cpp +++ b/src/devices/bus/pci/sw1000xg.cpp @@ -83,12 +83,11 @@ void sw1000xg_device::device_add_mconfig(machine_config &config) H83002(config, m_maincpu, 16_MHz_XTAL); m_maincpu->set_addrmap(AS_PROGRAM, &sw1000xg_device::h8_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP30(config, m_swp30); m_swp30->set_addrmap(AS_DATA, &sw1000xg_device::swp30_map); - m_swp30->add_route(0, "lspeaker", 1.0); - m_swp30->add_route(1, "rspeaker", 1.0); + m_swp30->add_route(0, "speaker", 1.0, 0); + m_swp30->add_route(1, "speaker", 1.0, 1); } diff --git a/src/devices/bus/plg1x0/plg100-vl.cpp b/src/devices/bus/plg1x0/plg100-vl.cpp index ae6f326c2bd..ee8a5050c14 100644 --- a/src/devices/bus/plg1x0/plg100-vl.cpp +++ b/src/devices/bus/plg1x0/plg100-vl.cpp @@ -67,8 +67,8 @@ void plg100_vl_device::device_add_mconfig(machine_config &config) m_cpu->write_sci_tx<1>().set([this] (int state) { m_connector->do_midi_tx(state); }); DSPV(config, m_dspv, 22.5792_MHz_XTAL); - m_dspv->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_dspv->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_dspv->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_dspv->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); } ROM_START( plg100_vl ) diff --git a/src/devices/bus/plg1x0/plg1x0.cpp b/src/devices/bus/plg1x0/plg1x0.cpp index 6abd5100209..939b4265e5d 100644 --- a/src/devices/bus/plg1x0/plg1x0.cpp +++ b/src/devices/bus/plg1x0/plg1x0.cpp @@ -12,7 +12,7 @@ DEFINE_DEVICE_TYPE(PLG1X0_CONNECTOR, plg1x0_connector, "plg1x0_connector", "PLG1 plg1x0_connector::plg1x0_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, PLG1X0_CONNECTOR, tag, owner, clock), device_single_card_slot_interface<device_plg1x0_interface>(mconfig, *this), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_midi_tx(*this) { } diff --git a/src/devices/bus/rc2014/sound.cpp b/src/devices/bus/rc2014/sound.cpp index acdb36e5442..3dafc5a7fb8 100644 --- a/src/devices/bus/rc2014/sound.cpp +++ b/src/devices/bus/rc2014/sound.cpp @@ -158,14 +158,13 @@ void rc2014_ym2149_device::device_reset() void rc2014_ym2149_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2149(config, m_psg, 0); - m_psg->add_route(0, "rspeaker", 0.25); - m_psg->add_route(2, "rspeaker", 0.25); - m_psg->add_route(1, "lspeaker", 0.25); - m_psg->add_route(2, "lspeaker", 0.25); + m_psg->add_route(0, "speaker", 0.25, 1); + m_psg->add_route(2, "speaker", 0.25, 1); + m_psg->add_route(1, "speaker", 0.25, 0); + m_psg->add_route(2, "speaker", 0.25, 0); } //************************************************************************** @@ -190,14 +189,13 @@ rc2014_ay8190_device::rc2014_ay8190_device(const machine_config &mconfig, const void rc2014_ay8190_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8910(config, m_psg, 0); - m_psg->add_route(0, "rspeaker", 0.25); - m_psg->add_route(2, "rspeaker", 0.25); - m_psg->add_route(1, "lspeaker", 0.25); - m_psg->add_route(2, "lspeaker", 0.25); + m_psg->add_route(0, "speaker", 0.25, 1); + m_psg->add_route(2, "speaker", 0.25, 1); + m_psg->add_route(1, "speaker", 0.25, 0); + m_psg->add_route(2, "speaker", 0.25, 0); } } diff --git a/src/devices/bus/rs232/mboardd.cpp b/src/devices/bus/rs232/mboardd.cpp index 002f868c40a..1ec2bdc8c9b 100644 --- a/src/devices/bus/rs232/mboardd.cpp +++ b/src/devices/bus/rs232/mboardd.cpp @@ -78,12 +78,11 @@ void mockingboard_d_device::device_add_mconfig(machine_config &config) m_cpu->out_p1_cb().set(FUNC(mockingboard_d_device::p1_w)); m_cpu->out_ser_tx_cb().set(FUNC(mockingboard_d_device::ser_tx_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8913(config, m_ay1, 1022727); - m_ay1->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_ay1->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); AY8913(config, m_ay2, 1022727); - m_ay2->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_ay2->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); } const tiny_rom_entry *mockingboard_d_device::device_rom_region() const diff --git a/src/devices/bus/segaai/soundbox.cpp b/src/devices/bus/segaai/soundbox.cpp index 3496f1ac479..230275da343 100644 --- a/src/devices/bus/segaai/soundbox.cpp +++ b/src/devices/bus/segaai/soundbox.cpp @@ -142,12 +142,11 @@ void segaai_soundbox_device::device_add_mconfig(machine_config &config) m_tmp8255->out_pb_callback().set(FUNC(segaai_soundbox_device::tmp8255_portb_w)); m_tmp8255->out_pc_callback().set(FUNC(segaai_soundbox_device::tmp8255_portc_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, DERIVED_CLOCK(1,1)); // ~3.58MHz m_ym2151->irq_handler().set(FUNC(segaai_soundbox_device::ym2151_irq_w)); - m_ym2151->add_route(0, "lspeaker", 1.00); - m_ym2151->add_route(1, "rspeaker", 1.00); + m_ym2151->add_route(0, "speaker", 1.00, 0); + m_ym2151->add_route(1, "speaker", 1.00, 1); } ROM_START(soundbox) diff --git a/src/devices/bus/spectrum/neogs.cpp b/src/devices/bus/spectrum/neogs.cpp index 156c2e2895c..2848523a328 100644 --- a/src/devices/bus/spectrum/neogs.cpp +++ b/src/devices/bus/spectrum/neogs.cpp @@ -426,11 +426,10 @@ void neogs_device::device_add_mconfig(machine_config &config) m_sdcard->set_prefer_sdhc(); m_sdcard->spi_miso_callback().set([this](int state) { m_spi_data_in_latch <<= 1; m_spi_data_in_latch |= state; }); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.75); // TDA1543 - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.75); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 0); // TDA1543 + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } const tiny_rom_entry *neogs_device::device_rom_region() const diff --git a/src/devices/bus/st/replay.cpp b/src/devices/bus/st/replay.cpp new file mode 100644 index 00000000000..f7df23a2dcc --- /dev/null +++ b/src/devices/bus/st/replay.cpp @@ -0,0 +1,108 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// Microdeal ST Replay + +// A 8-bit mono DAC and a 8-bit mono ADC on a cartridge, with a vague +// lowpass filter. + +// A peculiarity of the ST cartridge port is that it's readonly. So +// writing to the DAC is done by reading at an appropriate address. + +#include "emu.h" +#include "replay.h" + +#include "sound/adc.h" +#include "sound/dac.h" +#include "speaker.h" + +namespace { + +class st_replay_device : public device_t, public device_stcart_interface +{ +public: + st_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + virtual ~st_replay_device(); + + virtual void map(address_space_installer &space) override; + +protected: + virtual void device_start() override ATTR_COLD; + virtual void device_reset() override ATTR_COLD; + virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; + +private: + required_device<zn449_device> m_adc; + required_device<zn429e_device> m_dac; + required_device<microphone_device> m_mic; + required_device<speaker_device> m_speaker; + + void cartmap(address_map &map) ATTR_COLD; + + u16 dac_w(offs_t data); + u8 adc_r(); +}; + +st_replay_device::st_replay_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, ST_REPLAY, tag, owner, clock), + device_stcart_interface(mconfig, *this), + m_adc(*this, "adc"), + m_dac(*this, "dac"), + m_mic(*this, "mic"), + m_speaker(*this, "speaker") +{ +} + +st_replay_device::~st_replay_device() +{ +} + +u16 st_replay_device::dac_w(offs_t data) +{ + m_dac->write(data); + return 0xffff; +} + +u8 st_replay_device::adc_r() +{ + double tm = machine().time().as_double(); + s8 level = 127 * sin(tm*440*2*M_PI); + return level + 0x80; +} + +void st_replay_device::map(address_space_installer &space) +{ + space.install_device(0xfa0000, 0xfbffff, *this, &st_replay_device::cartmap); +} + +void st_replay_device::cartmap(address_map &map) +{ + map(0x00000, 0x001ff).r(FUNC(st_replay_device::dac_w)).mirror(0xfe00); + map(0x10001, 0x10001).r(m_adc, FUNC(zn449_device::read)).mirror(0xfffe); +} + +void st_replay_device::device_add_mconfig(machine_config &config) +{ + MICROPHONE(config, m_mic, 1).front_center(); + m_mic->add_route(0, m_adc, 1.0, 0); + + ZN449(config, m_adc); + + // ZN429D the schematics say, not sure if any significant difference + ZN429E(config, m_dac); + m_dac->add_route(0, m_speaker, 1.0, 0); + + SPEAKER(config, m_speaker, 1).front_center(); +} + +void st_replay_device::device_start() +{ +} + +void st_replay_device::device_reset() +{ +} + +} // anonymous namespace + +DEFINE_DEVICE_TYPE_PRIVATE(ST_REPLAY, device_stcart_interface, st_replay_device, "st_replay", "Microdeal ST Replay") diff --git a/src/devices/bus/st/replay.h b/src/devices/bus/st/replay.h new file mode 100644 index 00000000000..b6e2c73a062 --- /dev/null +++ b/src/devices/bus/st/replay.h @@ -0,0 +1,15 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#ifndef MAME_BUS_ST_REPLAY_H +#define MAME_BUS_ST_REPLAY_H + +// Microdeal ST Replay + +#pragma once + +#include "stcart.h" + +DECLARE_DEVICE_TYPE(ST_REPLAY, device_stcart_interface) + +#endif // MAME_BUS_ST_REPLAY_H diff --git a/src/devices/bus/st/stcart.cpp b/src/devices/bus/st/stcart.cpp new file mode 100644 index 00000000000..0e53093bf92 --- /dev/null +++ b/src/devices/bus/st/stcart.cpp @@ -0,0 +1,40 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "stcart.h" + +#include "replay.h" + +DEFINE_DEVICE_TYPE(STCART_CONNECTOR, stcart_connector, "stcart_connector", "Atari ST cartridge connector") + +stcart_connector::stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, STCART_CONNECTOR, tag, owner, clock), + device_single_card_slot_interface<device_stcart_interface>(mconfig, *this) +{ +} + +void stcart_connector::device_start() +{ +} + +void stcart_connector::map(address_space_installer &space) +{ + auto card = get_card_device(); + if(card) + card->map(space); +} + +void stcart_intf(device_slot_interface &device) +{ + device.option_add("replay", ST_REPLAY); +} + +device_stcart_interface::device_stcart_interface(const machine_config &mconfig, device_t &device) : + device_interface(device, "stcart") +{ +} + +device_stcart_interface::~device_stcart_interface() +{ +} diff --git a/src/devices/bus/st/stcart.h b/src/devices/bus/st/stcart.h new file mode 100644 index 00000000000..49ccb78a2e6 --- /dev/null +++ b/src/devices/bus/st/stcart.h @@ -0,0 +1,50 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Atari ST cartridges + +#ifndef MAME_BUS_ST_STCART_H +#define MAME_BUS_ST_STCART_H + +#pragma once + +class device_stcart_interface; + +class stcart_connector: public device_t, public device_single_card_slot_interface<device_stcart_interface> +{ +public: + template <typename T> + stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt) + : stcart_connector(mconfig, tag, owner, (uint32_t)0) + { + option_reset(); + opts(*this); + set_default_option(dflt); + set_fixed(false); + } + + stcart_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); + + void map(address_space_installer &space); + +protected: + virtual void device_start() override ATTR_COLD; +}; + +class device_stcart_interface: public device_interface +{ +public: + device_stcart_interface(const machine_config &mconfig, device_t &device); + virtual ~device_stcart_interface(); + + virtual void map(address_space_installer &space) = 0; + +protected: + +}; + +DECLARE_DEVICE_TYPE(STCART_CONNECTOR, stcart_connector) + +void stcart_intf(device_slot_interface &device); + +#endif // MAME_BUS_ST_STCART_H diff --git a/src/devices/bus/waveblaster/db50xg.cpp b/src/devices/bus/waveblaster/db50xg.cpp index 6d3c0f067d5..c105227dce5 100644 --- a/src/devices/bus/waveblaster/db50xg.cpp +++ b/src/devices/bus/waveblaster/db50xg.cpp @@ -71,8 +71,8 @@ void db50xg_device::device_add_mconfig(machine_config &config) m_cpu->write_sci_tx<0>().set([this] (int state) { m_connector->do_midi_tx(state); }); SWP00(config, m_swp00); - m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); } ROM_START( db50xg ) diff --git a/src/devices/bus/waveblaster/db60xg.cpp b/src/devices/bus/waveblaster/db60xg.cpp index 4f8ede66612..c194d5d0e6e 100644 --- a/src/devices/bus/waveblaster/db60xg.cpp +++ b/src/devices/bus/waveblaster/db60xg.cpp @@ -69,8 +69,8 @@ void db60xg_device::device_add_mconfig(machine_config &config) m_cpu->write_sci_tx<0>().set([this] (int state) { m_connector->do_midi_tx(state); }); SWP00(config, m_swp00); - m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_swp00->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_swp00->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); } ROM_START( db60xg ) diff --git a/src/devices/bus/waveblaster/omniwave.cpp b/src/devices/bus/waveblaster/omniwave.cpp index 54d5731029f..a83399c28f9 100644 --- a/src/devices/bus/waveblaster/omniwave.cpp +++ b/src/devices/bus/waveblaster/omniwave.cpp @@ -47,8 +47,8 @@ void omniwave_device::midi_rx(int state) void omniwave_device::device_add_mconfig(machine_config &config) { KS0164(config, m_ks0164, 16.9344_MHz_XTAL); - m_ks0164->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_ks0164->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_ks0164->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_ks0164->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); m_ks0164->midi_tx().set([this] (int state) { m_connector->do_midi_tx(state); }); } diff --git a/src/devices/bus/waveblaster/waveblaster.cpp b/src/devices/bus/waveblaster/waveblaster.cpp index c280a2fd083..fc019ff62e1 100644 --- a/src/devices/bus/waveblaster/waveblaster.cpp +++ b/src/devices/bus/waveblaster/waveblaster.cpp @@ -15,7 +15,7 @@ DEFINE_DEVICE_TYPE(WAVEBLASTER_CONNECTOR, waveblaster_connector, "waveblaster_co waveblaster_connector::waveblaster_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, WAVEBLASTER_CONNECTOR, tag, owner, clock), device_single_card_slot_interface<device_waveblaster_interface>(mconfig, *this), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_midi_tx(*this) { } diff --git a/src/devices/bus/waveblaster/wg130.cpp b/src/devices/bus/waveblaster/wg130.cpp index 32aeae3c8a3..8c44347c2b7 100644 --- a/src/devices/bus/waveblaster/wg130.cpp +++ b/src/devices/bus/waveblaster/wg130.cpp @@ -77,8 +77,8 @@ void wg130_device::device_add_mconfig(machine_config &config) { GT913(config, m_gt913, 30_MHz_XTAL / 2); m_gt913->set_addrmap(AS_DATA, &wg130_device::map); - m_gt913->add_route(0, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 0); - m_gt913->add_route(1, DEVICE_SELF_OWNER, 1.0, AUTO_ALLOC_INPUT, 1); + m_gt913->add_route(0, DEVICE_SELF_OWNER, 1.0, 0); + m_gt913->add_route(1, DEVICE_SELF_OWNER, 1.0, 1); m_gt913->read_port1().set_constant(0xff); m_gt913->write_port1().set_nop(); m_gt913->read_port2().set_constant(0xff); diff --git a/src/devices/cpu/h6280/h6280.cpp b/src/devices/cpu/h6280/h6280.cpp index f725e6065a5..1261de78a78 100644 --- a/src/devices/cpu/h6280/h6280.cpp +++ b/src/devices/cpu/h6280/h6280.cpp @@ -169,7 +169,7 @@ DEFINE_DEVICE_TYPE(H6280, h6280_device, "h6280", "Hudson Soft HuC6280") h6280_device::h6280_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cpu_device(mconfig, H6280, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_program_config("program", ENDIANNESS_LITTLE, 8, 21, 0, 16, 0, address_map_constructor(FUNC(h6280_device::internal_map), this)) , m_io_config("io", ENDIANNESS_LITTLE, 8, 2) , m_port_in_cb(*this, 0) @@ -232,8 +232,8 @@ const h6280_device::ophandler h6280_device::s_opcodetable[256] = void h6280_device::device_add_mconfig(machine_config &config) { C6280(config, m_psg, DERIVED_CLOCK(1,2)); - m_psg->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_psg->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_psg->add_route(0, *this, 1.0, 0); + m_psg->add_route(1, *this, 1.0, 1); } void h6280_device::device_start() diff --git a/src/devices/cpu/h8/gt913.cpp b/src/devices/cpu/h8/gt913.cpp index 8201ac9d66d..620f82173a4 100644 --- a/src/devices/cpu/h8/gt913.cpp +++ b/src/devices/cpu/h8/gt913.cpp @@ -28,7 +28,7 @@ DEFINE_DEVICE_TYPE(GT913, gt913_device, "gt913", "Casio GT913F") gt913_device::gt913_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : h8_device(mconfig, GT913, tag, owner, clock, address_map_constructor(FUNC(gt913_device::map), this)), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_rom(*this, DEVICE_SELF), m_data_config("data", ENDIANNESS_BIG, 16, 22, 0), m_write_ple(*this), @@ -102,8 +102,8 @@ void gt913_device::device_add_mconfig(machine_config &config) GT913_SOUND(config, m_sound, DERIVED_CLOCK(1, 1)); m_sound->set_device_rom_tag(m_rom); - m_sound->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_sound->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_sound->add_route(0, *this, 1.0, 0); + m_sound->add_route(1, *this, 1.0, 1); GT913_KBD_HLE(config, m_kbd, 0); m_kbd->irq_cb().set([this] (int val) { diff --git a/src/devices/cpu/h8/swx00.cpp b/src/devices/cpu/h8/swx00.cpp index 12ff74e9bbf..f626a8303ae 100644 --- a/src/devices/cpu/h8/swx00.cpp +++ b/src/devices/cpu/h8/swx00.cpp @@ -7,7 +7,7 @@ DEFINE_DEVICE_TYPE(SWX00, swx00_device, "swx00", "Yamaha SWX00") swx00_device::swx00_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock, u8 mode) : h8s2000_device(mconfig, SWX00, tag, owner, clock, address_map_constructor(FUNC(swx00_device::map), this)), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_intc(*this, "intc"), m_adc(*this, "adc"), m_dma(*this, "dma"), @@ -316,8 +316,8 @@ void swx00_device::device_add_mconfig(machine_config &config) SWX00_SOUND(config, m_swx00); m_swx00->set_space(DEVICE_SELF, AS_S); - m_swx00->add_route(0, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 0); - m_swx00->add_route(1, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 1); + m_swx00->add_route(0, DEVICE_SELF, 1.0, 0); + m_swx00->add_route(1, DEVICE_SELF, 1.0, 1); } device_memory_interface::space_config_vector swx00_device::memory_space_config() const diff --git a/src/devices/cpu/m6502/gew12.cpp b/src/devices/cpu/m6502/gew12.cpp index 2459bb13517..4d77abc7771 100644 --- a/src/devices/cpu/m6502/gew12.cpp +++ b/src/devices/cpu/m6502/gew12.cpp @@ -20,7 +20,7 @@ DEFINE_DEVICE_TYPE(GEW12, gew12_device, "gew12", "Yamaha YMW728-F (GEW12)") gew12_device::gew12_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : m6502_mcu_device_base<w65c02_device>(mconfig, GEW12, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_in_cb(*this, 0xff), m_out_cb(*this) , m_rom(*this, DEVICE_SELF) , m_bank(*this, "bank%u", 0U) diff --git a/src/devices/cpu/m6502/gew7.cpp b/src/devices/cpu/m6502/gew7.cpp index 2594a2166ef..76e1378d9e8 100644 --- a/src/devices/cpu/m6502/gew7.cpp +++ b/src/devices/cpu/m6502/gew7.cpp @@ -20,7 +20,7 @@ DEFINE_DEVICE_TYPE(GEW7, gew7_device, "gew7", "Yamaha YMW270-F (GEW7)") gew7_device::gew7_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : m6502_mcu_device_base<w65c02_device>(mconfig, GEW7, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_in_cb(*this, 0xff), m_out_cb(*this) , m_rom(*this, DEVICE_SELF) , m_bank(*this, "bank%u", 0U) @@ -37,8 +37,8 @@ void gew7_device::device_add_mconfig(machine_config &config) { GEW7_PCM(config, m_pcm, DERIVED_CLOCK(1, 1)); m_pcm->set_device_rom_tag(m_rom); - m_pcm->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_pcm->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_pcm->add_route(0, *this, 1.0, 0); + m_pcm->add_route(1, *this, 1.0, 1); } void gew7_device::device_start() diff --git a/src/devices/cpu/m6502/rp2a03.cpp b/src/devices/cpu/m6502/rp2a03.cpp index 0d9153b42f7..4132e780d5a 100644 --- a/src/devices/cpu/m6502/rp2a03.cpp +++ b/src/devices/cpu/m6502/rp2a03.cpp @@ -45,7 +45,7 @@ rp2a03_core_device::rp2a03_core_device(const machine_config &mconfig, const char rp2a03_device::rp2a03_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : rp2a03_core_device(mconfig, type, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 1) + , device_mixer_interface(mconfig, *this) , m_apu(*this, "nesapu") { program_config.m_internal_map = address_map_constructor(FUNC(rp2a03_device::rp2a03_map), this); @@ -84,7 +84,7 @@ void rp2a03_device::device_add_mconfig(machine_config &config) APU_2A03(config, m_apu, DERIVED_CLOCK(1,1)); m_apu->irq().set(FUNC(rp2a03_device::apu_irq)); m_apu->mem_read().set(FUNC(rp2a03_device::apu_read_mem)); - m_apu->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_apu->add_route(ALL_OUTPUTS, *this, 1.0, 0); } void rp2a03g_device::device_add_mconfig(machine_config &config) @@ -92,7 +92,7 @@ void rp2a03g_device::device_add_mconfig(machine_config &config) NES_APU(config, m_apu, DERIVED_CLOCK(1,1)); m_apu->irq().set(FUNC(rp2a03g_device::apu_irq)); m_apu->mem_read().set(FUNC(rp2a03g_device::apu_read_mem)); - m_apu->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_apu->add_route(ALL_OUTPUTS, *this, 1.0, 0); } diff --git a/src/devices/cpu/m6502/st2205u.cpp b/src/devices/cpu/m6502/st2205u.cpp index 8e63a20fab4..cf7639b9aca 100644 --- a/src/devices/cpu/m6502/st2205u.cpp +++ b/src/devices/cpu/m6502/st2205u.cpp @@ -101,25 +101,19 @@ st2302u_device::st2302u_device(const machine_config &mconfig, const char *tag, d { } -void st2205u_base_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void st2205u_base_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - outputs[1].fill(0); - outputs[2].fill(0); - outputs[3].fill(0); - - int samples = outputs[0].samples(); + int samples = stream.samples(); int outpos = 0; while (samples-- != 0) { for (int channel = 0; channel < 4; channel++) { s16 adpcm_contribution = m_adpcm_level[channel]; - outputs[channel].add_int(outpos, adpcm_contribution * 0x10, 32768); + stream.add_int(channel, outpos, adpcm_contribution * 0x10, 32768); auto psg_contribution = std::sin((double)m_psg_freqcntr[channel]/4096.0f); - outputs[channel].add_int(outpos, psg_contribution * m_psg_amplitude[channel]*0x80,32768); + stream.add_int(channel, outpos, psg_contribution * m_psg_amplitude[channel]*0x80,32768); } outpos++; diff --git a/src/devices/cpu/m6502/st2205u.h b/src/devices/cpu/m6502/st2205u.h index 17cc7f18740..cad10f08b3b 100644 --- a/src/devices/cpu/m6502/st2205u.h +++ b/src/devices/cpu/m6502/st2205u.h @@ -64,7 +64,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual unsigned st2xxx_bt_divider(int n) const override; virtual u8 st2xxx_prs_mask() const override { return 0xc0; } diff --git a/src/devices/cpu/tms57002/tms57002.cpp b/src/devices/cpu/tms57002/tms57002.cpp index 593a74e3263..3485ba25695 100644 --- a/src/devices/cpu/tms57002/tms57002.cpp +++ b/src/devices/cpu/tms57002/tms57002.cpp @@ -920,21 +920,20 @@ void tms57002_device::execute_run() icount = 0; } -void tms57002_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms57002_device::sound_stream_update(sound_stream &stream) { - assert(inputs[0].samples() == 1); - assert(outputs[0].samples() == 1); - - stream_buffer::sample_t in_scale = 32767.0 * ((st0 & ST0_SIM) ? 256.0 : 1.0); - si[0] = s32(inputs[0].get(0) * in_scale) & 0xffffff; - si[1] = s32(inputs[1].get(0) * in_scale) & 0xffffff; - si[2] = s32(inputs[2].get(0) * in_scale) & 0xffffff; - si[3] = s32(inputs[3].get(0) * in_scale) & 0xffffff; - - outputs[0].put_int(0, s32(so[0] << 8) >> 1, 32768 * 32768); - outputs[1].put_int(0, s32(so[1] << 8) >> 1, 32768 * 32768); - outputs[2].put_int(0, s32(so[2] << 8) >> 1, 32768 * 32768); - outputs[3].put_int(0, s32(so[3] << 8) >> 1, 32768 * 32768); + assert(stream.samples() == 1); + + sound_stream::sample_t in_scale = 32768.0 * ((st0 & ST0_SIM) ? 256.0 : 1.0); + si[0] = s32(stream.get(0, 0) * in_scale) & 0xffffff; + si[1] = s32(stream.get(1, 0) * in_scale) & 0xffffff; + si[2] = s32(stream.get(2, 0) * in_scale) & 0xffffff; + si[3] = s32(stream.get(3, 0) * in_scale) & 0xffffff; + + stream.put(0, 0, s32(so[0] << 8) / 2147483648.0); + stream.put(1, 0, s32(so[1] << 8) / 2147483648.0); + stream.put(2, 0, s32(so[2] << 8) / 2147483648.0); + stream.put(3, 0, s32(so[3] << 8) / 2147483648.0); sync_w(1); } diff --git a/src/devices/cpu/tms57002/tms57002.h b/src/devices/cpu/tms57002/tms57002.h index 7a6dce18416..547afff6d08 100644 --- a/src/devices/cpu/tms57002/tms57002.h +++ b/src/devices/cpu/tms57002/tms57002.h @@ -36,7 +36,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual space_config_vector memory_space_config() const override; virtual u32 execute_min_cycles() const noexcept override; virtual u32 execute_max_cycles() const noexcept override; diff --git a/src/devices/cpu/upd177x/upd177x.cpp b/src/devices/cpu/upd177x/upd177x.cpp index b5cd302312f..f8e9590f873 100644 --- a/src/devices/cpu/upd177x/upd177x.cpp +++ b/src/devices/cpu/upd177x/upd177x.cpp @@ -782,13 +782,11 @@ void upd177x_cpu_device::execute_run() } -void upd177x_cpu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd177x_cpu_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - const int smpl = m_dac_sign ? -m_dac : m_dac; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put_int(sampindex, smpl, 256); + stream.put_int(0, sampindex, smpl, 256); } } diff --git a/src/devices/cpu/upd177x/upd177x.h b/src/devices/cpu/upd177x/upd177x.h index 70a186acc55..0dcb245a446 100644 --- a/src/devices/cpu/upd177x/upd177x.h +++ b/src/devices/cpu/upd177x/upd177x.h @@ -57,7 +57,7 @@ protected: virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void program_map(address_map &map) ATTR_COLD; diff --git a/src/devices/imagedev/cassette.cpp b/src/devices/imagedev/cassette.cpp index 21cb7e8bd10..5c5d1ea560c 100644 --- a/src/devices/imagedev/cassette.cpp +++ b/src/devices/imagedev/cassette.cpp @@ -448,33 +448,29 @@ std::string cassette_image_device::call_display() // Cassette sound //------------------------------------------------- -void cassette_image_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cassette_image_device::sound_stream_update(sound_stream &stream) { cassette_state state = get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER); if (exists() && (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))) { + int samples = stream.samples(); cassette_image *cassette = get_image(); double time_index = get_position(); - double duration = ((double) outputs[0].samples()) / outputs[0].sample_rate(); + double duration = ((double) samples) / stream.sample_rate(); - if (m_samples.size() < outputs[0].samples()) - m_samples.resize(outputs[0].samples()); + if (m_samples.size() < samples) + m_samples.resize(samples); const cassette_image::Info info = cassette->get_info(); - for (int ch = 0; ch < outputs.size(); ch++) + for (int ch = 0; ch < stream.output_count(); ch++) { if (ch < info.channels) - cassette->get_samples(ch, time_index, duration, outputs[0].samples(), 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); + cassette->get_samples(ch, time_index, duration, samples, 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); else - cassette->get_samples(0, time_index, duration, outputs[0].samples(), 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); - for (int sampindex = 0; sampindex < outputs[ch].samples(); sampindex++) - outputs[ch].put_int(sampindex, m_samples[sampindex], 32768); + cassette->get_samples(0, time_index, duration, samples, 2, &m_samples[0], cassette_image::WAVEFORM_16BIT); + for (int sampindex = 0; sampindex < samples; sampindex++) + stream.put_int(ch, sampindex, m_samples[sampindex], 32768); } } - else - { - for (int ch = 0; ch < outputs.size(); ch++) - outputs[ch].fill(0); - } } diff --git a/src/devices/imagedev/cassette.h b/src/devices/imagedev/cassette.h index 60bd0357324..d73e248590e 100644 --- a/src/devices/imagedev/cassette.h +++ b/src/devices/imagedev/cassette.h @@ -103,7 +103,7 @@ public: void seek(double time, int origin); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; device_sound_interface& set_stereo() { m_stereo = true; return *this; } protected: diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp index 8dd70d5fd62..b6f3e2b69b5 100644 --- a/src/devices/imagedev/floppy.cpp +++ b/src/devices/imagedev/floppy.cpp @@ -1595,18 +1595,17 @@ void floppy_sound_device::step(int zone) // sound_stream_update - update the sound stream //------------------------------------------------- -void floppy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void floppy_sound_device::sound_stream_update(sound_stream &stream) { // We are using only one stream, unlike the parent class // Also, there is no need for interpolation, as we only expect // one sample rate of 44100 for all samples int16_t out; - auto &samplebuffer = outputs[0]; int m_idx = 0; int sampleend = 0; - for (int sampindex = 0; sampindex < samplebuffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { out = 0; @@ -1700,7 +1699,7 @@ void floppy_sound_device::sound_stream_update(sound_stream &stream, std::vector< } // Write to the stream buffer - samplebuffer.put_int(sampindex, out, 32768); + stream.put_int(0, sampindex, out, 32768); } } diff --git a/src/devices/imagedev/floppy.h b/src/devices/imagedev/floppy.h index 8e03f9438a7..2e7b0de3b50 100644 --- a/src/devices/imagedev/floppy.h +++ b/src/devices/imagedev/floppy.h @@ -413,7 +413,7 @@ protected: private: // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; sound_stream* m_sound; int m_step_base; diff --git a/src/devices/machine/acorn_vidc.cpp b/src/devices/machine/acorn_vidc.cpp index cd428e3fc01..daeb50d8ea3 100644 --- a/src/devices/machine/acorn_vidc.cpp +++ b/src/devices/machine/acorn_vidc.cpp @@ -65,8 +65,7 @@ acorn_vidc10_device::acorn_vidc10_device(const machine_config &mconfig, device_t , m_sound_mode(false) , m_dac(*this, "dac%u", 0) , m_dac_type(dac_type) - , m_lspeaker(*this, "lspeaker") - , m_rspeaker(*this, "rspeaker") + , m_speaker(*this, "speaker") , m_vblank_cb(*this) , m_sound_drq_cb(*this) , m_pixel_clock(0) @@ -110,12 +109,11 @@ device_memory_interface::space_config_vector acorn_vidc10_device::memory_space_c void acorn_vidc10_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); for (int i = 0; i < m_sound_max_channels; i++) { // custom DAC - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[i], 0).add_route(0, m_lspeaker, m_sound_input_gain).add_route(0, m_rspeaker, m_sound_input_gain); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac[i], 0).add_route(0, m_speaker, m_sound_input_gain, 0).add_route(0, m_speaker, m_sound_input_gain, 1); } } @@ -405,9 +403,8 @@ inline void acorn_vidc10_device::refresh_stereo_image(u8 channel) const float left_gain[8] = { 1.0f, 2.0f, 1.66f, 1.34f, 1.0f, 0.66f, 0.34f, 0.0f }; const float right_gain[8] = { 1.0f, 0.0f, 0.34f, 0.66f, 1.0f, 1.34f, 1.66f, 2.0f }; - m_lspeaker->set_input_gain(channel, left_gain[m_stereo_image[channel]] * m_sound_input_gain); - m_rspeaker->set_input_gain(channel, right_gain[m_stereo_image[channel]] * m_sound_input_gain); - //printf("%d %f %f\n",channel,m_lspeaker->input(channel).gain(),m_rspeaker->input(channel).gain()); + m_speaker->set_input_gain(0, left_gain[m_stereo_image[channel]] * m_sound_input_gain); + m_speaker->set_input_gain(1, right_gain[m_stereo_image[channel]] * m_sound_input_gain); } @@ -582,14 +579,14 @@ void arm_vidc20_device::device_add_mconfig(machine_config &config) for (int i = 0; i < m_sound_max_channels; i++) { m_dac[i]->reset_routes(); - m_dac[i]->add_route(0, m_lspeaker, 0.0); - m_dac[i]->add_route(0, m_rspeaker, 0.0); + m_dac[i]->add_route(0, m_speaker, 0.0, 0); + m_dac[i]->add_route(0, m_speaker, 0.0, 1); } // For simplicity we separate DACs for 32-bit mode // TODO: how stereo image copes with this if at all? - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[0], 0).add_route(ALL_OUTPUTS, m_lspeaker, 0.25); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[1], 0).add_route(ALL_OUTPUTS, m_rspeaker, 0.25); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[0], 0).add_route(ALL_OUTPUTS, m_speaker, 0.25, 0); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_dac32[1], 0).add_route(ALL_OUTPUTS, m_speaker, 0.25, 1); } void arm_vidc20_device::device_config_complete() diff --git a/src/devices/machine/acorn_vidc.h b/src/devices/machine/acorn_vidc.h index 23f8564f94a..49b5c0dca54 100644 --- a/src/devices/machine/acorn_vidc.h +++ b/src/devices/machine/acorn_vidc.h @@ -90,8 +90,7 @@ protected: required_device_array<dac_16bit_r2r_twos_complement_device, 8> m_dac; int m_dac_type; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<speaker_device> m_speaker; virtual void refresh_stereo_image(u8 channel); const int m_sound_max_channels = 8; diff --git a/src/devices/machine/cr511b.cpp b/src/devices/machine/cr511b.cpp index dc3fa967ba5..7f52ced1e20 100644 --- a/src/devices/machine/cr511b.cpp +++ b/src/devices/machine/cr511b.cpp @@ -45,7 +45,7 @@ DEFINE_DEVICE_TYPE(CR511B, cr511b_device, "cr511b", "CR-511-B CD-ROM drive") cr511b_device::cr511b_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : cdrom_image_device(mconfig, CR511B, tag, owner, clock), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_cdda(*this, "cdda"), m_stch_cb(*this), m_sten_cb(*this), @@ -72,8 +72,8 @@ cr511b_device::cr511b_device(const machine_config &mconfig, const char *tag, dev void cr511b_device::device_add_mconfig(machine_config &config) { CDDA(config, m_cdda); - m_cdda->add_route(0, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 0); - m_cdda->add_route(1, DEVICE_SELF, 1.0, AUTO_ALLOC_INPUT, 1); + m_cdda->add_route(0, DEVICE_SELF, 1.0, 0); + m_cdda->add_route(1, DEVICE_SELF, 1.0, 1); m_cdda->set_cdrom_tag(*this); m_cdda->audio_end_cb().set(FUNC(cr511b_device::audio_end_cb)); } diff --git a/src/devices/machine/generalplus_gpl16250soc.cpp b/src/devices/machine/generalplus_gpl16250soc.cpp index dc4505ce9ff..ec915385d99 100644 --- a/src/devices/machine/generalplus_gpl16250soc.cpp +++ b/src/devices/machine/generalplus_gpl16250soc.cpp @@ -27,7 +27,7 @@ DEFINE_DEVICE_TYPE(GCM394, sunplus_gcm394_device, "gcm394", "GeneralPlus GPL1625 sunplus_gcm394_base_device::sunplus_gcm394_base_device(const machine_config& mconfig, device_type type, const char* tag, device_t* owner, uint32_t clock, address_map_constructor internal) : unsp_20_device(mconfig, type, tag, owner, clock, internal), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_screen(*this, finder_base::DUMMY_TAG), m_spg_video(*this, "spgvideo"), m_spg_audio(*this, "spgaudio"), @@ -1845,8 +1845,8 @@ void sunplus_gcm394_base_device::device_add_mconfig(machine_config &config) m_spg_audio->write_irq_callback().set(FUNC(sunplus_gcm394_base_device::audioirq_w)); m_spg_audio->space_read_callback().set(FUNC(sunplus_gcm394_base_device::read_space)); - m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_spg_audio->add_route(0, *this, 1.0, 0); + m_spg_audio->add_route(1, *this, 1.0, 1); GCM394_VIDEO(config, m_spg_video, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); m_spg_video->write_video_irq_callback().set(FUNC(sunplus_gcm394_base_device::videoirq_w)); diff --git a/src/devices/machine/gt913_snd.cpp b/src/devices/machine/gt913_snd.cpp index 803e6443278..1965b798432 100644 --- a/src/devices/machine/gt913_snd.cpp +++ b/src/devices/machine/gt913_snd.cpp @@ -102,9 +102,9 @@ void gt913_sound_device::device_reset() std::memset(m_voices, 0, sizeof(m_voices)); } -void gt913_sound_device::sound_stream_update(sound_stream& stream, std::vector<read_stream_view> const& inputs, std::vector<write_stream_view>& outputs) +void gt913_sound_device::sound_stream_update(sound_stream& stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s64 left = 0, right = 0; @@ -115,8 +115,8 @@ void gt913_sound_device::sound_stream_update(sound_stream& stream, std::vector<r mix_sample(voice, left, right); } - outputs[0].put_int_clamp(i, (left * m_gain) >> 27, 32678); - outputs[1].put_int_clamp(i, (right * m_gain) >> 27, 32768); + stream.put_int_clamp(0, i, (left * m_gain) >> 27, 32678); + stream.put_int_clamp(1, i, (right * m_gain) >> 27, 32768); } } diff --git a/src/devices/machine/gt913_snd.h b/src/devices/machine/gt913_snd.h index 790eca81196..ba05cabe470 100644 --- a/src/devices/machine/gt913_snd.h +++ b/src/devices/machine/gt913_snd.h @@ -38,7 +38,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/machine/k054321.cpp b/src/devices/machine/k054321.cpp index 6a362f655b2..d53fd8d346f 100644 --- a/src/devices/machine/k054321.cpp +++ b/src/devices/machine/k054321.cpp @@ -59,8 +59,7 @@ void k054321_device::sound_map(address_map &map) k054321_device::k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, K054321, tag, owner, clock), - m_left(*this, finder_base::DUMMY_TAG), - m_right(*this, finder_base::DUMMY_TAG), + m_speaker(*this, finder_base::DUMMY_TAG), m_soundlatch(*this, "soundlatch%u", 0) { } @@ -68,17 +67,12 @@ k054321_device::k054321_device(const machine_config &mconfig, const char *tag, d void k054321_device::device_start() { // make sure that device_sound_interface is configured - if (!m_left->inputs() && !m_right->inputs()) + if (!m_speaker->inputs()) throw device_missing_dependencies(); // remember initial input gains - m_left_gains = std::make_unique<float[]>(m_left->inputs()); - m_right_gains = std::make_unique<float[]>(m_right->inputs()); - - for (int i = 0; i < m_left->inputs(); i++) - m_left_gains[i] = m_left->input_gain(i); - for (int i = 0; i < m_right->inputs(); i++) - m_right_gains[i] = m_right->input_gain(i); + m_left_gain = m_speaker->input_gain(0); + m_right_gain = m_speaker->input_gain(1); // register for savestates save_item(NAME(m_volume)); @@ -133,8 +127,6 @@ void k054321_device::propagate_volume() { double vol = pow(2, (m_volume - 40)/10.0); - for (int i = 0; i < m_left->inputs(); i++) - m_left->set_input_gain(i, m_active & 2 ? vol * m_left_gains[i] : 0.0); - for (int i = 0; i < m_right->inputs(); i++) - m_right->set_input_gain(i, m_active & 1 ? vol * m_right_gains[i] : 0.0); + m_speaker->set_input_gain(0, m_active & 2 ? vol * m_left_gain : 0.0); + m_speaker->set_input_gain(1, m_active & 1 ? vol * m_right_gain : 0.0); } diff --git a/src/devices/machine/k054321.h b/src/devices/machine/k054321.h index 9fba2f93c18..3d4739bf1a1 100644 --- a/src/devices/machine/k054321.h +++ b/src/devices/machine/k054321.h @@ -11,16 +11,15 @@ class k054321_device : public device_t { public: - template<typename T, typename U> - k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&left, U &&right) : - k054321_device(mconfig, tag, owner, 0) + k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + + template<typename T> + k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, T &&speaker) : + k054321_device(mconfig, tag, owner) { - m_left.set_tag(std::forward<T>(left)); - m_right.set_tag(std::forward<U>(right)); + m_speaker.set_tag(std::forward<T>(speaker)); } - k054321_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); - void main_map(address_map &map) ATTR_COLD; void sound_map(address_map &map) ATTR_COLD; @@ -30,12 +29,10 @@ protected: virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; private: - required_device<device_sound_interface> m_left; - required_device<device_sound_interface> m_right; + required_device<device_sound_interface> m_speaker; required_device_array<generic_latch_8_device, 3> m_soundlatch; - std::unique_ptr<float[]> m_left_gains; - std::unique_ptr<float[]> m_right_gains; + float m_left_gain, m_right_gain; u8 m_volume; u8 m_active; diff --git a/src/devices/machine/laserdsc.cpp b/src/devices/machine/laserdsc.cpp index e1033518cb5..dc9fd2f5064 100644 --- a/src/devices/machine/laserdsc.cpp +++ b/src/devices/machine/laserdsc.cpp @@ -392,7 +392,7 @@ TIMER_CALLBACK_MEMBER(laserdisc_device::fetch_vbi_data) // laserdiscs //------------------------------------------------- -void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void laserdisc_device::sound_stream_update(sound_stream &stream) { // compute AND values based on the squelch int16_t leftand = (m_audiosquelch & 1) ? 0x0000 : 0xffff; @@ -403,17 +403,7 @@ void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<rea if (samples_avail < 0) samples_avail += m_audiobufsize; - // if no attached ld, just clear the buffers - auto &dst0 = outputs[0]; - auto &dst1 = outputs[1]; - if (samples_avail < outputs[0].samples()) - { - dst0.fill(0); - dst1.fill(0); - } - - // otherwise, stream from our buffer - else + if (samples_avail >= stream.samples()) { int16_t *buffer0 = &m_audiobuffer[0][0]; int16_t *buffer1 = &m_audiobuffer[1][0]; @@ -421,10 +411,10 @@ void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<rea // copy samples, clearing behind us as we go int sampindex; - for (sampindex = 0; sampout != m_audiobufin && sampindex < outputs[0].samples(); sampindex++) + for (sampindex = 0; sampout != m_audiobufin && sampindex < stream.samples(); sampindex++) { - dst0.put_int(sampindex, buffer0[sampout] & leftand, 32768); - dst1.put_int(sampindex, buffer1[sampout] & rightand, 32768); + stream.put_int(0, sampindex, buffer0[sampout] & leftand, 32768); + stream.put_int(1, sampindex, buffer1[sampout] & rightand, 32768); buffer0[sampout] = 0; buffer1[sampout] = 0; sampout++; @@ -434,16 +424,16 @@ void laserdisc_device::sound_stream_update(sound_stream &stream, std::vector<rea m_audiobufout = sampout; // clear out the rest of the buffer - if (sampindex < outputs[0].samples()) + if (sampindex < stream.samples()) { sampout = (m_audiobufout == 0) ? m_audiobufsize - 1 : m_audiobufout - 1; s32 fill0 = buffer0[sampout] & leftand; s32 fill1 = buffer1[sampout] & rightand; - for ( ; sampindex < outputs[0].samples(); sampindex++) + for ( ; sampindex < stream.samples(); sampindex++) { - dst0.put_int(sampindex, fill0, 32768); - dst1.put_int(sampindex, fill1, 32768); + stream.put_int(0, sampindex, fill0, 32768); + stream.put_int(1, sampindex, fill1, 32768); } } } diff --git a/src/devices/machine/laserdsc.h b/src/devices/machine/laserdsc.h index 04e980ae64e..f84cd47a06a 100644 --- a/src/devices/machine/laserdsc.h +++ b/src/devices/machine/laserdsc.h @@ -213,7 +213,7 @@ protected: virtual void device_validity_check(validity_checker &valid) const override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual TIMER_CALLBACK_MEMBER(fetch_vbi_data); diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp index bba035194f3..c9d91704cce 100644 --- a/src/devices/machine/netlist.cpp +++ b/src/devices/machine/netlist.cpp @@ -813,16 +813,16 @@ void netlist_mame_stream_output_device::device_reset() LOGDEVCALLS("reset %s\n", name()); } -void netlist_mame_stream_output_device::sound_update_fill(write_stream_view &target) +void netlist_mame_stream_output_device::sound_update_fill(sound_stream &stream, int output) { - if (target.samples() < m_buffer.size()) - osd_printf_warning("sound %s: samples %d less bufsize %d\n", name(), target.samples(), m_buffer.size()); + if (stream.samples() < m_buffer.size()) + osd_printf_warning("sound %s: samples %d less bufsize %d\n", name(), stream.samples(), m_buffer.size()); int sampindex; for (sampindex = 0; sampindex < m_buffer.size(); sampindex++) - target.put(sampindex, m_buffer[sampindex]); - if (sampindex < target.samples()) - target.fill(m_cur, sampindex); + stream.put(output, sampindex, m_buffer[sampindex]); + if (sampindex < stream.samples()) + stream.fill(output, m_cur, sampindex); } @@ -860,7 +860,7 @@ void netlist_mame_stream_output_device::process(netlist::netlist_time_ext tim, n // throw emu_fatalerror("sound %s: pos %d exceeded bufsize %d\n", name().c_str(), pos, m_bufsize); while (m_buffer.size() < pos ) { - m_buffer.push_back(static_cast<stream_buffer::sample_t>(m_cur)); + m_buffer.push_back(static_cast<sound_stream::sample_t>(m_cur)); } m_cur = val; @@ -1396,7 +1396,7 @@ void netlist_mame_sound_device::device_start() m_inbuffer.resize(m_in.size()); /* initialize the stream(s) */ - m_stream = stream_alloc(m_in.size(), m_out.size(), m_sound_clock, STREAM_DISABLE_INPUT_RESAMPLING); + m_stream = stream_alloc(m_in.size(), m_out.size(), m_sound_clock); LOGDEVCALLS("sound device_start exit\n"); } @@ -1439,23 +1439,23 @@ void netlist_mame_sound_device::update_to_current_time() LOGTIMING("%s : %f us before machine time\n", this->name(), (cur - mtime).as_double() * 1000000.0); } -void netlist_mame_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void netlist_mame_sound_device::sound_stream_update(sound_stream &stream) { for (auto &e : m_in) { - auto clock_period = inputs[e.first].sample_period(); + auto clock_period = stream.sample_period(); auto sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(clock_period).as_raw())); - m_inbuffer[e.first] = netlist_mame_sound_input_buffer(inputs[e.first]); - e.second->buffer_reset(sample_time, m_inbuffer[e.first].samples(), &m_inbuffer[e.first]); + m_inbuffer[e.first] = netlist_mame_sound_input_buffer(stream, e.first); + e.second->buffer_reset(sample_time, stream.samples(), &m_inbuffer[e.first]); } - int samples = outputs[0].samples(); + int samples = stream.samples(); LOGDEBUG("samples %d\n", samples); // end_time() is the time at the END of the last sample we're generating // however, the sample value is the value at the START of that last sample, // so subtract one sample period so that we only process up to the minimum - auto nl_target_time = nltime_from_attotime(outputs[0].end_time() - outputs[0].sample_period()); + auto nl_target_time = nltime_from_attotime(stream.end_time() - stream.sample_period()); auto nltime(netlist().exec().time()); if (nltime < nl_target_time) @@ -1465,7 +1465,7 @@ void netlist_mame_sound_device::sound_stream_update(sound_stream &stream, std::v for (auto &e : m_out) { - e.second->sound_update_fill(outputs[e.first]); + e.second->sound_update_fill(stream, e.first); e.second->buffer_reset(nl_target_time); } diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h index 51f5bdeb09f..67b6b7d143c 100644 --- a/src/devices/machine/netlist.h +++ b/src/devices/machine/netlist.h @@ -249,19 +249,20 @@ private: // ---------------------------------------------------------------------------------------- // netlist_mame_sound_input_buffer // -// This is a wrapper device to provide operator[] on read_stream_view. +// This is a wrapper device to provide operator[] on an input stream. // ---------------------------------------------------------------------------------------- -class netlist_mame_sound_input_buffer : public read_stream_view +class netlist_mame_sound_input_buffer { public: - netlist_mame_sound_input_buffer() : - read_stream_view() { } + sound_stream *m_stream = nullptr; + int m_stream_input = 0; - netlist_mame_sound_input_buffer(read_stream_view const &src) : - read_stream_view(src) { } + netlist_mame_sound_input_buffer() {} - stream_buffer::sample_t operator[](std::size_t index) { return get(index); } + netlist_mame_sound_input_buffer(sound_stream &stream, int input) : m_stream(&stream), m_stream_input(input) { } + + sound_stream::sample_t operator[](std::size_t index) { return m_stream->get(m_stream_input, index); } }; // ---------------------------------------------------------------------------------------- @@ -302,7 +303,7 @@ protected: // device_t overrides virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_validity_check(validity_checker &valid) const override; //virtual void device_reset() override ATTR_COLD; @@ -634,7 +635,7 @@ public: m_buffer.clear(); } - void sound_update_fill(write_stream_view &target); + void sound_update_fill(sound_stream &stream, int output); void set_sample_time(netlist::netlist_time t) { m_sample_time = t; } @@ -649,7 +650,7 @@ private: uint32_t m_channel; const char * m_out_name; - std::vector<stream_buffer::sample_t> m_buffer; + std::vector<sound_stream::sample_t> m_buffer; double m_cur; netlist::netlist_time m_sample_time; diff --git a/src/devices/machine/pxa255.cpp b/src/devices/machine/pxa255.cpp index f11043af4e0..2c06dd618a7 100644 --- a/src/devices/machine/pxa255.cpp +++ b/src/devices/machine/pxa255.cpp @@ -265,11 +265,10 @@ void pxa255_periphs_device::device_add_mconfig(machine_config &config) PALETTE(config, m_palette).set_entries(256); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } /* diff --git a/src/devices/machine/s2636.cpp b/src/devices/machine/s2636.cpp index 10a5a2e2be8..d2576b07f1f 100644 --- a/src/devices/machine/s2636.cpp +++ b/src/devices/machine/s2636.cpp @@ -441,10 +441,9 @@ void s2636_device::write_intack(int state) // sound_stream_update - generate audio output //------------------------------------------------- -void s2636_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void s2636_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if (!m_sample_cnt) { @@ -460,7 +459,7 @@ void s2636_device::sound_stream_update(sound_stream &stream, std::vector<read_st } } - buffer.put(sampindex, m_sound_lvl ? 1.0 : 0.0); + stream.put(0, sampindex, m_sound_lvl ? 1.0 : 0.0); m_sample_cnt--; } } diff --git a/src/devices/machine/s2636.h b/src/devices/machine/s2636.h index 25c3d89f761..4be53bc73b1 100644 --- a/src/devices/machine/s2636.h +++ b/src/devices/machine/s2636.h @@ -60,7 +60,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum diff --git a/src/devices/machine/spg110.cpp b/src/devices/machine/spg110.cpp index 6afa6e8a4d3..1d3ac8260a0 100644 --- a/src/devices/machine/spg110.cpp +++ b/src/devices/machine/spg110.cpp @@ -18,7 +18,7 @@ DEFINE_DEVICE_TYPE(SPG110, spg110_device, "spg110", "SPG110 System-on-a-Chip") spg110_device::spg110_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, address_map_constructor internal) : unsp_device(mconfig, type, tag, owner, clock, internal), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_screen(*this, finder_base::DUMMY_TAG), m_spg_io(*this, "spg_io"), m_spg_video(*this, "spg_video"), @@ -132,8 +132,8 @@ void spg110_device::device_add_mconfig(machine_config &config) m_spg_audio->write_irq_callback().set(FUNC(spg110_device::audioirq_w)); m_spg_audio->space_read_callback().set(FUNC(spg110_device::space_r)); - m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_spg_audio->add_route(0, *this, 1.0, 0); + m_spg_audio->add_route(1, *this, 1.0, 1); } void spg110_device::internal_map(address_map &map) diff --git a/src/devices/machine/spg2xx.cpp b/src/devices/machine/spg2xx.cpp index 09e0e0c6f39..cf5988f995f 100644 --- a/src/devices/machine/spg2xx.cpp +++ b/src/devices/machine/spg2xx.cpp @@ -21,7 +21,7 @@ DEFINE_DEVICE_TYPE(SPG28X, spg28x_device, "spg28x", "SPG280-series Syste spg2xx_device::spg2xx_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, uint16_t sprite_limit, address_map_constructor internal) : unsp_device(mconfig, type, tag, owner, clock, internal), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_spg_audio(*this, "spgaudio"), m_spg_io(*this, "spgio"), m_spg_sysdma(*this, "spgsysdma"), @@ -193,8 +193,8 @@ void spg24x_device::device_add_mconfig(machine_config &config) m_spg_audio->channel_irq_callback().set(FUNC(spg24x_device::audiochirq_w)); m_spg_audio->space_read_callback().set(FUNC(spg24x_device::space_r)); - m_spg_audio->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_spg_audio->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_spg_audio->add_route(0, *this, 1.0, 0); + m_spg_audio->add_route(1, *this, 1.0, 1); SPG24X_IO(config, m_spg_io, DERIVED_CLOCK(1, 1), DEVICE_SELF, m_screen); diff --git a/src/devices/machine/spg2xx_audio.cpp b/src/devices/machine/spg2xx_audio.cpp index c81aee592a6..05fea0b4724 100644 --- a/src/devices/machine/spg2xx_audio.cpp +++ b/src/devices/machine/spg2xx_audio.cpp @@ -871,12 +871,9 @@ void spg2xx_audio_device::audio_w(offs_t offset, uint16_t data) } } -void spg2xx_audio_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void spg2xx_audio_device::sound_stream_update(sound_stream &stream) { - auto &out_l = outputs[0]; - auto &out_r = outputs[1]; - - for (int i = 0; i < out_l.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int32_t left_total = 0; int32_t right_total = 0; @@ -976,8 +973,8 @@ void spg2xx_audio_device::sound_stream_update(sound_stream &stream, std::vector< int32_t left_final = (int16_t)((left_total * (int16_t)m_audio_ctrl_regs[AUDIO_MAIN_VOLUME]) >> 7); int32_t right_final = (int16_t)((right_total * (int16_t)m_audio_ctrl_regs[AUDIO_MAIN_VOLUME]) >> 7); - out_l.put_int(i, int16_t(left_final), 32768); - out_r.put_int(i, int16_t(right_final), 32768); + stream.put_int(0, i, int16_t(left_final), 32768); + stream.put_int(1, i, int16_t(right_final), 32768); } } diff --git a/src/devices/machine/spg2xx_audio.h b/src/devices/machine/spg2xx_audio.h index 4834d9b965d..955ebf45975 100644 --- a/src/devices/machine/spg2xx_audio.h +++ b/src/devices/machine/spg2xx_audio.h @@ -33,7 +33,7 @@ public: protected: // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(irq_tick); TIMER_CALLBACK_MEMBER(audio_beat_tick); diff --git a/src/devices/machine/vrender0.cpp b/src/devices/machine/vrender0.cpp index 81ffdea1af0..2fe339a083a 100644 --- a/src/devices/machine/vrender0.cpp +++ b/src/devices/machine/vrender0.cpp @@ -42,8 +42,7 @@ vrender0soc_device::vrender0soc_device(const machine_config &mconfig, const char m_palette(*this, "palette"), m_vr0vid(*this, "vr0vid"), m_vr0snd(*this, "vr0snd"), - m_lspeaker(*this, "lspeaker"), - m_rspeaker(*this, "rspeaker"), + m_speaker(*this, "speaker"), m_uart(*this, "uart%u", 0), m_crtcregs(*this, "crtcregs"), write_tx(*this) @@ -135,15 +134,14 @@ void vrender0soc_device::device_add_mconfig(machine_config &config) PALETTE(config, m_palette, palette_device::RGB_565); - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); SOUND_VRENDER0(config, m_vr0snd, DERIVED_CLOCK(1,1)); // Correct? m_vr0snd->set_addrmap(vr0sound_device::AS_TEXTURE, &vrender0soc_device::texture_map); m_vr0snd->set_addrmap(vr0sound_device::AS_FRAME, &vrender0soc_device::frame_map); m_vr0snd->irq_callback().set(FUNC(vrender0soc_device::soundirq_cb)); - m_vr0snd->add_route(0, m_lspeaker, 1.0); - m_vr0snd->add_route(1, m_rspeaker, 1.0); + m_vr0snd->add_route(0, m_speaker, 1.0, 0); + m_vr0snd->add_route(1, m_speaker, 1.0, 1); } diff --git a/src/devices/machine/vrender0.h b/src/devices/machine/vrender0.h index 604966f2547..ca418101959 100644 --- a/src/devices/machine/vrender0.h +++ b/src/devices/machine/vrender0.h @@ -110,8 +110,7 @@ private: required_device <palette_device> m_palette; required_device <vr0video_device> m_vr0vid; required_device <vr0sound_device> m_vr0snd; - required_device <speaker_device> m_lspeaker; - required_device <speaker_device> m_rspeaker; + required_device <speaker_device> m_speaker; required_device_array <vr0uart_device, 2> m_uart; required_shared_ptr <uint32_t> m_crtcregs; std::unique_ptr<uint16_t []> m_textureram; diff --git a/src/devices/sound/ad1848.cpp b/src/devices/sound/ad1848.cpp index ac37b4cd05f..b9395d23360 100644 --- a/src/devices/sound/ad1848.cpp +++ b/src/devices/sound/ad1848.cpp @@ -23,10 +23,9 @@ ad1848_device::ad1848_device(const machine_config &mconfig, const char *tag, dev void ad1848_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } diff --git a/src/devices/sound/adc.cpp b/src/devices/sound/adc.cpp new file mode 100644 index 00000000000..3f2ee0b3175 --- /dev/null +++ b/src/devices/sound/adc.cpp @@ -0,0 +1,66 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// ADCs, unsigned or signed two-complement + +#include "emu.h" +#include "adc.h" + + +zn449_device::zn449_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ZN449, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_stream(nullptr), + m_current_value(0) +{ +} + +u8 zn449_device::read() +{ + m_stream->update(); + return m_current_value; +} + +void zn449_device::device_start() +{ + save_item(NAME(m_current_value)); + m_stream = stream_alloc(1, 0, SAMPLE_RATE_INPUT_ADAPTIVE); +} + +void zn449_device::sound_stream_update(sound_stream &stream) +{ + sound_stream::sample_t last_sample = stream.get(0, stream.samples()-1); + m_current_value = 128 * last_sample + 128; +} + +DEFINE_DEVICE_TYPE(ZN449, zn449_device, "zn449", "ZN449 ADC") + + + +adc10_device::adc10_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) + : device_t(mconfig, ADC10, tag, owner, clock), + device_sound_interface(mconfig, *this), + m_stream(nullptr), + m_current_value(0) +{ +} + +u16 adc10_device::read() +{ + m_stream->update(); + return m_current_value; +} + +void adc10_device::device_start() +{ + save_item(NAME(m_current_value)); + m_stream = stream_alloc(1, 0, SAMPLE_RATE_INPUT_ADAPTIVE); +} + +void adc10_device::sound_stream_update(sound_stream &stream) +{ + sound_stream::sample_t last_sample = stream.get(0, stream.samples()-1); + m_current_value = std::clamp(int(512 * last_sample), -512, 511); +} + +DEFINE_DEVICE_TYPE(ADC10, adc10_device, "adc10", "10-bits signed ADC") diff --git a/src/devices/sound/adc.h b/src/devices/sound/adc.h new file mode 100644 index 00000000000..43903a930de --- /dev/null +++ b/src/devices/sound/adc.h @@ -0,0 +1,42 @@ +// license:BSD-3-Clause +// copyright-holders: Olivier Galibert + +// ADCs, unsigned or signed two-complement + +#ifndef MAME_SOUND_ADC_H +#define MAME_SOUND_ADC_H + +#pragma once + +class zn449_device : public device_t, public device_sound_interface +{ +public: + zn449_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + u8 read(); + +protected: + sound_stream *m_stream; + u8 m_current_value; + + virtual void device_start() override ATTR_COLD; + virtual void sound_stream_update(sound_stream &stream) override; +}; + +class adc10_device : public device_t, public device_sound_interface +{ +public: + adc10_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); + u16 read(); + +protected: + sound_stream *m_stream; + u16 m_current_value; + + virtual void device_start() override ATTR_COLD; + virtual void sound_stream_update(sound_stream &stream) override; +}; + +DECLARE_DEVICE_TYPE(ZN449, zn449_device); +DECLARE_DEVICE_TYPE(ADC10, adc10_device); + +#endif // MAME_SOUND_ADC_H diff --git a/src/devices/sound/aica.cpp b/src/devices/sound/aica.cpp index f7cf5875e93..1e3eaac954e 100644 --- a/src/devices/sound/aica.cpp +++ b/src/devices/sound/aica.cpp @@ -1234,11 +1234,11 @@ s32 aica_device::UpdateSlot(AICA_SLOT *slot) return sample; } -void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, write_stream_view &bufl, write_stream_view &bufr) +void aica_device::DoMasterSamples(sound_stream &stream) { int i; - for (int s = 0; s < bufl.samples(); ++s) + for (int s = 0; s < stream.samples(); ++s) { s32 smpl = 0, smpr = 0; @@ -1279,7 +1279,7 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w { if (EFSDL(i + 16)) // 16,17 for EXTS { - m_DSP.EXTS[i] = s16(inputs[i].get(s) * 32767.0); + m_DSP.EXTS[i] = s16(stream.get(i, s) * 32767.0); u32 Enc = ((EFPAN(i + 16)) << 0x8) | ((EFSDL(i + 16)) << 0xd); smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT; smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT; @@ -1297,9 +1297,9 @@ void aica_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, w smpr = clip16(smpr >> 3); } - bufl.put_int(s, smpl * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); + stream.put_int(0, s, smpl * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); // TODO: diverges with SCSP, also wut? - bufr.put_int(s, smpr * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); + stream.put_int(1, s, smpr * m_LPANTABLE[MVOL() << 0xd], 32768 << SHIFT); } } @@ -1385,9 +1385,9 @@ void aica_device::exec_dma() // sound_stream_update - handle a stream update //------------------------------------------------- -void aica_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void aica_device::sound_stream_update(sound_stream &stream) { - DoMasterSamples(inputs, outputs[0], outputs[1]); + DoMasterSamples(stream); } //------------------------------------------------- diff --git a/src/devices/sound/aica.h b/src/devices/sound/aica.h index 6e99346cd4f..afca6b17387 100644 --- a/src/devices/sound/aica.h +++ b/src/devices/sound/aica.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; @@ -126,7 +126,7 @@ private: u16 r16(u32 addr); [[maybe_unused]] void TimersAddTicks(int ticks); s32 UpdateSlot(AICA_SLOT *slot); - void DoMasterSamples(std::vector<read_stream_view> const &inputs, write_stream_view &bufl, write_stream_view &bufr); + void DoMasterSamples(sound_stream &stream); void exec_dma(); diff --git a/src/devices/sound/ap2010pcm.cpp b/src/devices/sound/ap2010pcm.cpp index 234264f52f9..7a7d9442be1 100644 --- a/src/devices/sound/ap2010pcm.cpp +++ b/src/devices/sound/ap2010pcm.cpp @@ -59,16 +59,13 @@ void ap2010pcm_device::device_start() save_item(NAME(m_fifo_fast_tail)); } -void ap2010pcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ap2010pcm_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - buffer.fill(0); - int16_t sample = 0; uint16_t sample_empty_count = 0; uint16_t fifo_size = m_fifo_size; uint16_t fifo_fast_size = m_fifo_fast_size; - for (size_t i = 0; i < buffer.samples(); i++) { + for (size_t i = 0; i < stream.samples(); i++) { if (m_fifo_fast_size) { sample = fifo_fast_pop(); } else if (m_fifo_size) { @@ -78,10 +75,10 @@ void ap2010pcm_device::sound_stream_update(sound_stream &stream, std::vector<rea sample_empty_count++; } - buffer.put_int(i, sample * m_volume, 32768); + stream.put_int(0, i, sample * m_volume, 32768); } if (fifo_size && sample_empty_count) { - LOG("pcm 0s = %d (had %d + fast %d, needed %d)\n", sample_empty_count, fifo_size, fifo_fast_size, buffer.samples()); + LOG("pcm 0s = %d (had %d + fast %d, needed %d)\n", sample_empty_count, fifo_size, fifo_fast_size, stream.samples()); } } diff --git a/src/devices/sound/ap2010pcm.h b/src/devices/sound/ap2010pcm.h index bea50bc4424..c5be63bbddd 100644 --- a/src/devices/sound/ap2010pcm.h +++ b/src/devices/sound/ap2010pcm.h @@ -30,7 +30,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // FIXME: Games check this against 0x1ff, but samples are lost with that limit diff --git a/src/devices/sound/asc.cpp b/src/devices/sound/asc.cpp index 231e6b2357f..347f9104649 100644 --- a/src/devices/sound/asc.cpp +++ b/src/devices/sound/asc.cpp @@ -123,20 +123,14 @@ TIMER_CALLBACK_MEMBER(asc_device::delayed_stream_update) // our sound stream //------------------------------------------------- -void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void asc_device::sound_stream_update(sound_stream &stream) { int i, ch; static uint32_t wtoffs[2] = { 0, 0x200 }; - auto &outL = outputs[0]; - auto &outR = outputs[1]; - switch (m_regs[R_MODE-0x800] & 3) { case 0: // chip off - outL.fill(0); - outR.fill(0); - // IIvx/IIvi bootrom indicates VASP updates this flag even when the chip is off if (m_chip_type == asc_type::VASP) { @@ -154,7 +148,7 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre case 1: // FIFO mode { - for (i = 0; i < outL.samples(); i++) + for (i = 0; i < stream.samples(); i++) { int8_t smpll, smplr; @@ -257,15 +251,15 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre break; } - outL.put_int(i, smpll, 32768 / 64); - outR.put_int(i, smplr, 32768 / 64); + stream.put_int(0, i, smpll, 32768 / 64); + stream.put_int(1, i, smplr, 32768 / 64); } break; } case 2: // wavetable mode { - for (i = 0; i < outL.samples(); i++) + for (i = 0; i < stream.samples(); i++) { int32_t mixL, mixR; int8_t smpl; @@ -291,8 +285,8 @@ void asc_device::sound_stream_update(sound_stream &stream, std::vector<read_stre mixR += smpl*256; } - outL.put_int(i, mixL, 32768 * 4); - outR.put_int(i, mixR, 32768 * 4); + stream.put_int(0, i, mixL, 32768 * 4); + stream.put_int(1, i, mixR, 32768 * 4); } break; } diff --git a/src/devices/sound/asc.h b/src/devices/sound/asc.h index 2f32b841c03..952f6bff8aa 100644 --- a/src/devices/sound/asc.h +++ b/src/devices/sound/asc.h @@ -77,7 +77,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update); diff --git a/src/devices/sound/astrocde.cpp b/src/devices/sound/astrocde.cpp index e29b6f31617..be7b8a7946b 100644 --- a/src/devices/sound/astrocde.cpp +++ b/src/devices/sound/astrocde.cpp @@ -115,9 +115,8 @@ void astrocade_io_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void astrocade_io_device::sound_stream_update(sound_stream &stream) { - auto &dest = outputs[0]; uint16_t noise_state; uint8_t master_count; uint8_t noise_clock; @@ -129,14 +128,14 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector< /* loop over samples */ int samples_this_time; - constexpr stream_buffer::sample_t sample_scale = 1.0f / 60.0f; - for (int sampindex = 0; sampindex < dest.samples(); sampindex += samples_this_time) + constexpr sound_stream::sample_t sample_scale = 1.0f / 60.0f; + for (int sampindex = 0; sampindex < stream.samples(); sampindex += samples_this_time) { s32 cursample = 0; /* compute the number of cycles until the next master oscillator reset */ /* or until the next noise boundary */ - samples_this_time = std::min<int>(dest.samples() - sampindex, 256 - master_count); + samples_this_time = std::min<int>(stream.samples() - sampindex, 256 - master_count); samples_this_time = std::min(samples_this_time, 64 - noise_clock); /* sum the output of the tone generators */ @@ -152,7 +151,7 @@ void astrocade_io_device::sound_stream_update(sound_stream &stream, std::vector< cursample += m_reg[7] >> 4; /* scale to max and output */ - dest.fill(stream_buffer::sample_t(cursample) * sample_scale, sampindex, samples_this_time); + stream.fill(0, sound_stream::sample_t(cursample) * sample_scale, sampindex, samples_this_time); /* clock the noise; a 2-bit counter clocks a 4-bit counter which clocks the LFSR */ noise_clock += samples_this_time; diff --git a/src/devices/sound/astrocde.h b/src/devices/sound/astrocde.h index 7c623e0f1f2..1fbe7504e8e 100644 --- a/src/devices/sound/astrocde.h +++ b/src/devices/sound/astrocde.h @@ -57,7 +57,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: void write(offs_t offset, uint8_t data); diff --git a/src/devices/sound/awacs.cpp b/src/devices/sound/awacs.cpp index 236852c854b..3ddb10e7007 100644 --- a/src/devices/sound/awacs.cpp +++ b/src/devices/sound/awacs.cpp @@ -103,7 +103,7 @@ void awacs_device::device_reset() // our sound stream //------------------------------------------------- -void awacs_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void awacs_device::sound_stream_update(sound_stream &stream) { m_last_sample = machine().time(); @@ -119,14 +119,14 @@ void awacs_device::sound_stream_update(sound_stream &stream, std::vector<read_st u32 data = m_output_cb(m_phase | (m_output_buffer ? 0x10000 : 0)); s16 left = data >> 16; s16 right = data; - outputs[0].put_int(0, left, 32768); - outputs[1].put_int(0, right, 32768); + stream.put_int(0, 0, left, 32768); + stream.put_int(1, 0, right, 32768); } else { m_output_buffer = false; - outputs[0].put_int(0, 0, 32768); - outputs[1].put_int(0, 0, 32768); + stream.put_int(0, 0, 0, 32768); + stream.put_int(1, 0, 0, 32768); } if(m_active & ACTIVE_IN) diff --git a/src/devices/sound/awacs.h b/src/devices/sound/awacs.h index d46f3fcec29..89bb254eb3a 100644 --- a/src/devices/sound/awacs.h +++ b/src/devices/sound/awacs.h @@ -49,7 +49,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; devcb_write_line m_irq_out_cb, m_irq_in_cb; devcb_read32 m_output_cb; diff --git a/src/devices/sound/ay8910.cpp b/src/devices/sound/ay8910.cpp index b4ad9a01043..f93d0027a85 100644 --- a/src/devices/sound/ay8910.cpp +++ b/src/devices/sound/ay8910.cpp @@ -593,7 +593,7 @@ be induced by cutoff currents from the 15 FETs. #define ENABLE_REGISTER_TEST (0) // Enable preprogrammed registers -static constexpr stream_buffer::sample_t MAX_OUTPUT = 1.0; +static constexpr sound_stream::sample_t MAX_OUTPUT = 1.0; /************************************* @@ -758,7 +758,7 @@ static const ay8910_device::mosfet_param ay8910_mosfet_param = * *************************************/ -static inline void build_3D_table(double rl, const ay8910_device::ay_ym_param *par, const ay8910_device::ay_ym_param *par_env, int normalize, double factor, int zero_is_off, stream_buffer::sample_t *tab) +static inline void build_3D_table(double rl, const ay8910_device::ay_ym_param *par, const ay8910_device::ay_ym_param *par_env, int normalize, double factor, int zero_is_off, sound_stream::sample_t *tab) { double min = 10.0, max = 0.0; @@ -817,7 +817,7 @@ static inline void build_3D_table(double rl, const ay8910_device::ay_ym_param *p // for (e = 0;e<16;e++) printf("%d %d\n",e << 10, tab[e << 10]); } -static inline void build_single_table(double rl, const ay8910_device::ay_ym_param *par, int normalize, stream_buffer::sample_t *tab, int zero_is_off) +static inline void build_single_table(double rl, const ay8910_device::ay_ym_param *par, int normalize, sound_stream::sample_t *tab, int zero_is_off) { double rt; double rw; @@ -855,7 +855,7 @@ static inline void build_single_table(double rl, const ay8910_device::ay_ym_para } -static inline void build_mosfet_resistor_table(const ay8910_device::mosfet_param &par, const double rd, stream_buffer::sample_t *tab) +static inline void build_mosfet_resistor_table(const ay8910_device::mosfet_param &par, const double rd, sound_stream::sample_t *tab) { for (int j = 0; j < par.m_count; j++) { @@ -873,7 +873,7 @@ static inline void build_mosfet_resistor_table(const ay8910_device::mosfet_param } -stream_buffer::sample_t ay8910_device::mix_3D() +sound_stream::sample_t ay8910_device::mix_3D() { int indx = 0; @@ -1055,20 +1055,11 @@ void ay8910_device::ay8910_write_reg(int r, int v) // sound_stream_update - handle a stream update //------------------------------------------------- -void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ay8910_device::sound_stream_update(sound_stream &stream) { tone_t *tone; envelope_t *envelope; - int samples = outputs[0].samples(); - - // hack to prevent us from hanging when starting filtered outputs - if (!m_ready) - { - for (int chan = 0; chan < m_streams; chan++) - outputs[chan].fill(0); - } - // The 8910 has three outputs, each output is the mix of one of the three // tone generators and of the (single) noise generator. The two are mixed // BEFORE going into the DAC. The formula to mix each channel is: @@ -1077,7 +1068,7 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s // is 1, not 0, and can be modulated changing the volume. // buffering loop - for (int sampindex = 0; sampindex < samples; sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { for (int chan = 0; chan < NUM_CHANNELS; chan++) { @@ -1172,38 +1163,38 @@ void ay8910_device::sound_stream_update(sound_stream &stream, std::vector<read_s { env_volume >>= 1; if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field - outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); + stream.put(chan, sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); else - outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]); + stream.put(chan, sampindex, m_vol_table[chan][m_vol_enabled[chan] ? env_volume : 0]); } else { if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); else - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); } } else { if (m_feature & PSG_EXTENDED_ENVELOPE) // AY8914 Has a two bit tone_envelope field - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume >> (3-tone_envelope(tone)) : 0]); else - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? env_volume : 0]); } } else { if (is_expanded_mode()) - outputs[chan].put(sampindex, m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); + stream.put(chan, sampindex, m_env_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); else - outputs[chan].put(sampindex, m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); + stream.put(chan, sampindex, m_vol_table[chan][m_vol_enabled[chan] ? tone_volume(tone) : 0]); } } } else { - outputs[0].put(sampindex, mix_3D()); + stream.put(0, sampindex, mix_3D()); } } } @@ -1298,7 +1289,7 @@ void ay8910_device::device_start() m_streams = 1; } - m_vol3d_table = make_unique_clear<stream_buffer::sample_t[]>(8*32*32*32); + m_vol3d_table = make_unique_clear<sound_stream::sample_t[]>(8*32*32*32); build_mixer_table(); diff --git a/src/devices/sound/ay8910.h b/src/devices/sound/ay8910.h index ca763dc754c..44ec39649c2 100644 --- a/src/devices/sound/ay8910.h +++ b/src/devices/sound/ay8910.h @@ -140,7 +140,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void ay8910_write_ym(int addr, u8 data); u8 ay8910_read_ym(); @@ -294,7 +294,7 @@ private: // internal helpers void set_type(psg_type_t psg_type); - inline stream_buffer::sample_t mix_3D(); + inline sound_stream::sample_t mix_3D(); void ay8910_write_reg(int r, int v); void build_mixer_table(); void ay8910_statesave(); @@ -324,9 +324,9 @@ private: u8 m_vol_enabled[NUM_CHANNELS]; const ay_ym_param *m_par; const ay_ym_param *m_par_env; - stream_buffer::sample_t m_vol_table[NUM_CHANNELS][16]; - stream_buffer::sample_t m_env_table[NUM_CHANNELS][32]; - std::unique_ptr<stream_buffer::sample_t[]> m_vol3d_table; + sound_stream::sample_t m_vol_table[NUM_CHANNELS][16]; + sound_stream::sample_t m_env_table[NUM_CHANNELS][32]; + std::unique_ptr<sound_stream::sample_t[]> m_vol3d_table; int m_flags; // Flags int m_feature; // Chip specific features int m_res_load[3]; // Load on channel in ohms diff --git a/src/devices/sound/bbd.cpp b/src/devices/sound/bbd.cpp index 5b694b6970c..f09a0e5ad3a 100644 --- a/src/devices/sound/bbd.cpp +++ b/src/devices/sound/bbd.cpp @@ -12,105 +12,48 @@ // bbd_device_base - constructor //------------------------------------------------- -template<int Entries, int Outputs> -bbd_device_base<Entries, Outputs>::bbd_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : +bbd_device_base::bbd_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type) : device_t(mconfig, type, tag, owner, clock), - device_sound_interface(mconfig, *this), - m_stream(nullptr), - m_curpos(0), - m_cv_handler(*this), - m_next_bbdtime(attotime::zero) + device_sound_interface(mconfig, *this) { - std::fill_n(&m_buffer[0], Entries, 0); } - -//------------------------------------------------- -// device_start - device-specific startup -//------------------------------------------------- - -template<int Entries, int Outputs> -void bbd_device_base<Entries, Outputs>::device_start() +void bbd_device_base::set_bucket_count(int buckets) { - m_cv_handler.resolve(); - - if (m_cv_handler.isnull()) - m_stream = stream_alloc(1, Outputs, sample_rate()); - else - m_stream = stream_alloc(1, Outputs, SAMPLE_RATE_OUTPUT_ADAPTIVE, STREAM_DISABLE_INPUT_RESAMPLING); + m_buffer.resize(buckets); +} +void bbd_device_base::device_start() +{ + m_stream = stream_alloc(1, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE, STREAM_SYNCHRONOUS); save_item(NAME(m_buffer)); save_item(NAME(m_curpos)); - save_item(NAME(m_next_bbdtime)); -} -//------------------------------------------------- -// device_clock_changed - handle a clock change -//------------------------------------------------- +} -template<int Entries, int Outputs> -void bbd_device_base<Entries, Outputs>::device_clock_changed() +void bbd_device_base::device_reset() { - if (m_cv_handler.isnull()) - m_stream->set_sample_rate(sample_rate()); + std::fill(m_buffer.begin(), m_buffer.end(), 0); + m_curpos = 0; } +void bbd_device_base::tick() +{ + u32 nextpos = m_curpos + 1; + if(nextpos == m_buffer.size()) + nextpos = 0; + m_buffer[nextpos] = m_buffer[m_curpos]; + m_curpos = nextpos; +} -//------------------------------------------------- -// sound_stream_update - handle a stream update -//------------------------------------------------- - -template<int Entries, int Outputs> -void bbd_device_base<Entries, Outputs>::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void bbd_device_base::sound_stream_update(sound_stream &stream) { - // BBDs that I've seen so far typically have 2 outputs, with the first outputting - // sample n-1 and the second outputting sampe n; if chips with more outputs - // or other taps turn up, this logic will need to be made more flexible - if (m_cv_handler.isnull()) - { - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - { - for (int outnum = 0; outnum < Outputs; outnum++) - outputs[outnum].put(sampindex, m_buffer[(m_curpos + (Outputs - 1) - outnum) % Entries]); - m_buffer[m_curpos] = inputs[0].get(sampindex); - m_curpos = (m_curpos + 1) % Entries; - } - } - else - { - read_stream_view in(inputs[0], m_next_bbdtime); - attotime intime = in.start_time(); - attotime outtime = outputs[0].start_time(); - int inpos = 0; - - // loop until all outputs generated - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - { - // we need to process some more BBD input - while (outtime >= m_next_bbdtime) - { - // find the input sample that overlaps our start time - while (intime + in.sample_period() < m_next_bbdtime) - { - inpos++; - intime += in.sample_period(); - } - - // copy that to the buffer - m_buffer[m_curpos] = in.get(inpos); - m_curpos = (m_curpos + 1) % std::size(m_buffer); - - // advance the end time of this BBD sample - m_next_bbdtime += attotime(0, m_cv_handler(m_next_bbdtime)); - } - - // copy the most recently-generated BBD data - for (int outnum = 0; outnum < Outputs; outnum++) - outputs[outnum].put(sampindex, outputval(outnum - (Outputs - 1))); - outtime += outputs[0].sample_period(); - } - } + u32 nextpos = m_curpos + 1; + if(nextpos == m_buffer.size()) + nextpos = 0; + stream.put(0, 0, m_buffer[nextpos]); + m_buffer[m_curpos] = stream.get(0, 0); } @@ -124,6 +67,7 @@ DEFINE_DEVICE_TYPE(MN3004, mn3004_device, "mn3004", "MN3004 BBD") mn3004_device::mn3004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3004) { + set_bucket_count(512); } @@ -137,6 +81,7 @@ DEFINE_DEVICE_TYPE(MN3005, mn3005_device, "mn3005", "MN3005 BBD") mn3005_device::mn3005_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3005) { + set_bucket_count(4096); } @@ -150,6 +95,7 @@ DEFINE_DEVICE_TYPE(MN3006, mn3006_device, "mn3006", "MN3006 BBD") mn3006_device::mn3006_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3006) { + set_bucket_count(128); } @@ -163,6 +109,7 @@ DEFINE_DEVICE_TYPE(MN3204P, mn3204p_device, "mn3204p", "MN3204P BBD") mn3204p_device::mn3204p_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3204P) { + set_bucket_count(512); } @@ -176,4 +123,5 @@ DEFINE_DEVICE_TYPE(MN3207, mn3207_device, "mn3207", "MN3207 BBD") mn3207_device::mn3207_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : bbd_device_base(mconfig, tag, owner, clock, MN3207) { + set_bucket_count(1024); } diff --git a/src/devices/sound/bbd.h b/src/devices/sound/bbd.h index 64394a90620..4b761a64904 100644 --- a/src/devices/sound/bbd.h +++ b/src/devices/sound/bbd.h @@ -11,45 +11,38 @@ // ======================> bbd_device_base -template<int Entries, int Outputs> class bbd_device_base : public device_t, public device_sound_interface { public: - // configuration - template <typename... T> void set_cv_handler(T &&... args) - { - m_cv_handler.set(std::forward<T>(args)...); - } + void tick(); protected: - using cv_delegate = device_delegate<attoseconds_t (attotime const &)>; - // internal constructor bbd_device_base(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, device_type type); + void set_bucket_count(int buckets); + // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void device_clock_changed() override; + virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; protected: // override to convert clock to sample rate - stream_buffer::sample_t outputval(s32 index) const { return m_buffer[(m_curpos - index) % std::size(m_buffer)]; } + sound_stream::sample_t outputval(s32 index) const { return m_buffer[(m_curpos - index) % std::size(m_buffer)]; } virtual u32 sample_rate() const { return clock(); } sound_stream * m_stream; u32 m_curpos; - cv_delegate m_cv_handler; - attotime m_next_bbdtime; - stream_buffer::sample_t m_buffer[Entries + 1]; + std::vector<sound_stream::sample_t> m_buffer; }; // ======================> mn3004_device -class mn3004_device : public bbd_device_base<512, 2> +class mn3004_device : public bbd_device_base { public: mn3004_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -60,7 +53,7 @@ DECLARE_DEVICE_TYPE(MN3004, mn3004_device) // ======================> mn3005_device -class mn3005_device : public bbd_device_base<4096, 2> +class mn3005_device : public bbd_device_base { public: mn3005_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -71,7 +64,7 @@ DECLARE_DEVICE_TYPE(MN3005, mn3005_device) // ======================> mn3006_device -class mn3006_device : public bbd_device_base<128, 2> +class mn3006_device : public bbd_device_base { public: mn3006_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -82,7 +75,7 @@ DECLARE_DEVICE_TYPE(MN3006, mn3006_device) // ======================> mn3204p_device -class mn3204p_device : public bbd_device_base<512, 2> +class mn3204p_device : public bbd_device_base { public: mn3204p_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); @@ -93,7 +86,7 @@ DECLARE_DEVICE_TYPE(MN3204P, mn3204p_device) // ======================> mn3207_device -class mn3207_device : public bbd_device_base<1024, 2> +class mn3207_device : public bbd_device_base { public: mn3207_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0); diff --git a/src/devices/sound/beep.cpp b/src/devices/sound/beep.cpp index fd4096c72eb..9a341a7a2d3 100644 --- a/src/devices/sound/beep.cpp +++ b/src/devices/sound/beep.cpp @@ -52,19 +52,14 @@ void beep_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void beep_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - // if we're not enabled, just fill with 0 + // if we're not enabled, just leave cleared if (!m_enable || m_frequency == 0) - { - buffer.fill(0); return; - } // fill in the sample - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { m_incr -= m_frequency; while (m_incr < 0) @@ -73,7 +68,7 @@ void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_str m_signal = -m_signal; } - buffer.put(sampindex, m_signal); + stream.put(0, sampindex, m_signal); } } diff --git a/src/devices/sound/beep.h b/src/devices/sound/beep.h index a33ab803020..651ad143985 100644 --- a/src/devices/sound/beep.h +++ b/src/devices/sound/beep.h @@ -28,14 +28,14 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; // stream number bool m_enable; // enable beep uint32_t m_frequency; // set frequency - this can be changed using the appropriate function int32_t m_incr; // initial wave state - stream_buffer::sample_t m_signal; // current signal + sound_stream::sample_t m_signal; // current signal }; DECLARE_DEVICE_TYPE(BEEP, beep_device) diff --git a/src/devices/sound/bsmt2000.cpp b/src/devices/sound/bsmt2000.cpp index 428009b1fc2..44f35c09ba5 100644 --- a/src/devices/sound/bsmt2000.cpp +++ b/src/devices/sound/bsmt2000.cpp @@ -186,12 +186,12 @@ TIMER_CALLBACK_MEMBER(bsmt2000_device::deferred_data_write) // for our sound stream //------------------------------------------------- -void bsmt2000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void bsmt2000_device::sound_stream_update(sound_stream &stream) { // just fill with current left/right values - constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - outputs[0].fill(stream_buffer::sample_t(m_left_data) * sample_scale); - outputs[1].fill(stream_buffer::sample_t(m_right_data) * sample_scale); + constexpr sound_stream::sample_t sample_scale = 1.0 / 32768.0; + stream.fill(0, sound_stream::sample_t(m_left_data) * sample_scale); + stream.fill(1, sound_stream::sample_t(m_right_data) * sample_scale); } diff --git a/src/devices/sound/bsmt2000.h b/src/devices/sound/bsmt2000.h index dc9fc5751c2..e0c9fbabaec 100644 --- a/src/devices/sound/bsmt2000.h +++ b/src/devices/sound/bsmt2000.h @@ -52,7 +52,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/c140.cpp b/src/devices/sound/c140.cpp index 688ebec6459..9c83dac32db 100644 --- a/src/devices/sound/c140.cpp +++ b/src/devices/sound/c140.cpp @@ -215,12 +215,12 @@ void c140_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c140_device::sound_stream_update(sound_stream &stream) { float pbase = (float)m_baserate * 2.0f / (float)m_sample_rate; s16 *lmix, *rmix; - int samples = outputs[0].samples(); + int samples = stream.samples(); if (samples > m_sample_rate) samples = m_sample_rate; /* zap the contents of the mixer buffer */ @@ -317,22 +317,20 @@ void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_str lmix = m_mixer_buffer_left.get(); rmix = m_mixer_buffer_right.get(); { - auto &dest1 = outputs[0]; - auto &dest2 = outputs[1]; for (int i = 0; i < samples; i++) { - dest1.put_int_clamp(i, *lmix++, 32768 / 8); - dest2.put_int_clamp(i, *rmix++, 32768 / 8); + stream.put_int_clamp(0, i, *lmix++, 32768 / 8); + stream.put_int_clamp(1, i, *rmix++, 32768 / 8); } } } -void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c219_device::sound_stream_update(sound_stream &stream) { float pbase = (float)m_baserate * 2.0f / (float)m_sample_rate; s16 *lmix, *rmix; - int samples = outputs[0].samples(); + int samples = stream.samples(); if (samples > m_sample_rate) samples = m_sample_rate; /* zap the contents of the mixer buffer */ @@ -448,12 +446,10 @@ void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_str lmix = m_mixer_buffer_left.get(); rmix = m_mixer_buffer_right.get(); { - auto &dest1 = outputs[0]; - auto &dest2 = outputs[1]; for (int i = 0; i < samples; i++) { - dest1.put_int_clamp(i, *lmix++, 32768 / 8); - dest2.put_int_clamp(i, *rmix++, 32768 / 8); + stream.put_int_clamp(0, i, *lmix++, 32768 / 8); + stream.put_int_clamp(1, i, *rmix++, 32768 / 8); } } } diff --git a/src/devices/sound/c140.h b/src/devices/sound/c140.h index 2fda0526a82..9fd23b3b0a6 100644 --- a/src/devices/sound/c140.h +++ b/src/devices/sound/c140.h @@ -44,7 +44,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual int find_sample(int adrs, int bank, int voice); @@ -118,7 +118,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual int find_sample(int adrs, int bank, int voice) override; diff --git a/src/devices/sound/c352.cpp b/src/devices/sound/c352.cpp index dcbd58f3eb3..f4b21be2663 100644 --- a/src/devices/sound/c352.cpp +++ b/src/devices/sound/c352.cpp @@ -123,14 +123,9 @@ void c352_device::ramp_volume(c352_voice_t &v, int ch, u8 val) v.curr_vol[ch] += (vol_delta > 0) ? -1 : 1; } -void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c352_device::sound_stream_update(sound_stream &stream) { - auto &buffer_fl = outputs[0]; - auto &buffer_fr = outputs[1]; - auto &buffer_rl = outputs[2]; - auto &buffer_rr = outputs[3]; - - for (int i = 0; i < buffer_fl.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int out[4] = { 0, 0, 0, 0 }; @@ -174,10 +169,10 @@ void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_str out[3] += (((v.flags & C352_FLG_PHASEFR) ? -s : s) * v.curr_vol[3]) >> 8; } - buffer_fl.put_int(i, s16(out[0] >> 3), 32768); - buffer_fr.put_int(i, s16(out[1] >> 3), 32768); - buffer_rl.put_int(i, s16(out[2] >> 3), 32768); - buffer_rr.put_int(i, s16(out[3] >> 3), 32768); + stream.put_int(0, i, s16(out[0] >> 3), 32768); + stream.put_int(1, i, s16(out[1] >> 3), 32768); + stream.put_int(2, i, s16(out[2] >> 3), 32768); + stream.put_int(3, i, s16(out[3] >> 3), 32768); } } diff --git a/src/devices/sound/c352.h b/src/devices/sound/c352.h index 321d5144879..b404952745a 100644 --- a/src/devices/sound/c352.h +++ b/src/devices/sound/c352.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/c6280.cpp b/src/devices/sound/c6280.cpp index c6f3e92a4fd..df857d1f172 100644 --- a/src/devices/sound/c6280.cpp +++ b/src/devices/sound/c6280.cpp @@ -42,7 +42,7 @@ #include <algorithm> -void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void c6280_device::sound_stream_update(sound_stream &stream) { static const u8 scale_tab[16] = { @@ -53,11 +53,7 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st const u8 lmal = scale_tab[(m_balance >> 4) & 0x0f]; const u8 rmal = scale_tab[(m_balance >> 0) & 0x0f]; - /* Clear buffer */ - outputs[0].fill(0); - outputs[1].fill(0); - - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 lout = 0, rout = 0; for (int ch = 0; ch < 6; ch++) @@ -164,8 +160,8 @@ void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_st } } } - outputs[0].put_int(i, lout, 32768); - outputs[1].put_int(i, rout, 32768); + stream.put_int(0, i, lout, 32768); + stream.put_int(1, i, rout, 32768); } } diff --git a/src/devices/sound/c6280.h b/src/devices/sound/c6280.h index 407f5abaad0..85c94566ee7 100644 --- a/src/devices/sound/c6280.h +++ b/src/devices/sound/c6280.h @@ -22,7 +22,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct channel { diff --git a/src/devices/sound/cdda.cpp b/src/devices/sound/cdda.cpp index 5c39bbfe84e..281a625c0bf 100644 --- a/src/devices/sound/cdda.cpp +++ b/src/devices/sound/cdda.cpp @@ -15,9 +15,9 @@ static constexpr int MAX_SCAN_SECTORS = 2; // sound_stream_update - handle a stream update //------------------------------------------------- -void cdda_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdda_device::sound_stream_update(sound_stream &stream) { - get_audio_data(outputs[0], outputs[1]); + get_audio_data(stream); } //------------------------------------------------- @@ -199,12 +199,11 @@ int cdda_device::audio_ended() converts it to 2 16-bit 44.1 kHz streams -------------------------------------------------*/ -void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &bufR) +void cdda_device::get_audio_data(sound_stream &stream) { - int i; int16_t *audio_cache = (int16_t *) m_audio_cache.get(); - for (int sampindex = 0; sampindex < bufL.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { /* if no file, audio not playing, audio paused, or out of disc data, just zero fill */ @@ -219,25 +218,23 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf m_sequence_counter = m_disc->sequence_counter(); m_audio_data[0] = m_audio_data[1] = 0; - bufL.fill(0, sampindex); - bufR.fill(0, sampindex); return; } - int samples = bufL.samples() - sampindex; + int samples = stream.samples() - sampindex; if (samples > m_audio_samples) { samples = m_audio_samples; } - for (i = 0; i < samples; i++) + for (int i = 0; i < samples; i++) { /* CD-DA data on the disc is big-endian */ m_audio_data[0] = s16(big_endianize_int16( audio_cache[ m_audio_bptr ] )); - bufL.put_int(sampindex + i, m_audio_data[0], 32768); + stream.put_int(0, sampindex + i, m_audio_data[0], 32768); m_audio_bptr++; m_audio_data[1] = s16(big_endianize_int16( audio_cache[ m_audio_bptr ] )); - bufR.put_int(sampindex + i, m_audio_data[1], 32768); + stream.put_int(1, sampindex + i, m_audio_data[1], 32768); m_audio_bptr++; } @@ -252,7 +249,7 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf sectors = MAX_SECTORS; } - for (i = 0; i < sectors; i++) + for (int i = 0; i < sectors; i++) { const auto adr_control = m_disc->get_adr_control(m_disc->get_track(m_audio_lba)); diff --git a/src/devices/sound/cdda.h b/src/devices/sound/cdda.h index dcdea3cc5bf..5eadd5e315f 100644 --- a/src/devices/sound/cdda.h +++ b/src/devices/sound/cdda.h @@ -37,10 +37,10 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: - void get_audio_data(write_stream_view &bufL, write_stream_view &bufR); + void get_audio_data(sound_stream &stream); required_device<cdrom_image_device> m_disc; diff --git a/src/devices/sound/cdp1863.cpp b/src/devices/sound/cdp1863.cpp index da9194b9a7e..31d135b5c78 100644 --- a/src/devices/sound/cdp1863.cpp +++ b/src/devices/sound/cdp1863.cpp @@ -85,15 +85,14 @@ void cdp1863_device::device_start() // our sound stream //------------------------------------------------- -void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdp1863_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t signal = m_signal; - auto &buffer = outputs[0]; + sound_stream::sample_t signal = m_signal; if (m_oe) { double frequency; - int rate = buffer.sample_rate() / 2; + int rate = stream.sample_rate() / 2; // get progress through wave int incr = m_incr; @@ -118,9 +117,9 @@ void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_ signal = 1.0; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, signal); + stream.put(0, sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -133,8 +132,6 @@ void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_incr = incr; m_signal = signal; } - else - buffer.fill(0); } diff --git a/src/devices/sound/cdp1863.h b/src/devices/sound/cdp1863.h index 4d6f4f295b3..15c9054f13f 100644 --- a/src/devices/sound/cdp1863.h +++ b/src/devices/sound/cdp1863.h @@ -54,7 +54,7 @@ protected: virtual void device_start() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; @@ -65,7 +65,7 @@ private: // sound state int m_oe; // output enable int m_latch; // sound latch - stream_buffer::sample_t m_signal;// current signal + sound_stream::sample_t m_signal;// current signal int m_incr; // initial wave state }; diff --git a/src/devices/sound/cdp1864.cpp b/src/devices/sound/cdp1864.cpp index 2d8acb64358..c211dc451f4 100644 --- a/src/devices/sound/cdp1864.cpp +++ b/src/devices/sound/cdp1864.cpp @@ -243,15 +243,14 @@ TIMER_CALLBACK_MEMBER(cdp1864_device::dma_tick) // our sound stream //------------------------------------------------- -void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdp1864_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t signal = m_signal; - auto &buffer = outputs[0]; + sound_stream::sample_t signal = m_signal; if (m_aoe) { double frequency = unscaled_clock() / 8 / 4 / (m_latch + 1) / 2; - int rate = buffer.sample_rate() / 2; + int rate = stream.sample_rate() / 2; /* get progress through wave */ int incr = m_incr; @@ -265,9 +264,9 @@ void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_ signal = 1.0; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, signal); + stream.put(0, sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -280,8 +279,6 @@ void cdp1864_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_incr = incr; m_signal = signal; } - else - buffer.fill(0); } diff --git a/src/devices/sound/cdp1864.h b/src/devices/sound/cdp1864.h index c1bb7b36797..09ab0f78730 100644 --- a/src/devices/sound/cdp1864.h +++ b/src/devices/sound/cdp1864.h @@ -114,7 +114,7 @@ protected: virtual void device_reset() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(int_tick); TIMER_CALLBACK_MEMBER(efx_tick); @@ -152,7 +152,7 @@ private: // sound state int m_aoe; // audio on int m_latch; // sound latch - stream_buffer::sample_t m_signal; // current signal + sound_stream::sample_t m_signal; // current signal int m_incr; // initial wave state // timers diff --git a/src/devices/sound/cdp1869.cpp b/src/devices/sound/cdp1869.cpp index c0a54adaf99..531a95a065b 100644 --- a/src/devices/sound/cdp1869.cpp +++ b/src/devices/sound/cdp1869.cpp @@ -493,33 +493,32 @@ void cdp1869_device::cdp1869_palette(palette_device &palette) const // our sound stream //------------------------------------------------- -void cdp1869_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cdp1869_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t signal = m_signal; - auto &buffer = outputs[0]; + sound_stream::sample_t signal = m_signal; if (!m_toneoff && m_toneamp) { double frequency = (clock() / 2) / (512 >> m_tonefreq) / (m_tonediv + 1); // double amplitude = m_toneamp * ((0.78*5) / 15); - int rate = buffer.sample_rate() / 2; + int rate = stream.sample_rate() / 2; /* get progress through wave */ int incr = m_incr; if (signal < 0) { - signal = -(stream_buffer::sample_t(m_toneamp) / 15.0); + signal = -(sound_stream::sample_t(m_toneamp) / 15.0); } else { - signal = stream_buffer::sample_t(m_toneamp) / 15.0; + signal = sound_stream::sample_t(m_toneamp) / 15.0; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, signal); + stream.put(0, sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -532,8 +531,6 @@ void cdp1869_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_incr = incr; m_signal = signal; } - else - buffer.fill(0); /* if (!m_wnoff) { diff --git a/src/devices/sound/cdp1869.h b/src/devices/sound/cdp1869.h index eb458ee3bd9..537e8814133 100644 --- a/src/devices/sound/cdp1869.h +++ b/src/devices/sound/cdp1869.h @@ -215,7 +215,7 @@ protected: virtual space_config_vector memory_space_config() const override; // device_sound_interface callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(prd_update); @@ -266,7 +266,7 @@ private: uint16_t m_hma; // home memory address // sound state - stream_buffer::sample_t m_signal; // current signal + sound_stream::sample_t m_signal; // current signal int m_incr; // initial wave state int m_toneoff; // tone off int m_wnoff; // white noise off diff --git a/src/devices/sound/cem3394.cpp b/src/devices/sound/cem3394.cpp index b047092e00b..d2920a333c6 100644 --- a/src/devices/sound/cem3394.cpp +++ b/src/devices/sound/cem3394.cpp @@ -296,16 +296,13 @@ double cem3394_device::filter(double input, double cutoff) // buffer in mono //------------------------------------------------- -void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cem3394_device::sound_stream_update(sound_stream &stream) { - auto &external = inputs[0]; - auto &buffer = outputs[0]; - if (m_wave_select == 0 && m_mixer_external == 0) LOGMASKED(LOG_VALUES, "%f V didn't cut it\n", m_values[WAVE_SELECT]); // loop over samples - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // get the current VCO position and step it forward double vco_position = m_vco_position; @@ -336,7 +333,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_ // compute extension input (for Bally/Sente this is the noise) if (ENABLE_EXTERNAL) - result += EXTERNAL_VOLUME * m_mixer_external * external.get(sampindex); + result += EXTERNAL_VOLUME * m_mixer_external * stream.get(0, sampindex); // compute the modulated filter frequency and apply the filter // modulation tracks the VCO triangle @@ -344,7 +341,7 @@ void cem3394_device::sound_stream_update(sound_stream &stream, std::vector<read_ result = filter(result, filter_freq); // write the sample - buffer.put(sampindex, result * m_volume); + stream.put(0, sampindex, result * m_volume); } } @@ -407,7 +404,7 @@ double cem3394_device::compute_db(double voltage) } -stream_buffer::sample_t cem3394_device::compute_db_volume(double voltage) +sound_stream::sample_t cem3394_device::compute_db_volume(double voltage) { double temp; diff --git a/src/devices/sound/cem3394.h b/src/devices/sound/cem3394.h index e086ad7bf4b..bb109dbc2a2 100644 --- a/src/devices/sound/cem3394.h +++ b/src/devices/sound/cem3394.h @@ -32,7 +32,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: // Set the voltage going to a particular parameter @@ -51,7 +51,7 @@ public: private: double compute_db(double voltage); - stream_buffer::sample_t compute_db_volume(double voltage); + sound_stream::sample_t compute_db_volume(double voltage); private: double filter(double input, double cutoff); diff --git a/src/devices/sound/cf61909.cpp b/src/devices/sound/cf61909.cpp index 77b8af0b5de..136633079b2 100644 --- a/src/devices/sound/cf61909.cpp +++ b/src/devices/sound/cf61909.cpp @@ -132,9 +132,9 @@ void cf61909_device::write(offs_t offset, u8 data) } /**************************************************************************/ -void cf61909_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cf61909_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sample = 0; @@ -156,6 +156,6 @@ void cf61909_device::sound_stream_update(sound_stream &stream, std::vector<read_ } // Jaminator patent shows 10-bit sampling, assume that's actually true - outputs[0].put_int_clamp(i, sample >> 9, 1 << 9); + stream.put_int_clamp(0, i, sample >> 9, 1 << 9); } } diff --git a/src/devices/sound/cf61909.h b/src/devices/sound/cf61909.h index 0ccc6264c0b..c1aa58d889b 100644 --- a/src/devices/sound/cf61909.h +++ b/src/devices/sound/cf61909.h @@ -29,7 +29,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void rom_bank_pre_change() override; private: diff --git a/src/devices/sound/ct1745.cpp b/src/devices/sound/ct1745.cpp index 520274dd709..1ca962d1b49 100644 --- a/src/devices/sound/ct1745.cpp +++ b/src/devices/sound/ct1745.cpp @@ -29,7 +29,7 @@ DEFINE_DEVICE_TYPE(CT1745, ct1745_mixer_device, "ct1745", "Creative Labs CT1745 ct1745_mixer_device::ct1745_mixer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CT1745, tag, owner, clock) , device_memory_interface(mconfig, *this) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_irq_status_cb(*this, 0) , m_fm(*this, finder_base::DUMMY_TAG) , m_ldac(*this, finder_base::DUMMY_TAG) diff --git a/src/devices/sound/dac.cpp b/src/devices/sound/dac.cpp index c831ab24ac4..26d70d308f3 100644 --- a/src/devices/sound/dac.cpp +++ b/src/devices/sound/dac.cpp @@ -25,11 +25,11 @@ DEFINE_DEVICE_TYPE(_dac_type, _dac_class, _dac_shortname, _dac_description) // the given number of bits to a sample value //------------------------------------------------- -stream_buffer::sample_t dac_mapper_unsigned(u32 input, u8 bits) +sound_stream::sample_t dac_mapper_unsigned(u32 input, u8 bits) { - stream_buffer::sample_t scale = 1.0 / stream_buffer::sample_t((bits > 1) ? (1 << bits) : 1); + sound_stream::sample_t scale = 1.0 / sound_stream::sample_t((bits > 1) ? (1 << bits) : 1); input &= (1 << bits) - 1; - return stream_buffer::sample_t(input) * scale; + return sound_stream::sample_t(input) * scale; } @@ -38,7 +38,7 @@ stream_buffer::sample_t dac_mapper_unsigned(u32 input, u8 bits) // value of the given number of bits to a sample value //------------------------------------------------- -stream_buffer::sample_t dac_mapper_signed(u32 input, u8 bits) +sound_stream::sample_t dac_mapper_signed(u32 input, u8 bits) { return dac_mapper_unsigned(input ^ (1 << (bits - 1)), bits); } @@ -50,7 +50,7 @@ stream_buffer::sample_t dac_mapper_signed(u32 input, u8 bits) // treated as a negative 1s complement //------------------------------------------------- -stream_buffer::sample_t dac_mapper_ones_complement(u32 input, u8 bits) +sound_stream::sample_t dac_mapper_ones_complement(u32 input, u8 bits) { // this mapping assumes symmetric reference voltages, // which is true for all existing cases @@ -65,7 +65,7 @@ stream_buffer::sample_t dac_mapper_ones_complement(u32 input, u8 bits) // dac_device_base - constructor //------------------------------------------------- -dac_device_base::dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : +dac_device_base::dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : device_t(mconfig, type, tag, owner, clock), device_sound_interface(mconfig, *this), m_stream(nullptr), @@ -91,7 +91,7 @@ void dac_device_base::device_start() m_value_map[code] = m_mapper(code, m_bits) * m_gain; // determine the number of inputs - int inputs = (m_specified_inputs_mask == 0) ? 0 : 2; + int inputs = (get_sound_requested_inputs_mask() == 0) ? 0 : 2; // large stream buffer to favour emu/sound.cpp resample quality m_stream = stream_alloc(inputs, 1, 48000 * 32); @@ -105,38 +105,33 @@ void dac_device_base::device_start() // sound_stream_update - stream updates //------------------------------------------------- -void dac_device_base::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dac_device_base::sound_stream_update(sound_stream &stream) { - auto &out = outputs[0]; - // rails are constant - if (inputs.size() == 0) + if (stream.input_count() == 0) { - out.fill(m_range_min + m_curval * (m_range_max - m_range_min)); + stream.fill(0, m_range_min + m_curval * (m_range_max - m_range_min)); return; } - auto &hi = inputs[DAC_INPUT_RANGE_HI]; - auto &lo = inputs[DAC_INPUT_RANGE_LO]; - // constant lo, streaming hi - if (!BIT(m_specified_inputs_mask, DAC_INPUT_RANGE_LO)) + if (!BIT(get_sound_requested_inputs_mask(), DAC_INPUT_RANGE_LO)) { - for (int sampindex = 0; sampindex < out.samples(); sampindex++) - out.put(sampindex, m_range_min + m_curval * (hi.get(sampindex) - m_range_min)); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, m_range_min + m_curval * (stream.get(DAC_INPUT_RANGE_HI, sampindex) - m_range_min)); } // constant hi, streaming lo - else if (!BIT(m_specified_inputs_mask, DAC_INPUT_RANGE_HI)) + else if (!BIT(get_sound_requested_inputs_mask(), DAC_INPUT_RANGE_HI)) { - for (int sampindex = 0; sampindex < out.samples(); sampindex++) - out.put(sampindex, lo.get(sampindex) + m_curval * (m_range_max - lo.get(sampindex))); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, stream.get(DAC_INPUT_RANGE_LO, sampindex) + m_curval * (m_range_max - stream.get(DAC_INPUT_RANGE_LO, sampindex))); } // both streams provided else { - for (int sampindex = 0; sampindex < out.samples(); sampindex++) - out.put(sampindex, lo.get(sampindex) + m_curval * (hi.get(sampindex) - lo.get(sampindex))); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, stream.get(DAC_INPUT_RANGE_LO, sampindex) + m_curval * (stream.get(DAC_INPUT_RANGE_HI, sampindex) - stream.get(DAC_INPUT_RANGE_LO, sampindex))); } } diff --git a/src/devices/sound/dac.h b/src/devices/sound/dac.h index 58fa5cd7864..1465ee94a2e 100644 --- a/src/devices/sound/dac.h +++ b/src/devices/sound/dac.h @@ -33,17 +33,17 @@ // TYPE DEFINITIONS //************************************************************************** -constexpr stream_buffer::sample_t dac_gain_r2r = 1.0; -constexpr stream_buffer::sample_t dac_gain_bw = 2.0; +constexpr sound_stream::sample_t dac_gain_r2r = 1.0; +constexpr sound_stream::sample_t dac_gain_bw = 2.0; // ======================> dac_mapper_callback -using dac_mapper_callback = stream_buffer::sample_t (*)(u32 input, u8 bits); +using dac_mapper_callback = sound_stream::sample_t (*)(u32 input, u8 bits); -stream_buffer::sample_t dac_mapper_unsigned(u32 input, u8 bits); -stream_buffer::sample_t dac_mapper_signed(u32 input, u8 bits); -stream_buffer::sample_t dac_mapper_ones_complement(u32 input, u8 bits); +sound_stream::sample_t dac_mapper_unsigned(u32 input, u8 bits); +sound_stream::sample_t dac_mapper_signed(u32 input, u8 bits); +sound_stream::sample_t dac_mapper_ones_complement(u32 input, u8 bits); // ======================> dac_bit_interface @@ -82,13 +82,13 @@ class dac_device_base : public device_t, public device_sound_interface { protected: // constructor - dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain); + dac_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain); // device startup virtual void device_start() override ATTR_COLD; // stream generation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // set the current value void set_value(u32 value) @@ -100,26 +100,26 @@ protected: public: // configuration: default output range is -1..1 for all cases except // for 1-bit DACs, which default to 0..1 - dac_device_base &set_output_range(stream_buffer::sample_t range_min, stream_buffer::sample_t range_max) + dac_device_base &set_output_range(sound_stream::sample_t range_min, sound_stream::sample_t range_max) { m_range_min = range_min; m_range_max = range_max; return *this; } - dac_device_base &set_output_range(stream_buffer::sample_t vref) { return set_output_range(-vref, vref); } + dac_device_base &set_output_range(sound_stream::sample_t vref) { return set_output_range(-vref, vref); } private: // internal state sound_stream *m_stream; - stream_buffer::sample_t m_curval; - std::vector<stream_buffer::sample_t> m_value_map; + sound_stream::sample_t m_curval; + std::vector<sound_stream::sample_t> m_value_map; // configuration state u8 const m_bits; dac_mapper_callback const m_mapper; - stream_buffer::sample_t const m_gain; - stream_buffer::sample_t m_range_min; - stream_buffer::sample_t m_range_max; + sound_stream::sample_t const m_gain; + sound_stream::sample_t m_range_min; + sound_stream::sample_t m_range_max; }; @@ -128,7 +128,7 @@ private: class dac_bit_device_base : public dac_device_base, public dac_bit_interface { protected: - dac_bit_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : + dac_bit_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : dac_device_base(mconfig, type, tag, owner, clock, bits, mapper, gain) { } @@ -144,7 +144,7 @@ public: class dac_byte_device_base : public dac_device_base, public dac_byte_interface { protected: - dac_byte_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : + dac_byte_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : dac_device_base(mconfig, type, tag, owner, clock, bits, mapper, gain) { } @@ -160,7 +160,7 @@ public: class dac_word_device_base : public dac_device_base, public dac_word_interface { protected: - dac_word_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, stream_buffer::sample_t gain) : + dac_word_device_base(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 clock, u8 bits, dac_mapper_callback mapper, sound_stream::sample_t gain) : dac_device_base(mconfig, type, tag, owner, clock, bits, mapper, gain) { } diff --git a/src/devices/sound/dac3350a.cpp b/src/devices/sound/dac3350a.cpp index 77e91650a64..91e0593c358 100644 --- a/src/devices/sound/dac3350a.cpp +++ b/src/devices/sound/dac3350a.cpp @@ -320,13 +320,13 @@ float dac3350a_device::calculate_volume(int val) return powf(10.0, db / 20.0); } -void dac3350a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dac3350a_device::sound_stream_update(sound_stream &stream) { - const stream_buffer::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; + const sound_stream::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; - for (int channel = 0; channel < 2 && channel < outputs.size(); channel++) + for (int channel = 0; channel < 2 && channel < stream.output_count(); channel++) { - for (int sampindex = 0; sampindex < outputs[channel].samples(); sampindex++) - outputs[channel].put(sampindex, inputs[channel].get(sampindex) * enable_scale * m_volume[channel]); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(channel, sampindex, stream.get(channel, sampindex) * enable_scale * m_volume[channel]); } } diff --git a/src/devices/sound/dac3350a.h b/src/devices/sound/dac3350a.h index f1a284e1cec..920c5e73f92 100644 --- a/src/devices/sound/dac3350a.h +++ b/src/devices/sound/dac3350a.h @@ -17,7 +17,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void i2c_device_handle_write(); diff --git a/src/devices/sound/dac76.cpp b/src/devices/sound/dac76.cpp index 6e2065dd2cc..d5f6939edd5 100644 --- a/src/devices/sound/dac76.cpp +++ b/src/devices/sound/dac76.cpp @@ -103,7 +103,7 @@ void dac76_device::device_reset() // our sound stream //------------------------------------------------- -void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dac76_device::sound_stream_update(sound_stream &stream) { // get current output level int step_size = (2 << m_chord); @@ -113,7 +113,7 @@ void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_st vout *= (m_sb ? +1 : -1); // range is 0-8031, normalize to 0-1 range - stream_buffer::sample_t y = stream_buffer::sample_t(vout) * (1.0 / 8031.0); + sound_stream::sample_t y = sound_stream::sample_t(vout) * (1.0 / 8031.0); if (m_voltage_output) { @@ -121,16 +121,14 @@ void dac76_device::sound_stream_update(sound_stream &stream, std::vector<read_st y *= ((y >= 0) ? m_r_pos : m_r_neg) * FULL_SCALE_MULT; } - write_stream_view &out = outputs[0]; if (m_streaming_iref) { - const read_stream_view &iref = inputs[0]; - const int n = out.samples(); + const int n = stream.samples(); for (int i = 0; i < n; ++i) - out.put(i, iref.get(i) * y); + stream.put(0, i, stream.get(0, i) * y); } else { - out.fill(m_fixed_iref * y); + stream.fill(0, m_fixed_iref * y); } } diff --git a/src/devices/sound/dac76.h b/src/devices/sound/dac76.h index 462355b0b8f..5f4edbd29f5 100644 --- a/src/devices/sound/dac76.h +++ b/src/devices/sound/dac76.h @@ -92,7 +92,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr int m_level[8] = { 0, 33, 99, 231, 495, 1023, 2079, 4191 }; diff --git a/src/devices/sound/digitalk.cpp b/src/devices/sound/digitalk.cpp index d41c267e798..ebe7fbb14da 100644 --- a/src/devices/sound/digitalk.cpp +++ b/src/devices/sound/digitalk.cpp @@ -544,28 +544,27 @@ void digitalker_device::digitalker_step() // sound_stream_update - handle a stream update //------------------------------------------------- -void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void digitalker_device::sound_stream_update(sound_stream &stream) { - auto &sout = outputs[0]; int cpos = 0; - while(cpos != sout.samples()) { + while(cpos != stream.samples()) { if(m_zero_count == 0 && m_dac_index == 128) digitalker_step(); if(m_zero_count) { - int n = sout.samples() - cpos; + int n = stream.samples() - cpos; if(n > m_zero_count) n = m_zero_count; - sout.fill(0, cpos, n); + stream.fill(0, 0, cpos, n); cpos += n; m_zero_count -= n; } else if(m_dac_index != 128) { - while(cpos != sout.samples() && m_dac_index != 128) { + while(cpos != stream.samples() && m_dac_index != 128) { s32 v = m_dac[m_dac_index]; int pp = m_pitch_pos; - while(cpos != sout.samples() && pp != m_pitch) { - sout.put_int(cpos++, v, 32768); + while(cpos != stream.samples() && pp != m_pitch) { + stream.put_int(0, cpos++, v, 32768); pp++; } if(pp == m_pitch) { @@ -575,9 +574,6 @@ void digitalker_device::sound_stream_update(sound_stream &stream, std::vector<re m_pitch_pos = pp; } - } else { - sout.fill(0, cpos); - break; } } } diff --git a/src/devices/sound/digitalk.h b/src/devices/sound/digitalk.h index 053c9a60018..a169a9bebe8 100644 --- a/src/devices/sound/digitalk.h +++ b/src/devices/sound/digitalk.h @@ -29,7 +29,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void digitalker_write(uint8_t *adr, uint8_t vol, int8_t dac); diff --git a/src/devices/sound/disc_cls.h b/src/devices/sound/disc_cls.h index 6bd94631bde..2e301099b04 100644 --- a/src/devices/sound/disc_cls.h +++ b/src/devices/sound/disc_cls.h @@ -120,13 +120,14 @@ public: /* Add gain to the output and put into the buffers */ /* Clipping will be handled by the main sound system */ double val = DISCRETE_INPUT(0) * DISCRETE_INPUT(1); - m_outview->put(m_outview_sample++, val * (1.0 / 32768.0)); + m_stream->put(m_stream_output, m_outview_sample++, val * (1.0 / 32768.0)); } virtual int max_output() override { return 0; } - virtual void set_output_ptr(write_stream_view &view) override { m_outview = &view; m_outview_sample = 0; } + virtual void set_output_ptr(sound_stream &stream, int output) override { m_stream = &stream; m_stream_output = output; m_outview_sample = 0; } private: - write_stream_view *m_outview = nullptr; - u32 m_outview_sample = 0U; + sound_stream *m_stream = nullptr; + int m_stream_output = 0; + u32 m_outview_sample = 0U; }; DISCRETE_CLASS(dso_csvlog, 0, @@ -233,10 +234,9 @@ public: //protected: uint32_t m_stream_in_number = 0; - read_stream_view const *m_inview = nullptr; /* current in ptr for stream */ uint32_t m_inview_sample = 0; private: - void stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs); + void stream_generate(sound_stream &stream); double m_gain = 0.0; /* node gain */ double m_offset = 0.0; /* node offset */ diff --git a/src/devices/sound/disc_inp.hxx b/src/devices/sound/disc_inp.hxx index 1c6c9a6dba5..51519169767 100644 --- a/src/devices/sound/disc_inp.hxx +++ b/src/devices/sound/disc_inp.hxx @@ -242,16 +242,16 @@ void DISCRETE_CLASS_FUNC(dss_input_pulse, input_write)(int sub_node, uint8_t dat #define DSS_INPUT_STREAM__GAIN DISCRETE_INPUT(1) #define DSS_INPUT_STREAM__OFFSET DISCRETE_INPUT(2) -void discrete_dss_input_stream_node::stream_generate(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void discrete_dss_input_stream_node::stream_generate(sound_stream &stream) { - outputs[0].fill(m_data * (1.0 / 32768.0)); + stream.fill(0, m_data * (1.0 / 32768.0)); } DISCRETE_STEP(dss_input_stream) { /* the context pointer is set to point to the current input stream data in discrete_stream_update */ - if (EXPECTED(m_inview)) + if (EXPECTED(m_buffer_stream)) { - set_output(0, m_inview->get(m_inview_sample) * 32768.0 * m_gain + m_offset); + set_output(0, m_buffer_stream->get(m_stream_in_number, m_inview_sample) * 32768.0 * m_gain + m_offset); m_inview_sample++; } else @@ -260,7 +260,6 @@ DISCRETE_STEP(dss_input_stream) DISCRETE_RESET(dss_input_stream) { - m_inview = nullptr; m_data = 0; } @@ -300,7 +299,6 @@ DISCRETE_START(dss_input_stream) m_stream_in_number = DSS_INPUT_STREAM__STREAM; m_gain = DSS_INPUT_STREAM__GAIN; m_offset = DSS_INPUT_STREAM__OFFSET; - m_inview = nullptr; m_is_buffered = is_buffered(); m_buffer_stream = nullptr; @@ -316,6 +314,7 @@ void DISCRETE_CLASS_NAME(dss_input_stream)::stream_start(void) m_buffer_stream = m_device->machine().sound().stream_alloc(*snd_device, 0, 1, this->sample_rate(), stream_update_delegate(&discrete_dss_input_stream_node::stream_generate,this), STREAM_DEFAULT_FLAGS); - snd_device->get_stream()->set_input(m_stream_in_number, m_buffer_stream); + // WTF? + // snd_device->get_stream()->set_input(m_stream_in_number, m_buffer_stream); } } diff --git a/src/devices/sound/discrete.cpp b/src/devices/sound/discrete.cpp index ad5b89c8bd9..1a8b16602ac 100644 --- a/src/devices/sound/discrete.cpp +++ b/src/devices/sound/discrete.cpp @@ -1050,26 +1050,25 @@ void discrete_device::process(int samples) // our sound stream //------------------------------------------------- -void discrete_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void discrete_sound_device::sound_stream_update(sound_stream &stream) { int outputnum = 0; /* Setup any output streams */ for (discrete_sound_output_interface *node : m_output_list) { - node->set_output_ptr(outputs[outputnum]); + node->set_output_ptr(stream, outputnum); outputnum++; } /* Setup any input streams */ for (discrete_dss_input_stream_node *node : m_input_stream_list) { - node->m_inview = &inputs[node->m_stream_in_number]; node->m_inview_sample = 0; } /* just process it */ - process(outputs[0].samples()); + process(stream.samples()); } //------------------------------------------------- diff --git a/src/devices/sound/discrete.h b/src/devices/sound/discrete.h index 5a850ffc340..aa90b83b3f9 100644 --- a/src/devices/sound/discrete.h +++ b/src/devices/sound/discrete.h @@ -4164,7 +4164,7 @@ class discrete_sound_output_interface public: virtual ~discrete_sound_output_interface() { } - virtual void set_output_ptr(write_stream_view &view) = 0; + virtual void set_output_ptr(sound_stream &stream, int output) = 0; }; //************************************************************************** @@ -4305,7 +4305,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: typedef std::vector<discrete_dss_input_stream_node *> istream_node_list_t; diff --git a/src/devices/sound/dmadac.cpp b/src/devices/sound/dmadac.cpp index ae2ebce61ad..e1e937069b6 100644 --- a/src/devices/sound/dmadac.cpp +++ b/src/devices/sound/dmadac.cpp @@ -158,7 +158,7 @@ void dmadac_set_volume(dmadac_sound_device **devlist, uint8_t num_channels, uint void dmadac_sound_device::set_volume(uint16_t volume) { m_channel->update(); - m_volume = stream_buffer::sample_t(volume) * (1.0 / 256.0); + m_volume = sound_stream::sample_t(volume) * (1.0 / 256.0); } DEFINE_DEVICE_TYPE(DMADAC, dmadac_sound_device, "dmadac", "DMA-driven DAC") @@ -178,23 +178,19 @@ dmadac_sound_device::dmadac_sound_device(const machine_config &mconfig, const ch // sound_stream_update - handle a stream update //------------------------------------------------- -void dmadac_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dmadac_sound_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; uint32_t curout = m_bufout; uint32_t curin = m_bufin; - /* feed as much as we can */ + /* feed as much as we can, leave the rest as silence */ int sampindex; - for (sampindex = 0; curout != curin && sampindex < output.samples(); sampindex++) + for (sampindex = 0; curout != curin && sampindex < stream.samples(); sampindex++) { - output.put(sampindex, stream_buffer::sample_t(m_buffer[curout]) * m_volume); + stream.put(0, sampindex, sound_stream::sample_t(m_buffer[curout]) * m_volume); curout = (curout + 1) % BUFFER_SIZE; } - /* fill the rest with silence */ - output.fill(0, sampindex); - /* save the new output pointer */ m_bufout = curout; } diff --git a/src/devices/sound/dmadac.h b/src/devices/sound/dmadac.h index d221a7575e4..c05e967b59a 100644 --- a/src/devices/sound/dmadac.h +++ b/src/devices/sound/dmadac.h @@ -24,7 +24,7 @@ public: template <typename T> void transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, T* data) { int j; - constexpr stream_buffer::sample_t sample_scale = 1.0 / double(std::numeric_limits<T>::max()); + constexpr sound_stream::sample_t sample_scale = 1.0 / double(std::numeric_limits<T>::max()); if (m_enabled) { @@ -35,7 +35,7 @@ public: /* copy the data */ for (j = 0; j < total_frames && curin != maxin; j++) { - m_buffer[curin] = stream_buffer::sample_t(*src) * sample_scale; + m_buffer[curin] = sound_stream::sample_t(*src) * sample_scale; curin = (curin + 1) % BUFFER_SIZE; src += frame_spacing; } @@ -56,18 +56,18 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state /* sound stream and buffers */ sound_stream * m_channel; - std::vector<stream_buffer::sample_t> m_buffer; + std::vector<sound_stream::sample_t> m_buffer; uint32_t m_bufin; uint32_t m_bufout; /* per-channel parameters */ - stream_buffer::sample_t m_volume; + sound_stream::sample_t m_volume; uint8_t m_enabled; static constexpr int BUFFER_SIZE = 32768; diff --git a/src/devices/sound/dspv.cpp b/src/devices/sound/dspv.cpp index 9877cee3fb1..9ced7ba9ceb 100644 --- a/src/devices/sound/dspv.cpp +++ b/src/devices/sound/dspv.cpp @@ -113,9 +113,8 @@ void dspv_device::snd_w(offs_t offset, u16 data) logerror("w %02x, %04x %s\n", offset, data, machine().describe_context()); } -void dspv_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dspv_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } void dspv_device::device_start() diff --git a/src/devices/sound/dspv.h b/src/devices/sound/dspv.h index defc5343b32..ec6dab50c46 100644 --- a/src/devices/sound/dspv.h +++ b/src/devices/sound/dspv.h @@ -28,7 +28,7 @@ protected: virtual void state_export(const device_state_entry &entry) override; virtual void state_string_export(const device_state_entry &entry, std::string &str) const override; virtual std::unique_ptr<util::disasm_interface> create_disassembler() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: address_space_config m_prg1_config, m_prg2_config, m_data_config; diff --git a/src/devices/sound/es1373.cpp b/src/devices/sound/es1373.cpp index 5ce753da4a7..c3b88ecac49 100644 --- a/src/devices/sound/es1373.cpp +++ b/src/devices/sound/es1373.cpp @@ -80,8 +80,7 @@ void es1373_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } DEFINE_DEVICE_TYPE(ES1373, es1373_device, "es1373", "Creative Labs Ensoniq AudioPCI97 ES1373") @@ -211,24 +210,21 @@ TIMER_CALLBACK_MEMBER(es1373_device::delayed_stream_update) // sound_stream_update - handle update requests for // our sound stream //------------------------------------------------- -void es1373_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void es1373_device::sound_stream_update(sound_stream &stream) { if (m_dac1.enable) { LOGMASKED(LOG_UNIMPL, "%s: sound_stream_update DAC1 not implemented yet\n", tag()); } if (m_dac2.enable) { - send_audio_out(m_dac2, ICSTATUS_DAC2_INT_MASK, outputs[0], outputs[1]); - } else { - outputs[0].fill(0); - outputs[1].fill(0); + send_audio_out(m_dac2, ICSTATUS_DAC2_INT_MASK, stream); } if (m_adc.enable) { if (m_adc.format!=SCTRL_16BIT_MONO) { LOGMASKED(LOG_UNIMPL, "%s: sound_stream_update Only SCTRL_16BIT_MONO recorded supported\n", tag()); } else { - for (int i=0; i<outputs[0].samples(); i++) { + for (int i=0; i<stream.samples(); i++) { if (m_adc.buf_count<=m_adc.buf_size) { LOGMASKED(LOG_OTHER, "%s: ADC buf_count: %i buf_size: %i buf_rptr: %i buf_wptr: %i\n", machine().describe_context(), m_adc.buf_count, m_adc.buf_size, m_adc.buf_rptr, m_adc.buf_wptr); @@ -270,7 +266,7 @@ void es1373_device::sound_stream_update(sound_stream &stream, std::vector<read_s //------------------------------------------------- // send_audio_out - Sends channel audio output data //------------------------------------------------- -void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_stream_view &outL, write_stream_view &outR) +void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, sound_stream &stream) { // Only transfer PCI data if bus mastering is enabled // Fill initial half buffer @@ -281,7 +277,7 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_st //uint32_t sample_size = calc_size(chan.format); // Send data to sound stream bool buf_row_done; - for (int i=0; i<outL.samples(); i++) { + for (int i=0; i<stream.samples(); i++) { buf_row_done = false; int16_t lsamp = 0, rsamp = 0; if (chan.buf_count<=chan.buf_size) { @@ -293,7 +289,7 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_st } if (i == 0) LOGMASKED(LOG_OTHER, "%s: chan: %X samples: %i buf_count: %X buf_size: %X buf_rptr: %X buf_wptr: %X\n", - machine().describe_context(), chan.number, outL.samples(), chan.buf_count, chan.buf_size, chan.buf_rptr, chan.buf_wptr); + machine().describe_context(), chan.number, stream.samples(), chan.buf_count, chan.buf_size, chan.buf_rptr, chan.buf_wptr); // Buffer is 4 bytes per location, need to switch on sample mode switch (chan.format) { case SCTRL_8BIT_MONO: @@ -340,8 +336,8 @@ void es1373_device::send_audio_out(chan_info& chan, uint32_t intr_mask, write_st chan.buf_rptr -= 0x10; } } - outL.put_int(i, lsamp, 32768); - outR.put_int(i, rsamp, 32768); + stream.put_int(0, i, lsamp, 32768); + stream.put_int(1, i, rsamp, 32768); } } diff --git a/src/devices/sound/es1373.h b/src/devices/sound/es1373.h index 054a62901a3..b1c7739dde7 100644 --- a/src/devices/sound/es1373.h +++ b/src/devices/sound/es1373.h @@ -26,7 +26,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual void device_post_load() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update); @@ -52,7 +52,7 @@ private: void transfer_pci_audio(chan_info& chan, int type); uint32_t calc_size(const uint8_t &format); - void send_audio_out(chan_info& chan, uint32_t intr_mask, write_stream_view &outL, write_stream_view &outR); + void send_audio_out(chan_info& chan, uint32_t intr_mask, sound_stream &stream); emu_timer *m_timer; address_space *m_memory_space; diff --git a/src/devices/sound/es5503.cpp b/src/devices/sound/es5503.cpp index fc23656d36b..d4d05545852 100644 --- a/src/devices/sound/es5503.cpp +++ b/src/devices/sound/es5503.cpp @@ -152,12 +152,12 @@ void es5503_device::halt_osc(int onum, int type, uint32_t *accumulator, int ress m_irq_func(1); } } -void es5503_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void es5503_device::sound_stream_update(sound_stream &stream) { int32_t *mixp; int osc, snum, i; uint32_t ramptr; - int samples = outputs[0].samples(); + int samples = stream.samples(); assert(samples < (44100/50)); std::fill_n(&m_mix_buffer[0], samples*output_channels, 0); @@ -257,9 +257,9 @@ void es5503_device::sound_stream_update(sound_stream &stream, std::vector<read_s mixp = &m_mix_buffer[0]; for (int chan = 0; chan < output_channels; chan++) { - for (i = 0; i < outputs[chan].samples(); i++) + for (i = 0; i < stream.samples(); i++) { - outputs[chan].put_int(i, *mixp++, 32768*8); + stream.put_int(chan, i, *mixp++, 32768*8); } } } diff --git a/src/devices/sound/es5503.h b/src/devices/sound/es5503.h index ef22d476b42..e04d5018409 100644 --- a/src/devices/sound/es5503.h +++ b/src/devices/sound/es5503.h @@ -35,7 +35,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/es5506.cpp b/src/devices/sound/es5506.cpp index bc7412619f2..455c991b94b 100644 --- a/src/devices/sound/es5506.cpp +++ b/src/devices/sound/es5506.cpp @@ -1009,10 +1009,10 @@ inline void es550x_device::generate_irq(es550x_voice *voice, int v) ***********************************************************************************************/ -void es5506_device::generate_samples(std::vector<write_stream_view> &outputs) +void es5506_device::generate_samples(sound_stream &stream) { // loop while we still have samples to generate - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // loop over voices s32 cursample[12] = { 0 }; @@ -1038,15 +1038,15 @@ void es5506_device::generate_samples(std::vector<write_stream_view> &outputs) generate_irq(voice, v); } - for (int c = 0; c < outputs.size(); c++) - outputs[c].put_int(sampindex, cursample[c], 32768); + for (int c = 0; c < stream.output_count(); c++) + stream.put_int(c, sampindex, cursample[c], 32768); } } -void es5505_device::generate_samples(std::vector<write_stream_view> &outputs) +void es5505_device::generate_samples(sound_stream &stream) { // loop while we still have samples to generate - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // loop over voices s32 cursample[12] = { 0 }; @@ -1076,8 +1076,8 @@ void es5505_device::generate_samples(std::vector<write_stream_view> &outputs) generate_irq(voice, v); } - for (int c = 0; c < outputs.size(); c++) - outputs[c].put_int(sampindex, cursample[c], 32768); + for (int c = 0; c < stream.output_count(); c++) + stream.put_int(c, sampindex, cursample[c], 32768); } } @@ -2091,7 +2091,7 @@ u16 es5505_device::read(offs_t offset) // sound_stream_update - handle a stream update //------------------------------------------------- -void es550x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void es550x_device::sound_stream_update(sound_stream &stream) { #if ES5506_MAKE_WAVS // start the logging once we have a sample rate @@ -2103,7 +2103,7 @@ void es550x_device::sound_stream_update(sound_stream &stream, std::vector<read_s #endif // loop until all samples are output - generate_samples(outputs); + generate_samples(stream); #if ES5506_MAKE_WAVS // log the raw data diff --git a/src/devices/sound/es5506.h b/src/devices/sound/es5506.h index cb4279165af..372849f0ddb 100644 --- a/src/devices/sound/es5506.h +++ b/src/devices/sound/es5506.h @@ -84,7 +84,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void update_irq_state(); void update_internal_irq_state(); @@ -114,7 +114,7 @@ protected: void generate_ulaw(es550x_voice *voice, s32 *dest); void generate_pcm(es550x_voice *voice, s32 *dest); inline void generate_irq(es550x_voice *voice, int v); - virtual void generate_samples(std::vector<write_stream_view> &outputs) {} + virtual void generate_samples(sound_stream &stream) {} inline void update_index(es550x_voice *voice) { m_voice_index = voice->index; } virtual inline u16 read_sample(es550x_voice *voice, offs_t addr) { return 0; } @@ -189,7 +189,7 @@ protected: virtual void update_envelopes(es550x_voice *voice) override; virtual void check_for_end_forward(es550x_voice *voice, u64 &accum) override; virtual void check_for_end_reverse(es550x_voice *voice, u64 &accum) override; - virtual void generate_samples(std::vector<write_stream_view> &outputs) override; + virtual void generate_samples(sound_stream &stream) override; virtual inline u16 read_sample(es550x_voice *voice, offs_t addr) override { update_index(voice); return m_cache[get_bank(voice->control)].read_word(addr); } @@ -243,7 +243,7 @@ protected: virtual void update_envelopes(es550x_voice *voice) override; virtual void check_for_end_forward(es550x_voice *voice, u64 &accum) override; virtual void check_for_end_reverse(es550x_voice *voice, u64 &accum) override; - virtual void generate_samples(std::vector<write_stream_view> &outputs) override; + virtual void generate_samples(sound_stream &stream) override; virtual inline u16 read_sample(es550x_voice *voice, offs_t addr) override { update_index(voice); return m_cache[get_bank(voice->control)].read_word(addr); } diff --git a/src/devices/sound/esqpump.cpp b/src/devices/sound/esqpump.cpp index af1a59db799..cda48b68eb0 100644 --- a/src/devices/sound/esqpump.cpp +++ b/src/devices/sound/esqpump.cpp @@ -53,26 +53,22 @@ void esq_5505_5510_pump_device::device_clock_changed() m_stream->set_sample_rate(clock()); } -void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream) { - sound_assert(outputs[0].samples() == 1); - - auto &left = outputs[0]; - auto &right = outputs[1]; #define SAMPLE_SHIFT 4 - constexpr stream_buffer::sample_t input_scale = 32768.0 / (1 << SAMPLE_SHIFT); + constexpr sound_stream::sample_t input_scale = 32768.0 / (1 << SAMPLE_SHIFT); // anything for the 'aux' output? - stream_buffer::sample_t l = inputs[0].get(0) * (1.0 / (1 << SAMPLE_SHIFT)); - stream_buffer::sample_t r = inputs[1].get(0) * (1.0 / (1 << SAMPLE_SHIFT)); + sound_stream::sample_t l = stream.get(0, 0) * (1.0 / (1 << SAMPLE_SHIFT)); + sound_stream::sample_t r = stream.get(1, 0) * (1.0 / (1 << SAMPLE_SHIFT)); // push the samples into the ESP - m_esp->ser_w(0, s32(inputs[2].get(0) * input_scale)); - m_esp->ser_w(1, s32(inputs[3].get(0) * input_scale)); - m_esp->ser_w(2, s32(inputs[4].get(0) * input_scale)); - m_esp->ser_w(3, s32(inputs[5].get(0) * input_scale)); - m_esp->ser_w(4, s32(inputs[6].get(0) * input_scale)); - m_esp->ser_w(5, s32(inputs[7].get(0) * input_scale)); + m_esp->ser_w(0, s32(stream.get(2, 0) * input_scale)); + m_esp->ser_w(1, s32(stream.get(3, 0) * input_scale)); + m_esp->ser_w(2, s32(stream.get(4, 0) * input_scale)); + m_esp->ser_w(3, s32(stream.get(5, 0) * input_scale)); + m_esp->ser_w(4, s32(stream.get(6, 0) * input_scale)); + m_esp->ser_w(5, s32(stream.get(7, 0) * input_scale)); #if PUMP_FAKE_ESP_PROCESSING m_esp->ser_w(6, m_esp->ser_r(0) + m_esp->ser_r(2) + m_esp->ser_r(4)); @@ -88,16 +84,16 @@ void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, std::v #endif // read the processed result from the ESP and add to the saved AUX data - stream_buffer::sample_t ll = stream_buffer::sample_t(m_esp->ser_r(6)) * (1.0 / 32768.0); - stream_buffer::sample_t rr = stream_buffer::sample_t(m_esp->ser_r(7)) * (1.0 / 32768.0); + sound_stream::sample_t ll = sound_stream::sample_t(m_esp->ser_r(6)) * (1.0 / 32768.0); + sound_stream::sample_t rr = sound_stream::sample_t(m_esp->ser_r(7)) * (1.0 / 32768.0); l += ll; r += rr; #if !PUMP_FAKE_ESP_PROCESSING && PUMP_REPLACE_ESP_PROGRAM // if we're processing the fake program through the ESP, the result should just be that of adding the inputs - stream_buffer::sample_t el = (inputs[2].get(0)) + (inputs[4].get(0)) + (inputs[6].get(0)); - stream_buffer::sample_t er = (inputs[3].get(0)) + (inputs[5].get(0)) + (inputs[7].get(0)); - stream_buffer::sample_t e_next = el + er; + sound_stream::sample_t el = (stream.get(2, 0)) + (stream.get(4, 0)) + (stream.get(6, 0)); + sound_stream::sample_t er = (stream.get(3, 0)) + (stream.get(5, 0)) + (stream.get(7, 0)); + sound_stream::sample_t e_next = el + er; e[(ei + 0x1d0f) % 0x4000] = e_next; if (fabs(l - e[ei]) > 1e-5) { @@ -107,8 +103,8 @@ void esq_5505_5510_pump_device::sound_stream_update(sound_stream &stream, std::v #endif // write the combined data to the output - left.put(0, l); - right.put(0, r); + stream.put(0, 0, l); + stream.put(1, 0, r); #if PUMP_DETECT_SILENCE if (left.get(0) == 0 && right.get(0) == 0) { diff --git a/src/devices/sound/esqpump.h b/src/devices/sound/esqpump.h index dfbfe477770..e6257c1c977 100644 --- a/src/devices/sound/esqpump.h +++ b/src/devices/sound/esqpump.h @@ -73,7 +73,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state: @@ -103,7 +103,7 @@ private: #endif #if !PUMP_FAKE_ESP_PROCESSING && PUMP_REPLACE_ESP_PROGRAM - std::vector<stream_buffer::sample_t> e; + std::vector<sound_stream::sample_t> e; int ei; #endif }; diff --git a/src/devices/sound/flt_biquad.cpp b/src/devices/sound/flt_biquad.cpp index de6bfe63462..6960f48c14b 100644 --- a/src/devices/sound/flt_biquad.cpp +++ b/src/devices/sound/flt_biquad.cpp @@ -474,22 +474,19 @@ void filter_biquad_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_biquad_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void filter_biquad_device::sound_stream_update(sound_stream &stream) { - auto &src = inputs[0]; - auto &dst = outputs[0]; - - if (m_last_sample_rate != m_stream->sample_rate()) + if (m_last_sample_rate != stream.sample_rate()) { recalc(); - m_last_sample_rate = m_stream->sample_rate(); + m_last_sample_rate = stream.sample_rate(); } - for (int sampindex = 0; sampindex < dst.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - m_input = src.get(sampindex); + m_input = stream.get(0, sampindex); step(); - dst.put(sampindex, m_output); + stream.put(0, sampindex, m_output); } } diff --git a/src/devices/sound/flt_biquad.h b/src/devices/sound/flt_biquad.h index ad58a91de79..6f70a91280d 100644 --- a/src/devices/sound/flt_biquad.h +++ b/src/devices/sound/flt_biquad.h @@ -87,7 +87,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void recalc(); @@ -100,9 +100,9 @@ private: double m_q; double m_gain; - stream_buffer::sample_t m_input; + sound_stream::sample_t m_input; double m_w0, m_w1, m_w2; /* w[k], w[k-1], w[k-2], current and previous intermediate values */ - stream_buffer::sample_t m_output; + sound_stream::sample_t m_output; double m_a1, m_a2; /* digital filter coefficients, denominator */ double m_b0, m_b1, m_b2; /* digital filter coefficients, numerator */ }; diff --git a/src/devices/sound/flt_rc.cpp b/src/devices/sound/flt_rc.cpp index 489cb01fb07..2a14aaabbd3 100644 --- a/src/devices/sound/flt_rc.cpp +++ b/src/devices/sound/flt_rc.cpp @@ -55,34 +55,32 @@ void filter_rc_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_rc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void filter_rc_device::sound_stream_update(sound_stream &stream) { - auto &src = inputs[0]; - auto &dst = outputs[0]; - stream_buffer::sample_t memory = m_memory; + sound_stream::sample_t memory = m_memory; - if (m_last_sample_rate != m_stream->sample_rate()) + if (m_last_sample_rate != stream.sample_rate()) { recalc(); - m_last_sample_rate = m_stream->sample_rate(); + m_last_sample_rate = stream.sample_rate(); } switch (m_type) { case LOWPASS_3R: case LOWPASS: - for (int sampindex = 0; sampindex < dst.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - memory += (src.get(sampindex) - memory) * m_k; - dst.put(sampindex, memory); + memory += (stream.get(0, sampindex) - memory) * m_k; + stream.put(0, sampindex, memory); } break; case HIGHPASS: case AC: - for (int sampindex = 0; sampindex < dst.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - dst.put(sampindex, src.get(sampindex) - memory); - memory += (src.get(sampindex) - memory) * m_k; + stream.put(0, sampindex, stream.get(0, sampindex) - memory); + memory += (stream.get(0, sampindex) - memory) * m_k; } break; } diff --git a/src/devices/sound/flt_rc.h b/src/devices/sound/flt_rc.h index 9230da69a49..daabe4c11c7 100644 --- a/src/devices/sound/flt_rc.h +++ b/src/devices/sound/flt_rc.h @@ -110,15 +110,15 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void recalc(); private: sound_stream* m_stream; - stream_buffer::sample_t m_k; - stream_buffer::sample_t m_memory; + sound_stream::sample_t m_k; + sound_stream::sample_t m_memory; int m_type; int m_last_sample_rate; double m_R1; diff --git a/src/devices/sound/flt_vol.cpp b/src/devices/sound/flt_vol.cpp index d5d92209cac..c3f8b5f0b2e 100644 --- a/src/devices/sound/flt_vol.cpp +++ b/src/devices/sound/flt_vol.cpp @@ -35,10 +35,10 @@ void filter_volume_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void filter_volume_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void filter_volume_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, inputs[0].get(i) * m_gain); + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * m_gain); } diff --git a/src/devices/sound/flt_vol.h b/src/devices/sound/flt_vol.h index 2e2d665f257..96bc61af200 100644 --- a/src/devices/sound/flt_vol.h +++ b/src/devices/sound/flt_vol.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream* m_stream; diff --git a/src/devices/sound/gaelco.cpp b/src/devices/sound/gaelco.cpp index 2c04678ff62..e40f35d1e7c 100644 --- a/src/devices/sound/gaelco.cpp +++ b/src/devices/sound/gaelco.cpp @@ -77,10 +77,10 @@ gaelco_gae1_device::gaelco_gae1_device(const machine_config &mconfig, device_typ Writes length bytes to the sound buffer ============================================================================*/ -void gaelco_gae1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gaelco_gae1_device::sound_stream_update(sound_stream &stream) { /* fill all data needed */ - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int output_l = 0, output_r = 0; @@ -178,8 +178,8 @@ void gaelco_gae1_device::sound_stream_update(sound_stream &stream, std::vector<r #endif /* now that we have computed all channels, save current data to the output buffer */ - outputs[0].put_int(j, output_l, 32768); - outputs[1].put_int(j, output_r, 32768); + stream.put_int(0, j, output_l, 32768); + stream.put_int(1, j, output_r, 32768); } // if (wavraw) diff --git a/src/devices/sound/gaelco.h b/src/devices/sound/gaelco.h index 2fff2ca4bee..014472d73f9 100644 --- a/src/devices/sound/gaelco.h +++ b/src/devices/sound/gaelco.h @@ -43,7 +43,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/gb.cpp b/src/devices/sound/gb.cpp index 6a683a21313..e542f580fe6 100644 --- a/src/devices/sound/gb.cpp +++ b/src/devices/sound/gb.cpp @@ -1313,11 +1313,9 @@ void cgb04_apu_device::apu_power_off() // sound_stream_update - handle a stream update //------------------------------------------------- -void gameboy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gameboy_sound_device::sound_stream_update(sound_stream &stream) { - auto &outputl = outputs[0]; - auto &outputr = outputs[1]; - for (int sampindex = 0; sampindex < outputl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { s32 sample; s32 left = 0; @@ -1369,7 +1367,7 @@ void gameboy_sound_device::sound_stream_update(sound_stream &stream, std::vector right *= m_snd_control.vol_right; /* Update the buffers */ - outputl.put_int(sampindex, left, 32768 / 64); - outputr.put_int(sampindex, right, 32768 / 64); + stream.put_int(0, sampindex, left, 32768 / 64); + stream.put_int(1, sampindex, right, 32768 / 64); } } diff --git a/src/devices/sound/gb.h b/src/devices/sound/gb.h index be5f12fb324..ce1f1a75a88 100644 --- a/src/devices/sound/gb.h +++ b/src/devices/sound/gb.h @@ -27,7 +27,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; protected: enum diff --git a/src/devices/sound/gew.cpp b/src/devices/sound/gew.cpp index c9d3ea3e500..274acbc2494 100644 --- a/src/devices/sound/gew.cpp +++ b/src/devices/sound/gew.cpp @@ -543,9 +543,9 @@ void gew_pcm_device::dump_sample(slot_t &slot) // sound_stream_update - handle a stream update //------------------------------------------------- -void gew_pcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gew_pcm_device::sound_stream_update(sound_stream &stream) { - for (int32_t i = 0; i < outputs[0].samples(); ++i) + for (int32_t i = 0; i < stream.samples(); ++i) { int32_t smpl = 0; int32_t smpr = 0; @@ -624,8 +624,8 @@ void gew_pcm_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - outputs[0].put_int_clamp(i, smpl, 32768); - outputs[1].put_int_clamp(i, smpr, 32768); + stream.put_int_clamp(0, i, smpl, 32768); + stream.put_int_clamp(1, i, smpr, 32768); } } diff --git a/src/devices/sound/gew.h b/src/devices/sound/gew.h index ddee760d461..233a02227c5 100644 --- a/src/devices/sound/gew.h +++ b/src/devices/sound/gew.h @@ -29,7 +29,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/gt155.cpp b/src/devices/sound/gt155.cpp index 61faf1ac1e6..bdd71a074c5 100644 --- a/src/devices/sound/gt155.cpp +++ b/src/devices/sound/gt155.cpp @@ -93,9 +93,9 @@ void gt155_device::device_clock_changed() } /**************************************************************************/ -void gt155_device::sound_stream_update(sound_stream& stream, std::vector<read_stream_view> const& inputs, std::vector<write_stream_view>& outputs) +void gt155_device::sound_stream_update(sound_stream& stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s64 left = 0, right = 0; @@ -108,8 +108,8 @@ void gt155_device::sound_stream_update(sound_stream& stream, std::vector<read_st } } - outputs[0].put_int_clamp(i, left >> 11, 32678); - outputs[1].put_int_clamp(i, right >> 11, 32768); + stream.put_int_clamp(0, i, left >> 11, 32678); + stream.put_int_clamp(1, i, right >> 11, 32768); } } diff --git a/src/devices/sound/gt155.h b/src/devices/sound/gt155.h index 69dbe91121e..319ec1c2661 100644 --- a/src/devices/sound/gt155.h +++ b/src/devices/sound/gt155.h @@ -36,7 +36,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/hc55516.cpp b/src/devices/sound/hc55516.cpp index 885751c1a6a..0bd36ae381f 100644 --- a/src/devices/sound/hc55516.cpp +++ b/src/devices/sound/hc55516.cpp @@ -197,15 +197,12 @@ void cvsd_device_base::process_bit(bool bit, bool clock_state) // sound_stream_update - handle a stream update //------------------------------------------------- -void cvsd_device_base::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cvsd_device_base::sound_stream_update(sound_stream &stream) { // Stub, just return silence - auto &buffer = outputs[0]; - - m_samples_generated += buffer.samples(); + m_samples_generated += stream.samples(); if (m_samples_generated >= SAMPLE_RATE) m_samples_generated -= SAMPLE_RATE; - buffer.fill(0); } @@ -356,16 +353,14 @@ void hc55516_device::process_bit(bool bit, bool clock_state) // sound_stream_update_legacy - handle a stream update //------------------------------------------------- -void hc55516_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void hc55516_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (is_external_oscillator()) { // external oscillator - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - buffer.put_int(i, m_next_sample, 32768); + stream.put_int(0, i, m_next_sample, 32768); m_samples_generated++; @@ -384,8 +379,8 @@ void hc55516_device::sound_stream_update(sound_stream &stream, std::vector<read_ // software driven clock else { - for (int i = 0; i < buffer.samples(); i++) - buffer.put_int(i, m_next_sample, 32768); + for (int i = 0; i < stream.samples(); i++) + stream.put_int(0, i, m_next_sample, 32768); } } @@ -493,14 +488,12 @@ void mc3417_device::process_bit(bool bit, bool clock_state) } } -void mc3417_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mc3417_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (!is_external_oscillator()) { // track how many samples we've updated without a clock; if it's been more than 1/32 of a second, output silence - m_samples_generated += buffer.samples(); + m_samples_generated += stream.samples(); if (m_samples_generated > SAMPLE_RATE / 32) { m_samples_generated = SAMPLE_RATE; @@ -509,16 +502,16 @@ void mc3417_device::sound_stream_update(sound_stream &stream, std::vector<read_s } // compute the interpolation slope - stream_buffer::sample_t sample = m_curr_sample; - stream_buffer::sample_t slope = (m_next_sample - sample) / buffer.samples(); + sound_stream::sample_t sample = m_curr_sample; + sound_stream::sample_t slope = (m_next_sample - sample) / stream.samples(); m_curr_sample = m_next_sample; if (is_external_oscillator()) { // external oscillator - for (int i = 0; i < buffer.samples(); i++, sample += slope) + for (int i = 0; i < stream.samples(); i++, sample += slope) { - buffer.put(i, sample); + stream.put(0, i, sample); m_samples_generated++; @@ -537,8 +530,8 @@ void mc3417_device::sound_stream_update(sound_stream &stream, std::vector<read_s // software driven clock else { - for (int i = 0; i < buffer.samples(); i++, sample += slope) - buffer.put(i, sample); + for (int i = 0; i < stream.samples(); i++, sample += slope) + stream.put(0, i, sample); } } diff --git a/src/devices/sound/hc55516.h b/src/devices/sound/hc55516.h index 9862e489b3f..ac1a56bf739 100644 --- a/src/devices/sound/hc55516.h +++ b/src/devices/sound/hc55516.h @@ -52,7 +52,7 @@ public: // Audio In pin, an analog value of the audio waveform being pushed to the chip. // TODO: this is not hooked up or implemented yet, and this should really be handled as an // input stream from a separate DAC device, not a value push function at all. - //void audio_in_w(stream_buffer::sample_t data); + //void audio_in_w(sound_stream::sample_t data); // sets the buffered digit (0 or 1), common to all chips. TODO: replace all use of this with // digin_cb once implemented @@ -74,7 +74,7 @@ protected: //virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // callbacks devcb_write_line m_clock_state_push_cb; // TODO: get rid of this, if you use it you should feel bad @@ -129,7 +129,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // callbacks devcb_write_line m_agc_push_cb; @@ -179,7 +179,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // const coefficients defined by constructor; should these be adjustable by the user or externally defined, // as they are implemented using a set of two small lowpass filters outside the chip? @@ -190,8 +190,8 @@ protected: // internal state double m_sylfilter; double m_intfilter; - stream_buffer::sample_t m_curr_sample; - stream_buffer::sample_t m_next_sample; + sound_stream::sample_t m_curr_sample; + sound_stream::sample_t m_next_sample; // internal handlers virtual void process_bit(bool bit, bool clock_state) override; diff --git a/src/devices/sound/huc6230.cpp b/src/devices/sound/huc6230.cpp index ba969479cf2..33e59309f2b 100644 --- a/src/devices/sound/huc6230.cpp +++ b/src/devices/sound/huc6230.cpp @@ -19,16 +19,16 @@ #include "huc6230.h" -void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void huc6230_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // TODO: this implies to read from the PSG inputs // doesn't seem right at all, eventually causes extreme DC offset on BIOS main menu, // possibly because adpcm_timer runs from a different thread, // needs to be rechecked once we have better examples ... - s32 samp0 = inputs[0].get(i) * 32768.0; - s32 samp1 = inputs[1].get(i) * 32768.0; + s32 samp0 = stream.get(0, i) * 32768.0; + s32 samp1 = stream.get(1, i) * 32768.0; for (int adpcm = 0; adpcm < 2; adpcm++) { @@ -42,8 +42,8 @@ void huc6230_device::sound_stream_update(sound_stream &stream, std::vector<read_ samp1 = std::clamp(samp1 + ((channel->m_output * channel->m_rvol) >> 4), -32768, 32767); } - outputs[0].put_int(i, samp0, 32768); - outputs[1].put_int(i, samp1, 32768); + stream.put_int(0, i, samp0, 32768); + stream.put_int(1, i, samp1, 32768); } } diff --git a/src/devices/sound/huc6230.h b/src/devices/sound/huc6230.h index f71e746190c..4c0ba5dea0b 100644 --- a/src/devices/sound/huc6230.h +++ b/src/devices/sound/huc6230.h @@ -28,7 +28,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct adpcm_channel { diff --git a/src/devices/sound/i5000.cpp b/src/devices/sound/i5000.cpp index 3f194ef74c5..9c599651925 100644 --- a/src/devices/sound/i5000.cpp +++ b/src/devices/sound/i5000.cpp @@ -114,9 +114,9 @@ bool i5000snd_device::read_sample(int ch) } -void i5000snd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void i5000snd_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int32_t mix_l = 0; int32_t mix_r = 0; @@ -157,8 +157,8 @@ void i5000snd_device::sound_stream_update(sound_stream &stream, std::vector<read mix_l += m_channels[ch].output_l; } - outputs[0].put_int(i, mix_r, 32768 * 16); - outputs[1].put_int(i, mix_l, 32768 * 16); + stream.put_int(0, i, mix_r, 32768 * 16); + stream.put_int(1, i, mix_l, 32768 * 16); } } diff --git a/src/devices/sound/i5000.h b/src/devices/sound/i5000.h index 2769b58520c..7012e45cc5e 100644 --- a/src/devices/sound/i5000.h +++ b/src/devices/sound/i5000.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; sound_stream *m_stream; diff --git a/src/devices/sound/ics2115.cpp b/src/devices/sound/ics2115.cpp index 2e93ab5b1da..521b1de28ff 100644 --- a/src/devices/sound/ics2115.cpp +++ b/src/devices/sound/ics2115.cpp @@ -422,13 +422,13 @@ void ics2115_device::ics2115_voice::update_ramp() } } -int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_view> &outputs) +int ics2115_device::fill_output(ics2115_voice& voice, sound_stream &stream) { bool irq_invalid = false; const u16 fine = 1 << (3*(voice.vol.incr >> 6)); voice.vol.add = (voice.vol.incr & 0x3f)<< (10 - fine); - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { constexpr int RAMP_SHIFT = 6; const u32 volacc = (voice.vol.acc >> 14) & 0xfff; @@ -449,8 +449,8 @@ int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_v //if (voice.playing()) if (!m_vmode || voice.playing()) { - outputs[0].add_int(i, (sample * vleft) >> (5 + volume_bits), 32768); - outputs[1].add_int(i, (sample * vright) >> (5 + volume_bits), 32768); + stream.add_int(0, i, (sample * vleft) >> (5 + volume_bits), 32768); + stream.add_int(1, i, (sample * vright) >> (5 + volume_bits), 32768); } voice.update_ramp(); @@ -465,11 +465,8 @@ int ics2115_device::fill_output(ics2115_voice& voice, std::vector<write_stream_v return irq_invalid; } -void ics2115_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ics2115_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - bool irq_invalid = false; for (int osc = 0; osc <= m_active_osc; osc++) { @@ -486,7 +483,7 @@ void ics2115_device::sound_stream_update(sound_stream &stream, std::vector<read_ logerror("[%06x=%04x]", curaddr, (s16)sample); #endif */ - if (fill_output(voice, outputs)) + if (fill_output(voice, stream)) irq_invalid = true; #ifdef ICS2115_DEBUG diff --git a/src/devices/sound/ics2115.h b/src/devices/sound/ics2115.h index a02a28075e3..8e99180ca53 100644 --- a/src/devices/sound/ics2115.h +++ b/src/devices/sound/ics2115.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; @@ -119,7 +119,7 @@ private: void recalc_irq(); // stream helper functions - int fill_output(ics2115_voice& voice, std::vector<write_stream_view> &outputs); + int fill_output(ics2115_voice& voice, sound_stream &stream); s32 get_sample(ics2115_voice& voice); u8 read_sample(ics2115_voice& voice, u32 addr) { return m_cache.read_byte((voice.osc.saddr << 20) | (addr & 0xfffff)); } diff --git a/src/devices/sound/iopspu.cpp b/src/devices/sound/iopspu.cpp index 55e6cd3b789..785d9a4f43b 100644 --- a/src/devices/sound/iopspu.cpp +++ b/src/devices/sound/iopspu.cpp @@ -89,10 +89,9 @@ void iop_spu_device::dma_done(int bank) core.m_status &= ~STATUS_DMA_ACTIVE; } -void iop_spu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void iop_spu_device::sound_stream_update(sound_stream &stream) { // TODO - outputs[0].fill(0); } TIMER_CALLBACK_MEMBER(iop_spu_device::autodma_done_timer_hack) diff --git a/src/devices/sound/iopspu.h b/src/devices/sound/iopspu.h index d52d3f2d4a4..94ac7614055 100644 --- a/src/devices/sound/iopspu.h +++ b/src/devices/sound/iopspu.h @@ -48,7 +48,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // HACK: This timer is currently used to trigger an interrupt after the auto-DMA-transferred buffer would have been // mixed and played back, as the PS2 BIOS pulls a null return address and crashes if we trigger the auto-DMA-complete diff --git a/src/devices/sound/iremga20.cpp b/src/devices/sound/iremga20.cpp index b87c9f26da0..99c7a823cf9 100644 --- a/src/devices/sound/iremga20.cpp +++ b/src/devices/sound/iremga20.cpp @@ -130,12 +130,9 @@ void iremga20_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void iremga20_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void iremga20_device::sound_stream_update(sound_stream &stream) { - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - for (int i = 0; i < outL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sampleout = 0; @@ -159,8 +156,8 @@ void iremga20_device::sound_stream_update(sound_stream &stream, std::vector<read } } - outL.put_int(i, sampleout, 32768 * 4); - outR.put_int(i, sampleout, 32768 * 4); + stream.put_int(0, i, sampleout, 32768 * 4); + stream.put_int(1, i, sampleout, 32768 * 4); } } diff --git a/src/devices/sound/iremga20.h b/src/devices/sound/iremga20.h index 2f854d8c55a..c397327ca76 100644 --- a/src/devices/sound/iremga20.h +++ b/src/devices/sound/iremga20.h @@ -36,7 +36,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/k005289.cpp b/src/devices/sound/k005289.cpp index 4202ce8207c..5a766ddc8af 100644 --- a/src/devices/sound/k005289.cpp +++ b/src/devices/sound/k005289.cpp @@ -85,10 +85,9 @@ void k005289_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void k005289_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k005289_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - for (int sampid = 0; sampid < outputs[0].samples(); sampid++) + for (int sampid = 0; sampid < stream.samples(); sampid++) { for (int i = 0; i < 2; i++) { @@ -98,7 +97,7 @@ void k005289_device::sound_stream_update(sound_stream &stream, std::vector<read_ v.waveform = (v.waveform & ~0x1f) | ((v.waveform + 1) & 0x1f); v.counter = v.frequency; } - outputs[0].add_int(sampid, ((m_sound_prom[((i & 1) << 8) | v.waveform] & 0xf) - 8) * v.volume, 512); + stream.add_int(0, sampid, ((m_sound_prom[((i & 1) << 8) | v.waveform] & 0xf) - 8) * v.volume, 512); } } } diff --git a/src/devices/sound/k005289.h b/src/devices/sound/k005289.h index 1518202f13c..0cadc1182d5 100644 --- a/src/devices/sound/k005289.h +++ b/src/devices/sound/k005289.h @@ -26,7 +26,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: required_region_ptr<u8> m_sound_prom; diff --git a/src/devices/sound/k007232.cpp b/src/devices/sound/k007232.cpp index 125ebc1352e..137f3a0ca92 100644 --- a/src/devices/sound/k007232.cpp +++ b/src/devices/sound/k007232.cpp @@ -211,7 +211,7 @@ void k007232_device::set_bank(int chan_a_bank, int chan_b_bank) // sound_stream_update - handle a stream update //------------------------------------------------- -void k007232_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k007232_device::sound_stream_update(sound_stream &stream) { if (K007232_LOG_PCM) { @@ -237,7 +237,7 @@ void k007232_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { s32 lsum = 0, rsum = 0; for (int i = 0; i < KDAC_A_PCM_MAX; i++) @@ -282,7 +282,7 @@ void k007232_device::sound_stream_update(sound_stream &stream, std::vector<read_ rsum += out * vol_b; } } - outputs[0].put_int(j, lsum, 32768); - outputs[1].put_int(j, rsum, 32768); + stream.put_int(0, j, lsum, 32768); + stream.put_int(1, j, rsum, 32768); } } diff --git a/src/devices/sound/k007232.h b/src/devices/sound/k007232.h index 7082d412d56..3c95e71a51c 100644 --- a/src/devices/sound/k007232.h +++ b/src/devices/sound/k007232.h @@ -37,7 +37,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/k051649.cpp b/src/devices/sound/k051649.cpp index 3afa41849d8..c4dd31c1ba7 100644 --- a/src/devices/sound/k051649.cpp +++ b/src/devices/sound/k051649.cpp @@ -133,12 +133,9 @@ void k051649_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void k051649_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k051649_device::sound_stream_update(sound_stream &stream) { - // zap the contents of the mixer buffer - outputs[0].fill(0); - - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { for (sound_channel &voice : m_channel_list) { @@ -157,7 +154,7 @@ void k051649_device::sound_stream_update(sound_stream &stream, std::vector<read_ } // scale to 11 bit digital output on chip - outputs[0].add_int(i, voice.sample >> 4, 1024); + stream.add_int(0, i, voice.sample >> 4, 1024); } } } diff --git a/src/devices/sound/k051649.h b/src/devices/sound/k051649.h index 3e0b60dfc86..c71d7ed8fd7 100644 --- a/src/devices/sound/k051649.h +++ b/src/devices/sound/k051649.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // parameters for a channel diff --git a/src/devices/sound/k053260.cpp b/src/devices/sound/k053260.cpp index e08e385d8f8..d11ae99fcda 100644 --- a/src/devices/sound/k053260.cpp +++ b/src/devices/sound/k053260.cpp @@ -308,11 +308,11 @@ void k053260_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void k053260_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k053260_device::sound_stream_update(sound_stream &stream) { if (m_mode & 2) { - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { s32 buffer[2] = {0, 0}; @@ -322,15 +322,10 @@ void k053260_device::sound_stream_update(sound_stream &stream, std::vector<read_ voice.play(buffer); } - outputs[0].put_int_clamp(j, buffer[0], 32768); - outputs[1].put_int_clamp(j, buffer[1], 32768); + stream.put_int_clamp(0, j, buffer[0], 32768); + stream.put_int_clamp(1, j, buffer[1], 32768); } } - else - { - outputs[0].fill(0); - outputs[1].fill(0); - } } diff --git a/src/devices/sound/k053260.h b/src/devices/sound/k053260.h index 7f9e963ea26..a1da89af19e 100644 --- a/src/devices/sound/k053260.h +++ b/src/devices/sound/k053260.h @@ -41,7 +41,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/k054539.cpp b/src/devices/sound/k054539.cpp index b7108e925f8..3bcadb703b7 100644 --- a/src/devices/sound/k054539.cpp +++ b/src/devices/sound/k054539.cpp @@ -103,7 +103,7 @@ void k054539_device::keyoff(int channel) regs[0x22c] &= ~(1 << channel); } -void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void k054539_device::sound_stream_update(sound_stream &stream) { static constexpr double VOL_CAP = 1.80; @@ -115,13 +115,9 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_ int16_t *rbase = (int16_t *)&ram[0]; if(!(regs[0x22f] & 1)) - { - outputs[0].fill(0); - outputs[1].fill(0); return; - } - for(int sample = 0; sample != outputs[0].samples(); sample++) { + for(int sample = 0; sample != stream.samples(); sample++) { double lval, rval; if(!(flags & DISABLE_REVERB)) lval = rval = rbase[reverb_pos]; @@ -299,8 +295,8 @@ void k054539_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } reverb_pos = (reverb_pos + 1) & 0x1fff; - outputs[0].put_int(sample, lval, 32768); - outputs[1].put_int(sample, rval, 32768); + stream.put_int(0, sample, lval, 32768); + stream.put_int(1, sample, rval, 32768); } } diff --git a/src/devices/sound/k054539.h b/src/devices/sound/k054539.h index 70df821dd2f..9e3ba6aa5f1 100644 --- a/src/devices/sound/k054539.h +++ b/src/devices/sound/k054539.h @@ -66,7 +66,7 @@ protected: virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/ks0164.cpp b/src/devices/sound/ks0164.cpp index 78b24423b2e..bad6b32c4f3 100644 --- a/src/devices/sound/ks0164.cpp +++ b/src/devices/sound/ks0164.cpp @@ -474,9 +474,9 @@ void ks0164_device::cpu_map(address_map &map) map(0xe000, 0xffff).ram(); } -void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ks0164_device::sound_stream_update(sound_stream &stream) { - for(int sample = 0; sample != outputs[0].samples(); sample++) { + for(int sample = 0; sample != stream.samples(); sample++) { s32 suml = 0, sumr = 0; for(int voice = 0; voice < 0x20; voice++) { u16 *regs = m_sregs[voice]; @@ -537,7 +537,7 @@ void ks0164_device::sound_stream_update(sound_stream &stream, std::vector<read_s } } } - outputs[0].put_int(sample, suml, 32768 * 32); - outputs[1].put_int(sample, sumr, 32768 * 32); + stream.put_int(0, sample, suml, 32768 * 32); + stream.put_int(1, sample, sumr, 32768 * 32); } } diff --git a/src/devices/sound/ks0164.h b/src/devices/sound/ks0164.h index cb7c0f5dff5..fde35585e93 100644 --- a/src/devices/sound/ks0164.h +++ b/src/devices/sound/ks0164.h @@ -27,7 +27,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.cpp b/src/devices/sound/l7a1045_l6028_dsp_a.cpp index aeb87e47968..cd65ec51f6e 100644 --- a/src/devices/sound/l7a1045_l6028_dsp_a.cpp +++ b/src/devices/sound/l7a1045_l6028_dsp_a.cpp @@ -151,12 +151,8 @@ void l7a1045_sound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void l7a1045_sound_device::sound_stream_update(sound_stream &stream) { - /* Clear the buffers */ - outputs[0].fill(0); - outputs[1].fill(0); - for (int i = 0; i < 32; i++) { if (m_key & (1 << i)) @@ -170,7 +166,7 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector uint32_t pos = vptr->pos; uint32_t frac = vptr->frac; - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int32_t sample; uint8_t data; @@ -197,8 +193,8 @@ void l7a1045_sound_device::sound_stream_update(sound_stream &stream, std::vector sample = int8_t(data & 0xfc) << (3 - (data & 3)); frac += step; - outputs[0].add_int(j, sample * vptr->l_volume, 32768 * 512); - outputs[1].add_int(j, sample * vptr->r_volume, 32768 * 512); + stream.add_int(0, j, sample * vptr->l_volume, 32768 * 512); + stream.add_int(1, j, sample * vptr->r_volume, 32768 * 512); } vptr->pos = pos; diff --git a/src/devices/sound/l7a1045_l6028_dsp_a.h b/src/devices/sound/l7a1045_l6028_dsp_a.h index 3115e1826bb..20a5348a779 100644 --- a/src/devices/sound/l7a1045_l6028_dsp_a.h +++ b/src/devices/sound/l7a1045_l6028_dsp_a.h @@ -34,7 +34,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct l7a1045_voice diff --git a/src/devices/sound/lc78836m.cpp b/src/devices/sound/lc78836m.cpp index 7b611e59cf7..ecb007ad081 100644 --- a/src/devices/sound/lc78836m.cpp +++ b/src/devices/sound/lc78836m.cpp @@ -88,14 +88,12 @@ void lc78836m_device::device_clock_changed() update_clock(); } -void lc78836m_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lc78836m_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[0].put(0, m_sample_ch1 * m_att / 1024.0); + stream.put(0, 0, m_sample_ch1 * m_att / 1024.0); m_sample_ch1 = 0; - outputs[1].fill(0); - outputs[1].put(0, m_sample_ch2 * m_att / 1024.0); + stream.put(1, 0, m_sample_ch2 * m_att / 1024.0); m_sample_ch2 = 0; if (m_mute && m_att > 0) @@ -129,7 +127,7 @@ void lc78836m_device::bclk_w(int state) m_sample_bit++; if (m_sample_bit >= 16) { - stream_buffer::sample_t sample = m_sample / double(std::numeric_limits<int16_t>::max()); + sound_stream::sample_t sample = m_sample / double(std::numeric_limits<int16_t>::max()); if (m_lrck) m_sample_ch1 = sample; diff --git a/src/devices/sound/lc78836m.h b/src/devices/sound/lc78836m.h index e2622fa3500..a1dc2d04ef7 100644 --- a/src/devices/sound/lc78836m.h +++ b/src/devices/sound/lc78836m.h @@ -38,7 +38,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void update_clock(); @@ -56,7 +56,7 @@ private: uint8_t m_sample_bit; int16_t m_sample; - stream_buffer::sample_t m_sample_ch1, m_sample_ch2; + sound_stream::sample_t m_sample_ch1, m_sample_ch2; double m_att; }; diff --git a/src/devices/sound/lc82310.cpp b/src/devices/sound/lc82310.cpp index 3404a5c9629..87523d591d1 100644 --- a/src/devices/sound/lc82310.cpp +++ b/src/devices/sound/lc82310.cpp @@ -258,15 +258,15 @@ void lc82310_device::fill_buffer() stream->set_sample_rate(frame_sample_rate); } -void lc82310_device::append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount) +void lc82310_device::append_buffer(sound_stream &stream, int &pos, int scount) { int s1 = std::min(scount - pos, m_sample_count); int words_per_sample = std::min(m_frame_channels, 2); for (int i = 0; i < s1; i++) { - outputs[0].put_int(pos, samples[m_samples_idx * words_per_sample], 32768); - outputs[1].put_int(pos, samples[m_samples_idx * words_per_sample + (words_per_sample >> 1)], 32768); + stream.put_int(0, pos, samples[m_samples_idx * words_per_sample], 32768); + stream.put_int(1, pos, samples[m_samples_idx * words_per_sample + (words_per_sample >> 1)], 32768); m_samples_idx++; pos++; @@ -279,9 +279,9 @@ void lc82310_device::append_buffer(std::vector<write_stream_view> &outputs, int } } -void lc82310_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lc82310_device::sound_stream_update(sound_stream &stream) { - int csamples = outputs[0].samples(); + int csamples = stream.samples(); int pos = 0; while (pos < csamples) @@ -290,12 +290,8 @@ void lc82310_device::sound_stream_update(sound_stream &stream, std::vector<read_ fill_buffer(); if (m_sample_count <= 0) - { - outputs[0].fill(0, pos); - outputs[1].fill(0, pos); return; - } - append_buffer(outputs, pos, csamples); + append_buffer(stream, pos, csamples); } } diff --git a/src/devices/sound/lc82310.h b/src/devices/sound/lc82310.h index 802c7bbe2e9..64a4372c3d4 100644 --- a/src/devices/sound/lc82310.h +++ b/src/devices/sound/lc82310.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum : uint8_t @@ -63,7 +63,7 @@ private: void handle_command(uint8_t cmd, uint8_t param); void fill_buffer(); - void append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount); + void append_buffer(sound_stream &stream, int &pos, int scount); sound_stream *stream; std::unique_ptr<mp3_audio> mp3dec; diff --git a/src/devices/sound/lmc1992.cpp b/src/devices/sound/lmc1992.cpp index feaa0810226..313855ea6df 100644 --- a/src/devices/sound/lmc1992.cpp +++ b/src/devices/sound/lmc1992.cpp @@ -175,9 +175,8 @@ void lmc1992_device::device_start() // our sound stream //------------------------------------------------- -void lmc1992_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lmc1992_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } diff --git a/src/devices/sound/lmc1992.h b/src/devices/sound/lmc1992.h index dc9ea4d9806..371b241d2ff 100644 --- a/src/devices/sound/lmc1992.h +++ b/src/devices/sound/lmc1992.h @@ -71,7 +71,7 @@ protected: virtual void device_start() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: inline void execute_command(int addr, int data); diff --git a/src/devices/sound/lynx.cpp b/src/devices/sound/lynx.cpp index 1a1f20d0bda..8520804d07b 100644 --- a/src/devices/sound/lynx.cpp +++ b/src/devices/sound/lynx.cpp @@ -477,11 +477,9 @@ void lynx_sound_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lynx_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 result = 0; for (int channel = 0; channel < LYNX_AUDIO_CHANNELS; channel++) @@ -489,7 +487,7 @@ void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<re execute(channel); result += m_audio[channel].reg.output * 15; // where does the *15 come from? } - buffer.put_int(i, result, 32768); + stream.put_int(0, i, result, 32768); } } @@ -497,12 +495,9 @@ void lynx_sound_device::sound_stream_update(sound_stream &stream, std::vector<re // sound_stream_update - handle a stream update //------------------------------------------------- -void lynx2_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void lynx2_sound_device::sound_stream_update(sound_stream &stream) { - auto &left = outputs[0]; - auto &right = outputs[1]; - - for (int i = 0; i < left.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 lsum = 0; s32 rsum = 0; @@ -525,7 +520,7 @@ void lynx2_sound_device::sound_stream_update(sound_stream &stream, std::vector<r rsum += v * 15; } } - left.put_int(i, lsum, 32768); - right.put_int(i, rsum, 32768); + stream.put_int(0, i, lsum, 32768); + stream.put_int(1, i, rsum, 32768); } } diff --git a/src/devices/sound/lynx.h b/src/devices/sound/lynx.h index b729afe4ebe..d0b3b73c961 100644 --- a/src/devices/sound/lynx.h +++ b/src/devices/sound/lynx.h @@ -56,7 +56,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void reset_channel(LYNX_AUDIO *channel); void shift(int chan_nr); @@ -85,7 +85,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/devices/sound/mas3507d.cpp b/src/devices/sound/mas3507d.cpp index 25f9d2ab1af..ff9024dc60f 100644 --- a/src/devices/sound/mas3507d.cpp +++ b/src/devices/sound/mas3507d.cpp @@ -449,19 +449,19 @@ void mas3507d_device::fill_buffer() cb_demand(mp3data_count < mp3data.size()); } -void mas3507d_device::append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount) +void mas3507d_device::append_buffer(sound_stream &stream, int &pos, int scount) { const int bytes_per_sample = std::min(frame_channels, 2); // More than 2 channels is unsupported here const int s1 = std::min(scount - pos, sample_count); - const stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - const stream_buffer::sample_t mute_scale = is_muted ? 0.0 : 1.0; + const sound_stream::sample_t sample_scale = 1.0 / 32768.0; + const sound_stream::sample_t mute_scale = is_muted ? 0.0 : 1.0; for(int i = 0; i < s1; i++) { - const stream_buffer::sample_t lsamp_mixed = stream_buffer::sample_t(samples[samples_idx * bytes_per_sample]) * sample_scale * mute_scale * gain_ll; - const stream_buffer::sample_t rsamp_mixed = stream_buffer::sample_t(samples[samples_idx * bytes_per_sample + (bytes_per_sample >> 1)]) * sample_scale * mute_scale * gain_rr; + const sound_stream::sample_t lsamp_mixed = sound_stream::sample_t(samples[samples_idx * bytes_per_sample]) * sample_scale * mute_scale * gain_ll; + const sound_stream::sample_t rsamp_mixed = sound_stream::sample_t(samples[samples_idx * bytes_per_sample + (bytes_per_sample >> 1)]) * sample_scale * mute_scale * gain_rr; - outputs[0].put(pos, lsamp_mixed); - outputs[1].put(pos, rsamp_mixed); + stream.put(0, pos, lsamp_mixed); + stream.put(1, pos, rsamp_mixed); samples_idx++; pos++; @@ -485,21 +485,18 @@ void mas3507d_device::reset_playback() samples_idx = 0; } -void mas3507d_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mas3507d_device::sound_stream_update(sound_stream &stream) { - int csamples = outputs[0].samples(); + int csamples = stream.samples(); int pos = 0; while(pos < csamples) { if(sample_count == 0) fill_buffer(); - if(sample_count <= 0) { - outputs[0].fill(0, pos); - outputs[1].fill(0, pos); + if(sample_count <= 0) return; - } - append_buffer(outputs, pos, csamples); + append_buffer(stream, pos, csamples); } } diff --git a/src/devices/sound/mas3507d.h b/src/devices/sound/mas3507d.h index 5078c050863..c4f77aefc16 100644 --- a/src/devices/sound/mas3507d.h +++ b/src/devices/sound/mas3507d.h @@ -28,7 +28,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void i2c_nak(); @@ -41,7 +41,7 @@ private: void reg_write(uint32_t adr, uint32_t val); void fill_buffer(); - void append_buffer(std::vector<write_stream_view> &outputs, int &pos, int scount); + void append_buffer(sound_stream &stream, int &pos, int scount); int gain_to_db(double val); float gain_to_percentage(int val); diff --git a/src/devices/sound/mea8000.cpp b/src/devices/sound/mea8000.cpp index 25381b9ae81..caa0aef5ea0 100644 --- a/src/devices/sound/mea8000.cpp +++ b/src/devices/sound/mea8000.cpp @@ -420,9 +420,9 @@ void mea8000_device::stop_frame() -void mea8000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mea8000_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(stream_buffer::sample_t(m_output) * (1.0 / 32768.0)); + stream.fill(0, sound_stream::sample_t(m_output) * (1.0 / 32768.0)); } /* next sample in frame, sampling at 64 kHz */ diff --git a/src/devices/sound/mea8000.h b/src/devices/sound/mea8000.h index 121b1866912..bcd96e161b0 100644 --- a/src/devices/sound/mea8000.h +++ b/src/devices/sound/mea8000.h @@ -29,7 +29,7 @@ public: protected: // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: /* filter coefficients from frequencies */ diff --git a/src/devices/sound/mm5837.cpp b/src/devices/sound/mm5837.cpp index 40bec2727b8..74f90d01599 100644 --- a/src/devices/sound/mm5837.cpp +++ b/src/devices/sound/mm5837.cpp @@ -109,8 +109,8 @@ void mm5837_stream_device::device_start() // sound_stream_update - fill the sound buffer //------------------------------------------------- -void mm5837_stream_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mm5837_stream_device::sound_stream_update(sound_stream &stream) { - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - outputs[0].put(sampindex, m_source.clock() ? 1.0 : 0.0); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put(0, sampindex, m_source.clock() ? 1.0 : 0.0); } diff --git a/src/devices/sound/mm5837.h b/src/devices/sound/mm5837.h index 2e8e5406506..169965ef1d5 100644 --- a/src/devices/sound/mm5837.h +++ b/src/devices/sound/mm5837.h @@ -196,7 +196,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; // sound stream diff --git a/src/devices/sound/mmc5.cpp b/src/devices/sound/mmc5.cpp index 2659e36535c..48b976e588d 100644 --- a/src/devices/sound/mmc5.cpp +++ b/src/devices/sound/mmc5.cpp @@ -91,7 +91,7 @@ void mmc5_sound_device::device_start() */ for (int i = 0; i < 31; i++) { - stream_buffer::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); + sound_stream::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); m_square_lut[i] = pulse_out; } @@ -297,19 +297,18 @@ void mmc5_sound_device::pcm_w(u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void mmc5_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mmc5_sound_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t accum = 0.0; - auto &output = outputs[0]; + sound_stream::sample_t accum = 0.0; - for (int sampindex = 0; sampindex < output.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { tick_square(m_core.squ[0]); tick_square(m_core.squ[1]); accum = m_square_lut[m_core.squ[0].output + m_core.squ[1].output]; - accum += stream_buffer::sample_t(m_core.pcm.output) / 255.0f; + accum += sound_stream::sample_t(m_core.pcm.output) / 255.0f; - output.put(sampindex, -accum); + stream.put(0, sampindex, -accum); } } diff --git a/src/devices/sound/mmc5.h b/src/devices/sound/mmc5.h index a8f0ea9f406..a9fd920f63f 100644 --- a/src/devices/sound/mmc5.h +++ b/src/devices/sound/mmc5.h @@ -47,7 +47,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: /* GLOBAL CONSTANTS */ @@ -58,7 +58,7 @@ private: u32 m_samps_per_sync; /* Number of samples per vsync */ u32 m_vbl_times[SYNCS_MAX1]; /* VBL durations in samples */ u32 m_sync_times1[SYNCS_MAX1]; /* Samples per sync table */ - stream_buffer::sample_t m_square_lut[31]; // Non-linear Square wave output LUT + sound_stream::sample_t m_square_lut[31]; // Non-linear Square wave output LUT sound_stream *m_stream; devcb_write_line m_irq_handler; diff --git a/src/devices/sound/mos6560.cpp b/src/devices/sound/mos6560.cpp index 6434621f13d..5f77f5e0781 100644 --- a/src/devices/sound/mos6560.cpp +++ b/src/devices/sound/mos6560.cpp @@ -865,12 +865,11 @@ void mos6560_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mos6560_device::sound_stream_update(sound_stream &stream) { int i, v; - auto &buffer = outputs[0]; - for (i = 0; i < buffer.samples(); i++) + for (i = 0; i < stream.samples(); i++) { v = 0; if (TONE1_ON /*||(m_tone1pos != 0) */ ) @@ -883,7 +882,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (m_tone1pos >= m_tone1samples) { m_tone1pos = 0; - m_tone1samples = buffer.sample_rate() / TONE1_FREQUENCY; + m_tone1samples = stream.sample_rate() / TONE1_FREQUENCY; if (m_tone1samples == 0) m_tone1samples = 1; } @@ -899,7 +898,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (m_tone2pos >= m_tone2samples) { m_tone2pos = 0; - m_tone2samples = buffer.sample_rate() / TONE2_FREQUENCY; + m_tone2samples = stream.sample_rate() / TONE2_FREQUENCY; if (m_tone2samples == 0) m_tone2samples = 1; } @@ -915,7 +914,7 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ if (m_tone3pos >= m_tone3samples) { m_tone3pos = 0; - m_tone3samples = buffer.sample_rate() / TONE3_FREQUENCY; + m_tone3samples = stream.sample_rate() / TONE3_FREQUENCY; if (m_tone3samples == 0) m_tone3samples = 1; } @@ -935,6 +934,6 @@ void mos6560_device::sound_stream_update(sound_stream &stream, std::vector<read_ v = 8191; else if (v < -8191) v = -8191; - buffer.put_int(i, v, 8192); + stream.put_int(0, i, v, 8192); } } diff --git a/src/devices/sound/mos6560.h b/src/devices/sound/mos6560.h index 13b29ba363f..e48e4601466 100644 --- a/src/devices/sound/mos6560.h +++ b/src/devices/sound/mos6560.h @@ -118,7 +118,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; inline uint8_t read_videoram(offs_t offset); inline uint8_t read_colorram(offs_t offset); diff --git a/src/devices/sound/mos6581.cpp b/src/devices/sound/mos6581.cpp index 941472a58f0..af195f6fa0c 100644 --- a/src/devices/sound/mos6581.cpp +++ b/src/devices/sound/mos6581.cpp @@ -235,9 +235,9 @@ void mos6581_device::device_post_load() // our sound stream //------------------------------------------------- -void mos6581_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mos6581_device::sound_stream_update(sound_stream &stream) { - m_token->fill_buffer(outputs[0]); + m_token->fill_buffer(stream); } diff --git a/src/devices/sound/mos6581.h b/src/devices/sound/mos6581.h index 6f9c87a5abb..d4868606768 100644 --- a/src/devices/sound/mos6581.h +++ b/src/devices/sound/mos6581.h @@ -65,7 +65,7 @@ protected: virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void save_state(SID6581_t *token); private: diff --git a/src/devices/sound/mos7360.cpp b/src/devices/sound/mos7360.cpp index 51953d93ecd..6a3d5887b15 100644 --- a/src/devices/sound/mos7360.cpp +++ b/src/devices/sound/mos7360.cpp @@ -439,12 +439,11 @@ TIMER_CALLBACK_MEMBER(mos7360_device::timer_expired) // our sound stream //------------------------------------------------- -void mos7360_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mos7360_device::sound_stream_update(sound_stream &stream) { int i, v, a; - auto &buffer = outputs[0]; - for (i = 0; i < buffer.samples(); i++) + for (i = 0; i < stream.samples(); i++) { v = 0; @@ -487,7 +486,7 @@ void mos7360_device::sound_stream_update(sound_stream &stream, std::vector<read_ v = v * a; - buffer.put_int(i, v, 32768); + stream.put_int(0, i, v, 32768); } } diff --git a/src/devices/sound/mos7360.h b/src/devices/sound/mos7360.h index 1b6c1a8f5b0..9288c752824 100644 --- a/src/devices/sound/mos7360.h +++ b/src/devices/sound/mos7360.h @@ -107,7 +107,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; inline void set_interrupt(int mask); inline void clear_interrupt(int mask); diff --git a/src/devices/sound/msm5205.cpp b/src/devices/sound/msm5205.cpp index f3f1f5e6302..814b3191342 100644 --- a/src/devices/sound/msm5205.cpp +++ b/src/devices/sound/msm5205.cpp @@ -347,20 +347,16 @@ void msm5205_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void msm5205_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msm5205_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; - /* if this voice is active */ if (m_signal) { - constexpr stream_buffer::sample_t sample_scale = 1.0 / double(1 << 12); + constexpr sound_stream::sample_t sample_scale = 1.0 / double(1 << 12); const int dac_mask = (m_dac_bits >= 12) ? 0 : (1 << (12 - m_dac_bits)) - 1; - stream_buffer::sample_t val = stream_buffer::sample_t(m_signal & ~dac_mask) * sample_scale; - output.fill(val); + sound_stream::sample_t val = sound_stream::sample_t(m_signal & ~dac_mask) * sample_scale; + stream.fill(0, val); } - else - output.fill(0); } @@ -368,8 +364,8 @@ void msm5205_device::sound_stream_update(sound_stream &stream, std::vector<read_ // sound_stream_update - handle a stream update //------------------------------------------------- -void msm6585_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msm6585_device::sound_stream_update(sound_stream &stream) { // should this be different? - msm5205_device::sound_stream_update(stream, inputs, outputs); + msm5205_device::sound_stream_update(stream); } diff --git a/src/devices/sound/msm5205.h b/src/devices/sound/msm5205.h index d310c8d56fb..9aba7ea6f98 100644 --- a/src/devices/sound/msm5205.h +++ b/src/devices/sound/msm5205.h @@ -59,7 +59,7 @@ protected: TIMER_CALLBACK_MEMBER(update_adpcm); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void compute_tables(); virtual int get_prescaler() const; @@ -101,7 +101,7 @@ protected: virtual double adpcm_capture_divisor() const override { return 2.0; } // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/devices/sound/msm5232.cpp b/src/devices/sound/msm5232.cpp index e709b3af16b..1e05483b6e9 100644 --- a/src/devices/sound/msm5232.cpp +++ b/src/devices/sound/msm5232.cpp @@ -708,31 +708,18 @@ void msm5232_device::set_clock(int clock) // sound_stream_update - handle a stream update //------------------------------------------------- -void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msm5232_device::sound_stream_update(sound_stream &stream) { - auto &buf1 = outputs[0]; - auto &buf2 = outputs[1]; - auto &buf3 = outputs[2]; - auto &buf4 = outputs[3]; - auto &buf5 = outputs[4]; - auto &buf6 = outputs[5]; - auto &buf7 = outputs[6]; - auto &buf8 = outputs[7]; - auto &bufsolo1 = outputs[8]; - auto &bufsolo2 = outputs[9]; - auto &bufnoise = outputs[10]; - int i; - - for (i=0; i<buf1.samples(); i++) + for (int i=0; i<stream.samples(); i++) { /* calculate all voices' envelopes */ EG_voices_advance(); TG_group_advance(0); /* calculate tones group 1 */ - buf1.put_int(i, o2, 32768); - buf2.put_int(i, o4, 32768); - buf3.put_int(i, o8, 32768); - buf4.put_int(i, o16, 32768); + stream.put_int(0, i, o2, 32768); + stream.put_int(1, i, o4, 32768); + stream.put_int(2, i, o8, 32768); + stream.put_int(3, i, o16, 32768); SAVE_SINGLE_CHANNEL(0,o2) SAVE_SINGLE_CHANNEL(1,o4) @@ -740,13 +727,13 @@ void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_ SAVE_SINGLE_CHANNEL(3,o16) TG_group_advance(1); /* calculate tones group 2 */ - buf5.put_int(i, o2, 32768); - buf6.put_int(i, o4, 32768); - buf7.put_int(i, o8, 32768); - buf8.put_int(i, o16, 32768); + stream.put_int(4, i, o2, 32768); + stream.put_int(5, i, o4, 32768); + stream.put_int(6, i, o8, 32768); + stream.put_int(7, i, o16, 32768); - bufsolo1.put_int(i, solo8, 32768); - bufsolo2.put_int(i, solo16, 32768); + stream.put_int(8, i, solo8, 32768); + stream.put_int(9, i, solo16, 32768); SAVE_SINGLE_CHANNEL(4,o2) SAVE_SINGLE_CHANNEL(5,o4) @@ -774,6 +761,6 @@ void msm5232_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - bufnoise.put(i, (m_noise_rng & (1<<16)) ? 1.0 : 0.0); + stream.put(10, i, (m_noise_rng & (1<<16)) ? 1.0 : 0.0); } } diff --git a/src/devices/sound/msm5232.h b/src/devices/sound/msm5232.h index a79314b89fd..44ab63e46e3 100644 --- a/src/devices/sound/msm5232.h +++ b/src/devices/sound/msm5232.h @@ -25,7 +25,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct VOICE { diff --git a/src/devices/sound/n63701x.cpp b/src/devices/sound/n63701x.cpp index 6f16c988d8e..c6f09efae72 100644 --- a/src/devices/sound/n63701x.cpp +++ b/src/devices/sound/n63701x.cpp @@ -64,13 +64,12 @@ void namco_63701x_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void namco_63701x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_63701x_device::sound_stream_update(sound_stream &stream) { int ch; for (ch = 0;ch < 2;ch++) { - auto &buf = outputs[ch]; voice_63701x *v = &m_voices[ch]; if (v->playing) @@ -80,12 +79,12 @@ void namco_63701x_device::sound_stream_update(sound_stream &stream, std::vector< int vol = vol_table[v->volume]; int p; - for (p = 0;p < buf.samples();p++) + for (p = 0;p < stream.samples();p++) { if (v->silence_counter) { v->silence_counter--; - buf.put(p, 0); + stream.put(0, p, 0); } else { @@ -94,26 +93,24 @@ void namco_63701x_device::sound_stream_update(sound_stream &stream, std::vector< if (data == 0xff) /* end of sample */ { v->playing = 0; - buf.fill(0, p); + stream.fill(0, 0, p); break; } else if (data == 0x00) /* silence compression */ { data = base[(pos++) & 0xffff]; v->silence_counter = data; - buf.put(p, 0); + stream.put(0, p, 0); } else { - buf.put_int(p, vol * (data - 0x80), 32768); + stream.put_int(0, p, vol * (data - 0x80), 32768); } } } v->position = pos; } - else - buf.fill(0); } } diff --git a/src/devices/sound/n63701x.h b/src/devices/sound/n63701x.h index f4d24173e1c..cd66519e0c1 100644 --- a/src/devices/sound/n63701x.h +++ b/src/devices/sound/n63701x.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct voice_63701x diff --git a/src/devices/sound/namco.cpp b/src/devices/sound/namco.cpp index 5842c7ada83..688f1ce98ec 100644 --- a/src/devices/sound/namco.cpp +++ b/src/devices/sound/namco.cpp @@ -233,11 +233,11 @@ void namco_audio_device::build_decoded_waveform(uint8_t *rgnbase) // generate sound by oversampling -uint32_t namco_audio_device::namco_update_one(write_stream_view &buffer, const int16_t *wave, uint32_t counter, uint32_t freq) +uint32_t namco_audio_device::namco_update_one(sound_stream &stream, int output, const int16_t *wave, uint32_t counter, uint32_t freq) { - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.add_int(sampindex, wave[WAVEFORM_POSITION(counter)], 32768); + stream.add_int(output, sampindex, wave[WAVEFORM_POSITION(counter)], 32768); counter += freq; } @@ -679,14 +679,10 @@ void namco_15xx_device::sharedram_w(offs_t offset, uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_audio_device::sound_stream_update(sound_stream &stream) { if (m_stereo) { - // zap the contents of the buffers - outputs[0].fill(0); - outputs[1].fill(0); - // if no sound, we're done if (!m_sound_enable) return; @@ -694,8 +690,6 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r // loop over each voice and add its contribution for (sound_channel *voice = m_channel_list; voice < m_last_channel; voice++) { - auto &lmix = outputs[0]; - auto &rmix = outputs[1]; int lv = voice->volume[0]; int rv = voice->volume[1]; @@ -714,17 +708,17 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r int16_t r_noise_data = OUTPUT_LEVEL(0x07 * (rv >> 1)); // add our contribution - for (int i = 0; i < lmix.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { if (voice->noise_state) { - lmix.add_int(i, l_noise_data, 32768); - rmix.add_int(i, r_noise_data, 32768); + stream.add_int(0, i, l_noise_data, 32768); + stream.add_int(1, i, r_noise_data, 32768); } else { - lmix.add_int(i, -l_noise_data, 32768); - rmix.add_int(i, -r_noise_data, 32768); + stream.add_int(0, i, -l_noise_data, 32768); + stream.add_int(1, i, -r_noise_data, 32768); } if (hold) @@ -762,7 +756,7 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r const int16_t *lw = &m_waveform[lv][voice->waveform_select * 32]; // generate sound into the buffer - c = namco_update_one(lmix, lw, voice->counter, voice->frequency); + c = namco_update_one(stream, 0, lw, voice->counter, voice->frequency); } // only update if we have non-zero right volume @@ -771,7 +765,7 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r const int16_t *rw = &m_waveform[rv][voice->waveform_select * 32]; // generate sound into the buffer - c = namco_update_one(rmix, rw, voice->counter, voice->frequency); + c = namco_update_one(stream, 1, rw, voice->counter, voice->frequency); } // update the counter for this voice @@ -783,11 +777,6 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r { sound_channel *voice; - auto &buffer = outputs[0]; - - // zap the contents of the buffer - buffer.fill(0); - // if no sound, we're done if (!m_sound_enable) return; @@ -810,12 +799,12 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r int16_t noise_data = OUTPUT_LEVEL(0x07 * (v >> 1)); // add our contribution - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { if (voice->noise_state) - buffer.add_int(i, noise_data, 32768); + stream.add_int(0, i, noise_data, 32768); else - buffer.add_int(i, -noise_data, 32768); + stream.add_int(1, i, -noise_data, 32768); if (hold) { @@ -849,24 +838,24 @@ void namco_audio_device::sound_stream_update(sound_stream &stream, std::vector<r const int16_t *w = &m_waveform[v][voice->waveform_select * 32]; // generate sound into buffer and update the counter for this voice - voice->counter = namco_update_one(buffer, w, voice->counter, voice->frequency); + voice->counter = namco_update_one(stream, 0, w, voice->counter, voice->frequency); } } } } } -void namco_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_device::sound_stream_update(sound_stream &stream) { - namco_audio_device::sound_stream_update(stream, inputs, outputs); + namco_audio_device::sound_stream_update(stream); } -void namco_15xx_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_15xx_device::sound_stream_update(sound_stream &stream) { - namco_audio_device::sound_stream_update(stream, inputs, outputs); + namco_audio_device::sound_stream_update(stream); } -void namco_cus30_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_cus30_device::sound_stream_update(sound_stream &stream) { - namco_audio_device::sound_stream_update(stream, inputs, outputs); + namco_audio_device::sound_stream_update(stream); } diff --git a/src/devices/sound/namco.h b/src/devices/sound/namco.h index a5ce6814402..ac37d4d4aa3 100644 --- a/src/devices/sound/namco.h +++ b/src/devices/sound/namco.h @@ -43,7 +43,7 @@ protected: // internal state void build_decoded_waveform( uint8_t *rgnbase ); void update_namco_waveform(int offset, uint8_t data); - uint32_t namco_update_one(write_stream_view &buffer, const int16_t *wave, uint32_t counter, uint32_t freq); + uint32_t namco_update_one(sound_stream &stream, int output, const int16_t *wave, uint32_t counter, uint32_t freq); // waveform region optional_region_ptr<uint8_t> m_wave_ptr; @@ -69,7 +69,7 @@ protected: // decoded waveform table std::unique_ptr<int16_t[]> m_waveform[MAX_VOLUME]; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; class namco_device : public namco_audio_device @@ -86,7 +86,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: std::unique_ptr<uint8_t[]> m_soundregs; @@ -106,7 +106,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: std::unique_ptr<uint8_t[]> m_soundregs; @@ -125,7 +125,7 @@ public: void pacman_sound_w(offs_t offset, uint8_t data); protected: - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/devices/sound/namco_163.cpp b/src/devices/sound/namco_163.cpp index 3735e3147df..7f20a25928c 100644 --- a/src/devices/sound/namco_163.cpp +++ b/src/devices/sound/namco_163.cpp @@ -145,16 +145,13 @@ u8 namco_163_sound_device::data_r() } -void namco_163_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void namco_163_sound_device::sound_stream_update(sound_stream &stream) { if (m_disable) - { - outputs[0].fill(0); return; - } // Slightly noisy but closer to real hardware behavior - for (int s = 0; s < outputs[0].samples(); s++) + for (int s = 0; s < stream.samples(); s++) { u32 phase = (m_ram[m_reg_addr + 5] << 16) | (m_ram[m_reg_addr + 3] << 8) | m_ram[m_reg_addr + 1]; const u32 freq = ((m_ram[m_reg_addr + 4] & 0x3) << 16) | (m_ram[m_reg_addr + 2] << 8) | m_ram[m_reg_addr + 0]; @@ -174,6 +171,6 @@ void namco_163_sound_device::sound_stream_update(sound_stream &stream, std::vect { m_reg_addr = 0x78 - ((m_ram[0x7f] & 0x70) >> 1); } - outputs[0].put_int(s, output, 128); + stream.put_int(0, s, output, 128); } } diff --git a/src/devices/sound/namco_163.h b/src/devices/sound/namco_163.h index 953110194c9..61b3af8fe0e 100644 --- a/src/devices/sound/namco_163.h +++ b/src/devices/sound/namco_163.h @@ -34,7 +34,7 @@ protected: // internals inline s8 get_sample(u16 addr); - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; DECLARE_DEVICE_TYPE(NAMCO_163, namco_163_sound_device) diff --git a/src/devices/sound/nes_apu.cpp b/src/devices/sound/nes_apu.cpp index 86c8a8c8934..3f8755398bc 100644 --- a/src/devices/sound/nes_apu.cpp +++ b/src/devices/sound/nes_apu.cpp @@ -131,7 +131,7 @@ void nesapu_device::device_start() */ for (int i = 0; i < 31; i++) { - stream_buffer::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); + sound_stream::sample_t pulse_out = (i == 0) ? 0.0 : 95.88 / ((8128.0 / i) + 100.0); m_square_lut[i] = pulse_out; } @@ -153,7 +153,7 @@ void nesapu_device::device_start() { for (int d = 0; d < 128; d++) { - stream_buffer::sample_t tnd_out = (t / 8227.0) + (n / 12241.0) + (d / 22638.0); + sound_stream::sample_t tnd_out = (t / 8227.0) + (n / 12241.0) + (d / 22638.0); tnd_out = (tnd_out == 0.0) ? 0.0 : 159.79 / ((1.0 / tnd_out) + 100.0); m_tnd_lut[t][n][d] = tnd_out; } @@ -766,12 +766,11 @@ u8 nesapu_device::status_r() // sound_stream_update - handle a stream update //------------------------------------------------- -void nesapu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void nesapu_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t accum = 0.0; - auto &output = outputs[0]; + sound_stream::sample_t accum = 0.0; - for (int sampindex = 0; sampindex < output.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { apu_square(&m_APU.squ[0]); apu_square(&m_APU.squ[1]); @@ -782,6 +781,6 @@ void nesapu_device::sound_stream_update(sound_stream &stream, std::vector<read_s accum = m_square_lut[m_APU.squ[0].output + m_APU.squ[1].output]; accum += m_tnd_lut[m_APU.tri.output][m_APU.noi.output][m_APU.dpcm.output]; - output.put(sampindex, accum); + stream.put(0, sampindex, accum); } } diff --git a/src/devices/sound/nes_apu.h b/src/devices/sound/nes_apu.h index d5004d99bfb..d43c50cb3d4 100644 --- a/src/devices/sound/nes_apu.h +++ b/src/devices/sound/nes_apu.h @@ -58,7 +58,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void update_lfsr(apu_t::noise_t &chan); @@ -76,8 +76,8 @@ private: u32 m_vbl_times[SYNCS_MAX1]; /* VBL durations in samples */ u32 m_sync_times1[SYNCS_MAX1]; /* Samples per sync table */ u32 m_sync_times2[SYNCS_MAX2]; /* Samples per sync table */ - stream_buffer::sample_t m_square_lut[31]; // Non-linear Square wave output LUT - stream_buffer::sample_t m_tnd_lut[16][16][128]; // Non-linear Triangle, Noise, DMC output LUT + sound_stream::sample_t m_square_lut[31]; // Non-linear Square wave output LUT + sound_stream::sample_t m_tnd_lut[16][16][128]; // Non-linear Triangle, Noise, DMC output LUT sound_stream *m_stream; devcb_write_line m_irq_handler; diff --git a/src/devices/sound/nn71003f.cpp b/src/devices/sound/nn71003f.cpp index b9d926a9855..a0bb5e21ccc 100644 --- a/src/devices/sound/nn71003f.cpp +++ b/src/devices/sound/nn71003f.cpp @@ -78,7 +78,7 @@ void nn71003f_device::clk_w(int state) logerror("clk_w %d\n", state); } -void nn71003f_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void nn71003f_device::sound_stream_update(sound_stream &stream) { } diff --git a/src/devices/sound/nn71003f.h b/src/devices/sound/nn71003f.h index bdf1803cf54..55b72707d6d 100644 --- a/src/devices/sound/nn71003f.h +++ b/src/devices/sound/nn71003f.h @@ -29,7 +29,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: devcb_write_line m_miso; diff --git a/src/devices/sound/okim6258.cpp b/src/devices/sound/okim6258.cpp index 171100e2080..712b3269f36 100644 --- a/src/devices/sound/okim6258.cpp +++ b/src/devices/sound/okim6258.cpp @@ -147,15 +147,13 @@ void okim6258_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6258_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (m_status & STATUS_PLAYING) { int nibble_shift = m_nibble_shift; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* Compute the new amplitude and update the current step */ int nibble = (m_data_in >> nibble_shift) & 0xf; @@ -165,16 +163,12 @@ void okim6258_device::sound_stream_update(sound_stream &stream, std::vector<read nibble_shift ^= 4; - buffer.put_int(sampindex, sample, 32768); + stream.put_int(0, sampindex, sample, 32768); } /* Update the parameters */ m_nibble_shift = nibble_shift; } - else - { - buffer.fill(0); - } } int16_t okim6258_device::clock_adpcm(uint8_t nibble) diff --git a/src/devices/sound/okim6258.h b/src/devices/sound/okim6258.h index 0efb74d6fb9..e20b4ec4553 100644 --- a/src/devices/sound/okim6258.h +++ b/src/devices/sound/okim6258.h @@ -47,7 +47,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: int16_t clock_adpcm(uint8_t nibble); diff --git a/src/devices/sound/okim6295.cpp b/src/devices/sound/okim6295.cpp index d4006fea1da..1101cbdfa2f 100644 --- a/src/devices/sound/okim6295.cpp +++ b/src/devices/sound/okim6295.cpp @@ -56,24 +56,24 @@ DEFINE_DEVICE_TYPE(OKIM6295, okim6295_device, "okim6295", "OKI MSM6295 ADPCM") // volume lookup table. The manual lists only 9 steps, ~3dB per step. Given the dB values, // that seems to map to a 5-bit volume control. Any volume parameter beyond the 9th index // results in silent playback. -const stream_buffer::sample_t okim6295_device::s_volume_table[16] = +const sound_stream::sample_t okim6295_device::s_volume_table[16] = { - stream_buffer::sample_t(0x20) / stream_buffer::sample_t(0x20), // 0 dB - stream_buffer::sample_t(0x16) / stream_buffer::sample_t(0x20), // -3.2 dB - stream_buffer::sample_t(0x10) / stream_buffer::sample_t(0x20), // -6.0 dB - stream_buffer::sample_t(0x0b) / stream_buffer::sample_t(0x20), // -9.2 dB - stream_buffer::sample_t(0x08) / stream_buffer::sample_t(0x20), // -12.0 dB - stream_buffer::sample_t(0x06) / stream_buffer::sample_t(0x20), // -14.5 dB - stream_buffer::sample_t(0x04) / stream_buffer::sample_t(0x20), // -18.0 dB - stream_buffer::sample_t(0x03) / stream_buffer::sample_t(0x20), // -20.5 dB - stream_buffer::sample_t(0x02) / stream_buffer::sample_t(0x20), // -24.0 dB - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), + sound_stream::sample_t(0x20) / sound_stream::sample_t(0x20), // 0 dB + sound_stream::sample_t(0x16) / sound_stream::sample_t(0x20), // -3.2 dB + sound_stream::sample_t(0x10) / sound_stream::sample_t(0x20), // -6.0 dB + sound_stream::sample_t(0x0b) / sound_stream::sample_t(0x20), // -9.2 dB + sound_stream::sample_t(0x08) / sound_stream::sample_t(0x20), // -12.0 dB + sound_stream::sample_t(0x06) / sound_stream::sample_t(0x20), // -14.5 dB + sound_stream::sample_t(0x04) / sound_stream::sample_t(0x20), // -18.0 dB + sound_stream::sample_t(0x03) / sound_stream::sample_t(0x20), // -20.5 dB + sound_stream::sample_t(0x02) / sound_stream::sample_t(0x20), // -24.0 dB + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), }; @@ -175,17 +175,11 @@ void okim6295_device::device_clock_changed() // our sound stream //------------------------------------------------- -void okim6295_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6295_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - // iterate over voices and accumulate sample data for (auto & elem : m_voice) - elem.generate_adpcm(*this, outputs[0]); - - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, std::clamp(outputs[0].getraw(i), -1.0f, 1.0f)); + elem.generate_adpcm(*this, stream); } @@ -341,21 +335,21 @@ okim6295_device::okim_voice::okim_voice() : // add them to an output stream //------------------------------------------------- -void okim6295_device::okim_voice::generate_adpcm(device_rom_interface &rom, write_stream_view &buffer) +void okim6295_device::okim_voice::generate_adpcm(device_rom_interface &rom, sound_stream &stream) { // skip if not active if (!m_playing) return; // loop while we still have samples to generate - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // fetch the next sample byte int nibble = rom.read_byte(m_base_offset + m_sample / 2) >> (((m_sample & 1) << 2) ^ 4); // output to the buffer, scaling by the volume // signal in range -2048..2047 - buffer.add_int(sampindex, m_adpcm.clock(nibble) * m_volume, 2048); + stream.add_int(0, sampindex, m_adpcm.clock(nibble) * m_volume, 2048); // next! if (++m_sample >= m_count) diff --git a/src/devices/sound/okim6295.h b/src/devices/sound/okim6295.h index ccf8f39f8a4..11a42f84aa1 100644 --- a/src/devices/sound/okim6295.h +++ b/src/devices/sound/okim6295.h @@ -60,7 +60,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; @@ -70,14 +70,14 @@ protected: { public: okim_voice(); - void generate_adpcm(device_rom_interface &rom, write_stream_view &buffer); + void generate_adpcm(device_rom_interface &rom, sound_stream &stream); oki_adpcm_state m_adpcm; // current ADPCM state bool m_playing; offs_t m_base_offset; // pointer to the base memory location uint32_t m_sample; // current sample number uint32_t m_count; // total samples to play - stream_buffer::sample_t m_volume; // output volume + sound_stream::sample_t m_volume; // output volume }; // configuration state @@ -91,7 +91,7 @@ protected: sound_stream * m_stream; uint8_t m_pin7_state; - static const stream_buffer::sample_t s_volume_table[16]; + static const sound_stream::sample_t s_volume_table[16]; }; diff --git a/src/devices/sound/okim6376.cpp b/src/devices/sound/okim6376.cpp index 7807a163e71..383c4a17e1d 100644 --- a/src/devices/sound/okim6376.cpp +++ b/src/devices/sound/okim6376.cpp @@ -386,10 +386,6 @@ void okim6376_device::generate_adpcm(struct ADPCMVoice *voice, int16_t *buffer, voice->count = count; } - /* fill the rest with silence */ - while (samples--) - *buffer++ = 0; - if ((!voice->playing)&&(m_stage[channel]))//end of samples, load anything staged in { m_stage[channel] = 0; @@ -581,14 +577,11 @@ void okim6376_device::write(uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void okim6376_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6376_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - for (int i = 0; i < OKIM6376_VOICES; i++) { struct ADPCMVoice *voice = &m_voice[i]; - auto &buffer = outputs[0]; int16_t sample_data[MAX_SAMPLE_CHUNK]; if (i == 0) //channel 1 is the only channel to affect NAR { @@ -603,19 +596,16 @@ void okim6376_device::sound_stream_update(sound_stream &stream, std::vector<read } /* loop while we have samples remaining */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int remaining = buffer.samples() - sampindex; + int remaining = stream.samples() - sampindex; int samples = (remaining > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : remaining; generate_adpcm(voice, sample_data, samples,i); for (int samp = 0; samp < samples; samp++) - buffer.add_int(sampindex + samp, sample_data[samp], 32768); + stream.add_int(0, sampindex + samp, sample_data[samp], 32768); sampindex += samples; } } - - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, std::clamp(outputs[0].getraw(i), -1.0f, 1.0f)); } diff --git a/src/devices/sound/okim6376.h b/src/devices/sound/okim6376.h index d7c334a4321..57b188fdf3f 100644 --- a/src/devices/sound/okim6376.h +++ b/src/devices/sound/okim6376.h @@ -32,7 +32,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/okim6588.cpp b/src/devices/sound/okim6588.cpp index de12b18664b..c745b42e555 100644 --- a/src/devices/sound/okim6588.cpp +++ b/src/devices/sound/okim6588.cpp @@ -88,10 +88,10 @@ void okim6588_device::device_reset() // internal handlers //------------------------------------------------- -void okim6588_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim6588_device::sound_stream_update(sound_stream &stream) { // simply fill the buffer with the current sample - outputs[0].fill(m_adpcm.output() / 2048.0); + stream.fill(0, m_adpcm.output() / 2048.0); } TIMER_CALLBACK_MEMBER(okim6588_device::clock_adpcm) diff --git a/src/devices/sound/okim6588.h b/src/devices/sound/okim6588.h index 12f66f08c1e..c94ac32393a 100644 --- a/src/devices/sound/okim6588.h +++ b/src/devices/sound/okim6588.h @@ -32,7 +32,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum chip_mode : u8 diff --git a/src/devices/sound/okim9810.cpp b/src/devices/sound/okim9810.cpp index eba777cf227..f9d0d6e26c6 100644 --- a/src/devices/sound/okim9810.cpp +++ b/src/devices/sound/okim9810.cpp @@ -219,21 +219,11 @@ void okim9810_device::rom_bank_pre_change() // our sound stream //------------------------------------------------- -void okim9810_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void okim9810_device::sound_stream_update(sound_stream &stream) { - // reset the output streams - outputs[0].fill(0); - outputs[1].fill(0); - // iterate over voices and accumulate sample data for (auto & elem : m_voice) - elem.generate_audio(*this, outputs, m_global_volume, m_filter_type); - - for (int i = 0; i < outputs[0].samples(); i++) - { - outputs[0].put(i, std::clamp(outputs[0].getraw(i), -1.0f, 1.0f)); - outputs[1].put(i, std::clamp(outputs[1].getraw(i), -1.0f, 1.0f)); - } + elem.generate_audio(*this, stream, m_global_volume, m_filter_type); } @@ -627,7 +617,7 @@ okim9810_device::okim_voice::okim_voice() //------------------------------------------------- void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, - std::vector<write_stream_view> &outputs, + sound_stream &stream, const uint8_t global_volume, const uint8_t filter_type) { @@ -635,10 +625,6 @@ void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, if (!m_playing) return; - // separate out left and right channels - auto &outL = outputs[0]; - auto &outR = outputs[1]; - // get left and right volumes uint8_t volume_scale_left = volume_scale(global_volume, m_channel_volume, m_pan_volume_left); uint8_t volume_scale_right = volume_scale(global_volume, m_channel_volume, m_pan_volume_right); @@ -649,7 +635,7 @@ void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, return; // loop while we still have samples to generate - for (int sampindex = 0; sampindex < outL.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if (m_phrase_state == SEQ_PAUSE) { @@ -814,10 +800,10 @@ void okim9810_device::okim_voice::generate_audio(device_rom_interface &rom, // output to the stereo buffers, scaling by the volume // signal in range -2048..2047, volume in range 2..128 => signal * volume / 8 in range -32768..32767 int32_t interpValueL = (interpValue * (int32_t)volume_scale_left); - outL.add_int(sampindex, interpValueL, 32768 * 8); + stream.add_int(0, sampindex, interpValueL, 32768 * 8); int32_t interpValueR = (interpValue * (int32_t)volume_scale_right); - outR.add_int(sampindex, interpValueR, 32768 * 8); + stream.add_int(1, sampindex, interpValueR, 32768 * 8); // if the interpsample has reached its end, move on to the next sample m_interpSampleNum++; diff --git a/src/devices/sound/okim9810.h b/src/devices/sound/okim9810.h index f5407702271..d44dcd5f12a 100644 --- a/src/devices/sound/okim9810.h +++ b/src/devices/sound/okim9810.h @@ -95,7 +95,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; @@ -106,7 +106,7 @@ protected: public: okim_voice(); void generate_audio(device_rom_interface &rom, - std::vector<write_stream_view> &buffers, + sound_stream &stream, const uint8_t global_volume, const uint8_t filter_type); diff --git a/src/devices/sound/pcd3311.cpp b/src/devices/sound/pcd3311.cpp index 4b5a4fb87f5..03e5cd2aa81 100644 --- a/src/devices/sound/pcd3311.cpp +++ b/src/devices/sound/pcd3311.cpp @@ -52,7 +52,6 @@ void pcd3311_device::device_start() // our sound stream //------------------------------------------------- -void pcd3311_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void pcd3311_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } diff --git a/src/devices/sound/pcd3311.h b/src/devices/sound/pcd3311.h index 29f6c49650a..840b9da69ad 100644 --- a/src/devices/sound/pcd3311.h +++ b/src/devices/sound/pcd3311.h @@ -48,7 +48,7 @@ protected: virtual void device_start() override ATTR_COLD; // internal callbacks - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: int m_a0; diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp index 35f389fcd58..8b1125495b5 100644 --- a/src/devices/sound/pokey.cpp +++ b/src/devices/sound/pokey.cpp @@ -724,10 +724,8 @@ void pokey_device::step_one_clock() // our sound stream //------------------------------------------------- -void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void pokey_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - if (m_output_type == LEGACY_LINEAR) { int32_t out = 0; @@ -735,8 +733,8 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st out += ((m_out_raw >> (4*i)) & 0x0f); out *= POKEY_DEFAULT_GAIN; out = (out > 0x7fff) ? 0x7fff : out; - stream_buffer::sample_t outsamp = out * stream_buffer::sample_t(1.0 / 32768.0); - buffer.fill(outsamp); + sound_stream::sample_t outsamp = out * sound_stream::sample_t(1.0 / 32768.0); + stream.fill(0, outsamp); } else if (m_output_type == RC_LOWPASS) { @@ -745,11 +743,11 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st double V0 = rTot / (rTot+m_r_pullup) * m_v_ref / 5.0; double mult = (m_cap == 0.0) ? 1.0 : 1.0 - exp(-(rTot + m_r_pullup) / (m_cap * m_r_pullup * rTot) * m_clock_period.as_double()); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* store sum of output signals into the buffer */ m_out_filter += (V0 - m_out_filter) * mult; - buffer.put(sampindex, m_out_filter); + stream.put(0, sampindex, m_out_filter); } } else if (m_output_type == OPAMP_C_TO_GROUND) @@ -765,7 +763,7 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st */ double V0 = ((rTot+m_r_pullup) / rTot - 1.0) * m_v_ref / 5.0; - buffer.fill(V0); + stream.fill(0, V0); } else if (m_output_type == OPAMP_LOW_PASS) { @@ -777,16 +775,16 @@ void pokey_device::sound_stream_update(sound_stream &stream, std::vector<read_st double V0 = (m_r_pullup / rTot) * m_v_ref / 5.0; double mult = (m_cap == 0.0) ? 1.0 : 1.0 - exp(-1.0 / (m_cap * m_r_pullup) * m_clock_period.as_double()); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* store sum of output signals into the buffer */ m_out_filter += (V0 - m_out_filter) * mult; - buffer.put(sampindex, m_out_filter); + stream.put(0, sampindex, m_out_filter); } } else if (m_output_type == DISCRETE_VAR_R) { - buffer.fill(m_voltab[m_out_raw]); + stream.fill(0, m_voltab[m_out_raw]); } } diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h index 065a98082be..f198b5820fb 100644 --- a/src/devices/sound/pokey.h +++ b/src/devices/sound/pokey.h @@ -182,7 +182,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void execute_run() override; @@ -302,7 +302,7 @@ private: uint32_t m_poly5[0x1f]; uint32_t m_poly9[0x1ff]; uint32_t m_poly17[0x1ffff]; - stream_buffer::sample_t m_voltab[0x10000]; + sound_stream::sample_t m_voltab[0x10000]; output_type m_output_type; double m_r_pullup; diff --git a/src/devices/sound/qs1000.cpp b/src/devices/sound/qs1000.cpp index b3f494890b4..b3e87b1515a 100644 --- a/src/devices/sound/qs1000.cpp +++ b/src/devices/sound/qs1000.cpp @@ -423,12 +423,8 @@ void qs1000_device::wave_w(offs_t offset, uint8_t data) //------------------------------------------------- // sound_stream_update - //------------------------------------------------- -void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void qs1000_device::sound_stream_update(sound_stream &stream) { - // Rset the output stream - outputs[0].fill(0); - outputs[1].fill(0); - // Iterate over voices and accumulate sample data for (auto & chan : m_channels) { @@ -440,7 +436,7 @@ void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_s { if (chan.m_flags & QS1000_ADPCM) { - for (int samp = 0; samp < outputs[0].samples(); samp++) + for (int samp = 0; samp < stream.samples(); samp++) { if (chan.m_addr >= chan.m_loop_end) { @@ -484,13 +480,13 @@ void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_s chan.m_addr = (chan.m_addr + (chan.m_acc >> 18)) & QS1000_ADDRESS_MASK; chan.m_acc &= ((1 << 18) - 1); - outputs[0].add_int(samp, result * 4 * lvol * vol, 32768 << 12); - outputs[1].add_int(samp, result * 4 * rvol * vol, 32768 << 12); + stream.add_int(0, samp, result * 4 * lvol * vol, 32768 << 12); + stream.add_int(1, samp, result * 4 * rvol * vol, 32768 << 12); } } else { - for (int samp = 0; samp < outputs[0].samples(); samp++) + for (int samp = 0; samp < stream.samples(); samp++) { if (chan.m_addr >= chan.m_loop_end) { @@ -513,8 +509,8 @@ void qs1000_device::sound_stream_update(sound_stream &stream, std::vector<read_s chan.m_addr = (chan.m_addr + (chan.m_acc >> 18)) & QS1000_ADDRESS_MASK; chan.m_acc &= ((1 << 18) - 1); - outputs[0].add_int(samp, result * lvol * vol, 32768 << 12); - outputs[1].add_int(samp, result * rvol * vol, 32768 << 12); + stream.add_int(0, samp, result * lvol * vol, 32768 << 12); + stream.add_int(1, samp, result * rvol * vol, 32768 << 12); } } } diff --git a/src/devices/sound/qs1000.h b/src/devices/sound/qs1000.h index 8f8e83355bf..6a45ce83f6b 100644 --- a/src/devices/sound/qs1000.h +++ b/src/devices/sound/qs1000.h @@ -70,7 +70,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/qsound.cpp b/src/devices/sound/qsound.cpp index e1b4966a78a..306b22d9c0b 100644 --- a/src/devices/sound/qsound.cpp +++ b/src/devices/sound/qsound.cpp @@ -257,10 +257,10 @@ void qsound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void qsound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void qsound_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(stream_buffer::sample_t(m_samples[0]) * (1.0 / 32768.0)); - outputs[1].fill(stream_buffer::sample_t(m_samples[1]) * (1.0 / 32768.0)); + stream.fill(0, sound_stream::sample_t(m_samples[0]) * (1.0 / 32768.0)); + stream.fill(1, sound_stream::sample_t(m_samples[1]) * (1.0 / 32768.0)); } diff --git a/src/devices/sound/qsound.h b/src/devices/sound/qsound.h index bb69f26bbdd..c26f78a405b 100644 --- a/src/devices/sound/qsound.h +++ b/src/devices/sound/qsound.h @@ -33,7 +33,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_post_change() override; diff --git a/src/devices/sound/qsoundhle.cpp b/src/devices/sound/qsoundhle.cpp index ed69b569cb5..f1f5684038e 100644 --- a/src/devices/sound/qsoundhle.cpp +++ b/src/devices/sound/qsoundhle.cpp @@ -162,13 +162,13 @@ void qsound_hle_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void qsound_hle_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void qsound_hle_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i ++) + for (int i = 0; i < stream.samples(); i ++) { update_sample(); - outputs[0].put_int(i, m_out[0], 32768); - outputs[1].put_int(i, m_out[1], 32768); + stream.put_int(0, i, m_out[0], 32768); + stream.put_int(1, i, m_out[1], 32768); } } diff --git a/src/devices/sound/qsoundhle.h b/src/devices/sound/qsoundhle.h index c978ddf1719..166a01aabfe 100644 --- a/src/devices/sound/qsoundhle.h +++ b/src/devices/sound/qsoundhle.h @@ -30,7 +30,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/rf5c400.cpp b/src/devices/sound/rf5c400.cpp index fc466fb0a0f..b4311fc7c57 100644 --- a/src/devices/sound/rf5c400.cpp +++ b/src/devices/sound/rf5c400.cpp @@ -205,7 +205,7 @@ void rf5c400_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void rf5c400_device::sound_stream_update(sound_stream &stream) { int i, ch; uint64_t start, end, loop; @@ -214,18 +214,9 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_ uint8_t env_phase; double env_level, env_step, env_rstep; - outputs[0].fill(0); - outputs[1].fill(0); - outputs[2].fill(0); - outputs[3].fill(0); - for (ch=0; ch < 32; ch++) { rf5c400_channel *channel = &m_channels[ch]; - auto &buf0 = outputs[0]; - auto &buf1 = outputs[1]; - auto &buf2 = outputs[2]; - auto &buf3 = outputs[3]; start = ((uint32_t)(channel->startH & 0xFF00) << 8) | channel->startL; end = ((uint32_t)(channel->endHloopH & 0xFF) << 16) | channel->endL; @@ -249,7 +240,7 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_ continue; } - for (i=0; i < buf0.samples(); i++) + for (i=0; i < stream.samples(); i++) { int16_t tmp; int32_t sample; @@ -319,10 +310,10 @@ void rf5c400_device::sound_stream_update(sound_stream &stream, std::vector<read_ sample *= volume_table[vol]; sample = (sample >> 9) * env_level; - buf0.add_int(i, sample * pan_table[lvol], 32768); - buf1.add_int(i, sample * pan_table[rvol], 32768); - buf2.add_int(i, sample * pan_table[effect_lvol], 32768); - buf3.add_int(i, sample * pan_table[effect_rvol], 32768); + stream.add_int(0, i, sample * pan_table[lvol], 32768); + stream.add_int(1, i, sample * pan_table[rvol], 32768); + stream.add_int(2, i, sample * pan_table[effect_lvol], 32768); + stream.add_int(3, i, sample * pan_table[effect_rvol], 32768); pos += channel->step; if ((pos>>16) > end) diff --git a/src/devices/sound/rf5c400.h b/src/devices/sound/rf5c400.h index e7789817903..bc380571086 100644 --- a/src/devices/sound/rf5c400.h +++ b/src/devices/sound/rf5c400.h @@ -34,7 +34,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/rf5c68.cpp b/src/devices/sound/rf5c68.cpp index 09fd397d4fb..c7c062ddbd8 100644 --- a/src/devices/sound/rf5c68.cpp +++ b/src/devices/sound/rf5c68.cpp @@ -119,26 +119,19 @@ device_memory_interface::space_config_vector rf5c68_device::memory_space_config( // sound_stream_update - handle a stream update //------------------------------------------------- -void rf5c68_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void rf5c68_device::sound_stream_update(sound_stream &stream) { - auto &left = outputs[0]; - auto &right = outputs[1]; - /* bail if not enabled */ if (!m_enable) - { - left.fill(0); - right.fill(0); return; - } - if (m_mixleft.size() < left.samples()) - m_mixleft.resize(left.samples()); - if (m_mixright.size() < right.samples()) - m_mixright.resize(right.samples()); + if (m_mixleft.size() < stream.samples()) + m_mixleft.resize(stream.samples()); + if (m_mixright.size() < stream.samples()) + m_mixright.resize(stream.samples()); - std::fill_n(&m_mixleft[0], left.samples(), 0); - std::fill_n(&m_mixright[0], right.samples(), 0); + std::fill_n(&m_mixleft[0], stream.samples(), 0); + std::fill_n(&m_mixright[0], stream.samples(), 0); /* loop over channels */ for (pcm_channel &chan : m_chan) @@ -150,7 +143,7 @@ void rf5c68_device::sound_stream_update(sound_stream &stream, std::vector<read_s int rv = ((chan.pan >> 4) & 0x0f) * chan.env; /* loop over the sample buffer */ - for (int j = 0; j < left.samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int sample; @@ -196,10 +189,10 @@ void rf5c68_device::sound_stream_update(sound_stream &stream, std::vector<read_s */ const u8 output_shift = (m_output_bits > 16) ? 0 : (16 - m_output_bits); const s32 output_nandmask = (1 << output_shift) - 1; - for (int j = 0; j < left.samples(); j++) + for (int j = 0; j < stream.samples(); j++) { - left.put_int_clamp(j, m_mixleft[j] & ~output_nandmask, 32768); - right.put_int_clamp(j, m_mixright[j] & ~output_nandmask, 32768); + stream.put_int_clamp(0, j, m_mixleft[j] & ~output_nandmask, 32768); + stream.put_int_clamp(1, j, m_mixright[j] & ~output_nandmask, 32768); } } diff --git a/src/devices/sound/rf5c68.h b/src/devices/sound/rf5c68.h index 5b67e2e65b5..f95dc124650 100644 --- a/src/devices/sound/rf5c68.h +++ b/src/devices/sound/rf5c68.h @@ -45,7 +45,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/roland_gp.cpp b/src/devices/sound/roland_gp.cpp index fb6c4f208c2..9ae0d449ae7 100644 --- a/src/devices/sound/roland_gp.cpp +++ b/src/devices/sound/roland_gp.cpp @@ -73,6 +73,6 @@ void tc6116_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void tc6116_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tc6116_device::sound_stream_update(sound_stream &stream) { } diff --git a/src/devices/sound/roland_gp.h b/src/devices/sound/roland_gp.h index 555d814bb07..48854950817 100644 --- a/src/devices/sound/roland_gp.h +++ b/src/devices/sound/roland_gp.h @@ -25,7 +25,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/roland_lp.cpp b/src/devices/sound/roland_lp.cpp index fd63f56cf76..fe918d080f0 100644 --- a/src/devices/sound/roland_lp.cpp +++ b/src/devices/sound/roland_lp.cpp @@ -256,17 +256,14 @@ void mb87419_mb87420_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void mb87419_mb87420_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void mb87419_mb87420_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - for (auto& chn : m_chns) { if (! chn.enable || chn.play_dir == 0) continue; - for (int smpl = 0; smpl < outputs[0].samples(); smpl ++) + for (int smpl = 0; smpl < stream.samples(); smpl ++) { s32 smp_data; if (chn.play_dir > 0) @@ -274,8 +271,8 @@ void mb87419_mb87420_device::sound_stream_update(sound_stream &stream, std::vect else smp_data = sample_interpolate(chn.smpl_nxt, chn.smpl_cur, chn.addr & 0x3FFF); smp_data = smp_data * chn.volume; - outputs[0].add_int(smpl, smp_data, 32768 << 14); // >>14 results in a good overall volume - outputs[1].add_int(smpl, smp_data, 32768 << 14); + stream.add_int(0, smpl, smp_data, 32768 << 14); // >>14 results in a good overall volume + stream.add_int(1, smpl, smp_data, 32768 << 14); uint32_t old_addr = chn.addr; if (chn.play_dir > 0) diff --git a/src/devices/sound/roland_lp.h b/src/devices/sound/roland_lp.h index 3d9ced433d2..cc40a33d8c5 100644 --- a/src/devices/sound/roland_lp.h +++ b/src/devices/sound/roland_lp.h @@ -23,7 +23,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/roland_sa.cpp b/src/devices/sound/roland_sa.cpp index 9802d371368..2c365e2552d 100644 --- a/src/devices/sound/roland_sa.cpp +++ b/src/devices/sound/roland_sa.cpp @@ -264,12 +264,8 @@ void roland_sa_device::write(offs_t offset, u8 data) m_ctrl_mem[offset] = data; } -void roland_sa_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void roland_sa_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - - std::unique_ptr<int32_t []> int_buffer = make_unique_clear<int32_t []>(outputs[0].samples()); - for (size_t voiceI = 0; voiceI < NUM_VOICES; voiceI++) { for (size_t partI = 0; partI < PARTS_PER_VOICE; partI++) @@ -393,7 +389,7 @@ void roland_sa_device::sound_stream_update(sound_stream &stream, std::vector<rea exp_val2 = exp_val2 - 0x8000; int32_t exp_val = exp_val1 + exp_val2; - int_buffer[i] += exp_val; + stream.add_int(0, i, exp_val, 0x10000); } } @@ -405,7 +401,4 @@ void roland_sa_device::sound_stream_update(sound_stream &stream, std::vector<rea } } } - - for (size_t i = 0; i < outputs[0].samples(); i++) - outputs[0].put_int(i, int_buffer[i], 0xffff); } diff --git a/src/devices/sound/roland_sa.h b/src/devices/sound/roland_sa.h index 21c6440722c..3f88e910625 100644 --- a/src/devices/sound/roland_sa.h +++ b/src/devices/sound/roland_sa.h @@ -24,7 +24,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned NUM_VOICES = 16; diff --git a/src/devices/sound/rp2c33_snd.cpp b/src/devices/sound/rp2c33_snd.cpp index e50ce857f89..43cfbf46049 100644 --- a/src/devices/sound/rp2c33_snd.cpp +++ b/src/devices/sound/rp2c33_snd.cpp @@ -221,9 +221,9 @@ void rp2c33_sound_device::write(offs_t offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void rp2c33_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void rp2c33_sound_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { m_output = 0; if (!m_env_halt && !m_wave_halt) @@ -234,7 +234,7 @@ void rp2c33_sound_device::sound_stream_update(sound_stream &stream, std::vector< exec_mod(); exec_wave(); /* Update the buffers */ - outputs[0].put_int(i, m_output * m_mvol_table[m_mvol], 32768); + stream.put_int(0, i, m_output * m_mvol_table[m_mvol], 32768); } } diff --git a/src/devices/sound/rp2c33_snd.h b/src/devices/sound/rp2c33_snd.h index fb125b56747..f6005092344 100644 --- a/src/devices/sound/rp2c33_snd.h +++ b/src/devices/sound/rp2c33_snd.h @@ -43,7 +43,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream = nullptr; diff --git a/src/devices/sound/s14001a.cpp b/src/devices/sound/s14001a.cpp index 64e23033206..6e8c871d6f5 100644 --- a/src/devices/sound/s14001a.cpp +++ b/src/devices/sound/s14001a.cpp @@ -297,13 +297,13 @@ void s14001a_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void s14001a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void s14001a_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { Clock(); s16 sample = m_uOutputP2 - 7; // range -7..8 - outputs[0].put_int(i, sample, 8); + stream.put_int(0, i, sample, 8); } } diff --git a/src/devices/sound/s14001a.h b/src/devices/sound/s14001a.h index 814f0a7795c..c430963f4e4 100644 --- a/src/devices/sound/s14001a.h +++ b/src/devices/sound/s14001a.h @@ -32,7 +32,7 @@ protected: virtual void rom_bank_pre_change() override { m_stream->update(); } // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: u8 ReadMem(u16 offset, bool phase); diff --git a/src/devices/sound/s_dsp.cpp b/src/devices/sound/s_dsp.cpp index cb29aa52eb2..b2248b4ef71 100644 --- a/src/devices/sound/s_dsp.cpp +++ b/src/devices/sound/s_dsp.cpp @@ -979,17 +979,17 @@ void s_dsp_device::state_register() // sound_stream_update - handle a stream update //------------------------------------------------- -void s_dsp_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void s_dsp_device::sound_stream_update(sound_stream &stream) { s16 mix[2]; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { mix[0] = mix[1] = 0; dsp_update(mix); /* Update the buffers */ - outputs[0].put_int_clamp(i, (s32)mix[0], 32768); - outputs[1].put_int_clamp(i, (s32)mix[1], 32768); + stream.put_int(0, i, (s32)mix[0], 32768); + stream.put_int(1, i, (s32)mix[1], 32768); } } diff --git a/src/devices/sound/s_dsp.h b/src/devices/sound/s_dsp.h index 568c5c51fe3..7102d077b47 100644 --- a/src/devices/sound/s_dsp.h +++ b/src/devices/sound/s_dsp.h @@ -30,7 +30,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/saa1099.cpp b/src/devices/sound/saa1099.cpp index 682cbb5873f..dd5f6154afd 100644 --- a/src/devices/sound/saa1099.cpp +++ b/src/devices/sound/saa1099.cpp @@ -203,17 +203,12 @@ void saa1099_device::device_clock_changed() // sound_stream_update - handle a stream update //------------------------------------------------- -void saa1099_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void saa1099_device::sound_stream_update(sound_stream &stream) { int j, ch; /* if the channels are disabled we're done */ if (!m_all_ch_enable) - { - /* init output data */ - outputs[LEFT].fill(0); - outputs[RIGHT].fill(0); return; - } for (ch = 0; ch < 2; ch++) { @@ -227,7 +222,7 @@ void saa1099_device::sound_stream_update(sound_stream &stream, std::vector<read_ } /* fill all data needed */ - for( j = 0; j < outputs[0].samples(); j++ ) + for( j = 0; j < stream.samples(); j++ ) { int output_l = 0, output_r = 0; @@ -300,8 +295,8 @@ void saa1099_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_noise[ch].counter -= clock_divider; } /* write sound data to the buffer */ - outputs[LEFT].put_int(j, output_l, 32768 * 6); - outputs[RIGHT].put_int(j, output_r, 32768 * 6); + stream.put_int(LEFT, j, output_l, 32768 * 6); + stream.put_int(RIGHT, j, output_r, 32768 * 6); } } diff --git a/src/devices/sound/saa1099.h b/src/devices/sound/saa1099.h index fec5ccdc692..25433940c99 100644 --- a/src/devices/sound/saa1099.h +++ b/src/devices/sound/saa1099.h @@ -32,7 +32,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct saa1099_channel diff --git a/src/devices/sound/samples.cpp b/src/devices/sound/samples.cpp index afd72f5391a..4a1d527a958 100644 --- a/src/devices/sound/samples.cpp +++ b/src/devices/sound/samples.cpp @@ -315,34 +315,33 @@ void samples_device::device_post_load() // sound_stream_update - update a sound stream //------------------------------------------------- -void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void samples_device::sound_stream_update(sound_stream &stream) { // find the channel with this stream - constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; + constexpr sound_stream::sample_t sample_scale = 1.0 / 32768.0; for (int channel = 0; channel < m_channels; channel++) if (&stream == m_channel[channel].stream) { channel_t &chan = m_channel[channel]; - auto &buffer = outputs[0]; // process if we still have a source and we're not paused if (chan.source != nullptr && !chan.paused) { // load some info locally - double step = double(chan.curfreq) / double(buffer.sample_rate()); + double step = double(chan.curfreq) / double(stream.sample_rate()); double endpos = chan.source_len; const int16_t *sample = chan.source; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // do a linear interp on the sample double pos_floor = floor(chan.pos); double frac = chan.pos - pos_floor; int32_t ipos = int32_t(pos_floor); - stream_buffer::sample_t sample1 = stream_buffer::sample_t(sample[ipos++]); - stream_buffer::sample_t sample2 = stream_buffer::sample_t(sample[(ipos + 1) % chan.source_len]); - buffer.put(sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2)); + sound_stream::sample_t sample1 = sound_stream::sample_t(sample[ipos++]); + sound_stream::sample_t sample2 = sound_stream::sample_t(sample[(ipos + 1) % chan.source_len]); + stream.put(0, sampindex, sample_scale * ((1.0 - frac) * sample1 + frac * sample2)); // advance chan.pos += step; @@ -356,14 +355,11 @@ void samples_device::sound_stream_update(sound_stream &stream, std::vector<read_ { chan.source = nullptr; chan.source_num = -1; - buffer.fill(0, sampindex); break; } } } } - else - buffer.fill(0); break; } } diff --git a/src/devices/sound/samples.h b/src/devices/sound/samples.h index dae042016c6..975b85e5bdf 100644 --- a/src/devices/sound/samples.h +++ b/src/devices/sound/samples.h @@ -78,7 +78,7 @@ protected: virtual void device_post_load() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // internal classes struct channel_t diff --git a/src/devices/sound/scsp.cpp b/src/devices/sound/scsp.cpp index 2caec3580ae..ee0d31e4778 100644 --- a/src/devices/sound/scsp.cpp +++ b/src/devices/sound/scsp.cpp @@ -310,9 +310,9 @@ void scsp_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void scsp_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void scsp_device::sound_stream_update(sound_stream &stream) { - DoMasterSamples(inputs, outputs); + DoMasterSamples(stream); } u8 scsp_device::DecodeSCI(u8 irq) @@ -1264,12 +1264,9 @@ inline s32 scsp_device::UpdateSlot(SCSP_SLOT *slot) return sample; } -void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void scsp_device::DoMasterSamples(sound_stream &stream) { - auto &bufr = outputs[1]; - auto &bufl = outputs[0]; - - for (int s = 0; s < bufl.samples(); ++s) + for (int s = 0; s < stream.samples(); ++s) { s32 smpl = 0, smpr = 0; @@ -1325,7 +1322,7 @@ void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, s SCSP_SLOT *slot = m_Slots + i + 16; // 100217, 100237 EFSDL, EFPAN for EXTS0/1 if (EFSDL(slot)) { - m_DSP.EXTS[i] = s32(inputs[i].get(s) * 32768.0); + m_DSP.EXTS[i] = s32(stream.get(i, s) * 32768.0); u16 Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd); smpl += (m_DSP.EXTS[i] * m_LPANTABLE[Enc]) >> SHIFT; smpr += (m_DSP.EXTS[i] * m_RPANTABLE[Enc]) >> SHIFT; @@ -1334,13 +1331,13 @@ void scsp_device::DoMasterSamples(std::vector<read_stream_view> const &inputs, s if (DAC18B()) { - bufl.put_int_clamp(s, smpl, 131072); - bufr.put_int_clamp(s, smpr, 131072); + stream.put_int_clamp(0, s, smpl, 131072); + stream.put_int_clamp(1, s, smpr, 131072); } else { - bufl.put_int_clamp(s, smpl >> 2, 32768); - bufr.put_int_clamp(s, smpr >> 2, 32768); + stream.put_int_clamp(0, s, smpl >> 2, 32768); + stream.put_int_clamp(1, s, smpr >> 2, 32768); } } } diff --git a/src/devices/sound/scsp.h b/src/devices/sound/scsp.h index 9b02afd4767..4ec5d60f44b 100644 --- a/src/devices/sound/scsp.h +++ b/src/devices/sound/scsp.h @@ -48,7 +48,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum SCSP_STATE { SCSP_ATTACK, SCSP_DECAY1, SCSP_DECAY2, SCSP_RELEASE }; @@ -184,7 +184,7 @@ private: void w16(u32 addr, u16 val); u16 r16(u32 addr); inline s32 UpdateSlot(SCSP_SLOT *slot); - void DoMasterSamples(std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs); + void DoMasterSamples(sound_stream &stream); //LFO void LFO_Init(); diff --git a/src/devices/sound/segapcm.cpp b/src/devices/sound/segapcm.cpp index 9f7a9b6fc63..81f6ceffec9 100644 --- a/src/devices/sound/segapcm.cpp +++ b/src/devices/sound/segapcm.cpp @@ -72,12 +72,8 @@ void segapcm_device::rom_bank_pre_change() // sound_stream_update - handle a stream update //------------------------------------------------- -void segapcm_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void segapcm_device::sound_stream_update(sound_stream &stream) { - /* clear the buffers */ - outputs[0].fill(0); - outputs[1].fill(0); - // reg function // ------------------------------------------------ // 0x00 ? @@ -114,7 +110,7 @@ void segapcm_device::sound_stream_update(sound_stream &stream, std::vector<read_ int i; /* loop over samples on this channel */ - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int8_t v; @@ -133,8 +129,8 @@ void segapcm_device::sound_stream_update(sound_stream &stream, std::vector<read_ v = read_byte(offset + (addr >> 8)) - 0x80; /* apply panning and advance */ - outputs[0].add_int(i, v * (regs[2] & 0x7f), 32768); - outputs[1].add_int(i, v * (regs[3] & 0x7f), 32768); + stream.add_int(0, i, v * (regs[2] & 0x7f), 32768); + stream.add_int(1, i, v * (regs[3] & 0x7f), 32768); addr = (addr + regs[7]) & 0xffffff; } diff --git a/src/devices/sound/segapcm.h b/src/devices/sound/segapcm.h index c89ab3e1859..673c8075f27 100644 --- a/src/devices/sound/segapcm.h +++ b/src/devices/sound/segapcm.h @@ -41,7 +41,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/setapcm.cpp b/src/devices/sound/setapcm.cpp index ab002f68f10..c2eba36d31d 100644 --- a/src/devices/sound/setapcm.cpp +++ b/src/devices/sound/setapcm.cpp @@ -142,20 +142,17 @@ void setapcm_device<MaxVoices, Divider>::device_clock_changed() //------------------------------------------------- template<unsigned MaxVoices, unsigned Divider> -void setapcm_device<MaxVoices, Divider>::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void setapcm_device<MaxVoices, Divider>::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - - for (int sampleind = 0; sampleind < outputs[0].samples(); sampleind++) + for (int sampleind = 0; sampleind < stream.samples(); sampleind++) { for (int v = 0; v < MAX_VOICES; v++) { // check if voice is activated if (m_voice[v].update()) { - outputs[0].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 16, 32768 * MAX_VOICES); - outputs[1].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 16, 32768 * MAX_VOICES); + stream.add_int(0, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 16, 32768 * MAX_VOICES); + stream.add_int(1, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 16, 32768 * MAX_VOICES); } } } diff --git a/src/devices/sound/setapcm.h b/src/devices/sound/setapcm.h index bf55b14d460..fbd809cab9e 100644 --- a/src/devices/sound/setapcm.h +++ b/src/devices/sound/setapcm.h @@ -38,7 +38,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface implementation virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/sid.cpp b/src/devices/sound/sid.cpp index 86264810fda..7f7292a57be 100644 --- a/src/devices/sound/sid.cpp +++ b/src/devices/sound/sid.cpp @@ -29,9 +29,9 @@ float filterResTable[16]; #define maxLogicalVoices 4 -inline stream_buffer::sample_t mix_mono(uint16_t usum) +inline sound_stream::sample_t mix_mono(uint16_t usum) { - return stream_buffer::sample_t(int16_t(usum - maxLogicalVoices*128)) * (1.0 / (256 * maxLogicalVoices)); + return sound_stream::sample_t(int16_t(usum - maxLogicalVoices*128)) * (1.0 / (256 * maxLogicalVoices)); } } // anonymous namespace @@ -61,13 +61,13 @@ inline void SID6581_t::syncEm() } -void SID6581_t::fill_buffer(write_stream_view &buffer) +void SID6581_t::fill_buffer(sound_stream &stream) { //void* SID6581_t::fill16bitMono(void* buffer, uint32_t numberOfSamples) - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put(sampindex, mix_mono( + stream.put(0, sampindex, mix_mono( (*optr[0].outProc)(&optr[0]) +(*optr[1].outProc)(&optr[1]) +((*optr[2].outProc)(&optr[2])&optr3_outputmask) diff --git a/src/devices/sound/sid.h b/src/devices/sound/sid.h index 0b0af441879..45f900758f5 100644 --- a/src/devices/sound/sid.h +++ b/src/devices/sound/sid.h @@ -63,7 +63,7 @@ struct SID6581_t int port_r(running_machine &machine, int offset); void port_w(int offset, int data); - void fill_buffer(write_stream_view &buffer); + void fill_buffer(sound_stream &stream); private: void syncEm(); diff --git a/src/devices/sound/sn76477.cpp b/src/devices/sound/sn76477.cpp index 1ed2f8b57fe..ec855769be6 100644 --- a/src/devices/sound/sn76477.cpp +++ b/src/devices/sound/sn76477.cpp @@ -1700,7 +1700,7 @@ void sn76477_device::state_save_register() // sound_stream_update - handle a stream update //------------------------------------------------- -void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sn76477_device::sound_stream_update(sound_stream &stream) { double one_shot_cap_charging_step; double one_shot_cap_discharging_step; @@ -1719,8 +1719,6 @@ void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_ double voltage_out; double center_to_peak_voltage_out; - auto &buffer = outputs[0]; - /* compute charging values, doing it here ensures that we always use the latest values */ one_shot_cap_charging_step = compute_one_shot_cap_charging_rate() / m_our_sample_rate; one_shot_cap_discharging_step = compute_one_shot_cap_discharging_rate() / m_our_sample_rate; @@ -1743,7 +1741,7 @@ void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_ /* process 'samples' number of samples */ - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* update the one-shot cap voltage */ if (!m_one_shot_cap_voltage_ext) @@ -1995,7 +1993,7 @@ void sn76477_device::sound_stream_update(sound_stream &stream, std::vector<read_ sample = | ----------- - 1 | \ Vcen - Vmin / */ - buffer.put(sampindex, ((voltage_out - OUT_LOW_CLIP_THRESHOLD) / (OUT_CENTER_LEVEL_VOLTAGE - OUT_LOW_CLIP_THRESHOLD)) - 1); + stream.put(0, sampindex, ((voltage_out - OUT_LOW_CLIP_THRESHOLD) / (OUT_CENTER_LEVEL_VOLTAGE - OUT_LOW_CLIP_THRESHOLD)) - 1); if (LOG_WAV && (!m_enable || !LOG_WAV_ENABLED_ONLY)) { diff --git a/src/devices/sound/sn76477.h b/src/devices/sound/sn76477.h index c37a7326b4c..dd4e89a50e2 100644 --- a/src/devices/sound/sn76477.h +++ b/src/devices/sound/sn76477.h @@ -149,7 +149,7 @@ protected: virtual void device_stop() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: /* chip's external interface */ diff --git a/src/devices/sound/sn76496.cpp b/src/devices/sound/sn76496.cpp index 923a1d890d8..38a0c71faf5 100644 --- a/src/devices/sound/sn76496.cpp +++ b/src/devices/sound/sn76496.cpp @@ -365,16 +365,14 @@ inline bool sn76496_base_device::in_noise_mode() return ((m_register[6] & 4)!=0); } -void sn76496_base_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sn76496_base_device::sound_stream_update(sound_stream &stream) { int i; - auto *lbuffer = &outputs[0]; - auto *rbuffer = m_stereo ? &outputs[1] : nullptr; int16_t out; int16_t out2 = 0; - for (int sampindex = 0; sampindex < lbuffer->samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { // clock chip once if (m_current_clock > 0) // not ready for new divided clock @@ -440,9 +438,9 @@ void sn76496_base_device::sound_stream_update(sound_stream &stream, std::vector< if (m_negate) { out = -out; out2 = -out2; } - lbuffer->put_int(sampindex, out, 32768); + stream.put_int(0, sampindex, out, 32768); if (m_stereo) - rbuffer->put_int(sampindex, out2, 32768); + stream.put_int(1, sampindex, out2, 32768); } } diff --git a/src/devices/sound/sn76496.h b/src/devices/sound/sn76496.h index cbe73e7e6e7..46471398f02 100644 --- a/src/devices/sound/sn76496.h +++ b/src/devices/sound/sn76496.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_ready); diff --git a/src/devices/sound/snkwave.cpp b/src/devices/sound/snkwave.cpp index 9bd3ac62053..d11db0dc957 100644 --- a/src/devices/sound/snkwave.cpp +++ b/src/devices/sound/snkwave.cpp @@ -64,22 +64,17 @@ void snkwave_device::device_start() // for our sound stream //------------------------------------------------- -void snkwave_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void snkwave_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - assert(m_counter < 0x1000); assert(m_frequency < 0x1000); /* if no sound, we're done */ if (m_frequency == 0xfff) - { - buffer.fill(0); return; - } /* generate sound into buffer while updating the counter */ - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int loops; int16_t out = 0; @@ -104,7 +99,7 @@ void snkwave_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - buffer.put_int(sampindex, out, 32768); + stream.put_int(0, sampindex, out, 32768); } } diff --git a/src/devices/sound/snkwave.h b/src/devices/sound/snkwave.h index 091bd4e12e8..75b8c88e5b5 100644 --- a/src/devices/sound/snkwave.h +++ b/src/devices/sound/snkwave.h @@ -26,7 +26,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned WAVEFORM_LENGTH = 16; diff --git a/src/devices/sound/sp0250.cpp b/src/devices/sound/sp0250.cpp index 2c4384888e9..763fc5b11e0 100644 --- a/src/devices/sound/sp0250.cpp +++ b/src/devices/sound/sp0250.cpp @@ -257,18 +257,16 @@ int8_t sp0250_device::next() // sound_stream_update - handle a stream update //------------------------------------------------- -void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sp0250_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; - if (!m_pwm_mode) { - for (int sampindex = 0; sampindex < output.samples(); sampindex++) - output.put_int(sampindex, next(), 128); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put_int(0, sampindex, next(), 128); } else { - for (int sampindex = 0; sampindex < output.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { // see where we're at in the current PWM cycle if (m_pwm_index >= PWM_CLOCKS) @@ -282,7 +280,7 @@ void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_s // determine the value to fill and the number of samples remaining // until it changes - stream_buffer::sample_t value; + sound_stream::sample_t value; int remaining; if (m_pwm_index < m_pwm_count) { @@ -296,13 +294,13 @@ void sp0250_device::sound_stream_update(sound_stream &stream, std::vector<read_s } // clamp to the number of samples requested and advance the counters - if (remaining > output.samples() - sampindex) - remaining = output.samples() - sampindex; + if (remaining > stream.samples() - sampindex) + remaining = stream.samples() - sampindex; m_pwm_index += remaining; // fill the output while (remaining-- != 0) - outputs[0].put(sampindex++, value); + stream.put(0, sampindex++, value); } } } diff --git a/src/devices/sound/sp0250.h b/src/devices/sound/sp0250.h index fdba7710007..0becd7c93e6 100644 --- a/src/devices/sound/sp0250.h +++ b/src/devices/sound/sp0250.h @@ -22,7 +22,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); } private: diff --git a/src/devices/sound/sp0256.cpp b/src/devices/sound/sp0256.cpp index 3486f710be3..ba84d002eb5 100644 --- a/src/devices/sound/sp0256.cpp +++ b/src/devices/sound/sp0256.cpp @@ -1259,12 +1259,11 @@ void sp0256_device::set_clock(int clock) // sound_stream_update - handle a stream update //------------------------------------------------- -void sp0256_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sp0256_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; int output_index = 0; - while (output_index < output.samples()) + while (output_index < stream.samples()) { /* ---------------------------------------------------------------- */ /* First, drain as much of our scratch buffer as we can into the */ @@ -1272,20 +1271,20 @@ void sp0256_device::sound_stream_update(sound_stream &stream, std::vector<read_s /* ---------------------------------------------------------------- */ while (m_sc_tail != m_sc_head) { - output.put_int(output_index++, m_scratch[m_sc_tail++ & SCBUF_MASK], 32768); + stream.put_int(0, output_index++, m_scratch[m_sc_tail++ & SCBUF_MASK], 32768); m_sc_tail &= SCBUF_MASK; - if (output_index >= output.samples()) + if (output_index >= stream.samples()) break; } /* ---------------------------------------------------------------- */ /* If output outputs is full, then we're done. */ /* ---------------------------------------------------------------- */ - if (output_index > output.samples()) + if (output_index > stream.samples()) break; - int length = output.samples() - output_index; + int length = stream.samples() - output_index; /* ---------------------------------------------------------------- */ /* Process the current set of filter coefficients as long as the */ diff --git a/src/devices/sound/sp0256.h b/src/devices/sound/sp0256.h index bc7beda7433..eee0a3c05a5 100644 --- a/src/devices/sound/sp0256.h +++ b/src/devices/sound/sp0256.h @@ -60,7 +60,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update) { m_stream->update(); } private: diff --git a/src/devices/sound/spkrdev.cpp b/src/devices/sound/spkrdev.cpp index 19d1f1813d6..841656ab4ac 100644 --- a/src/devices/sound/spkrdev.cpp +++ b/src/devices/sound/spkrdev.cpp @@ -187,19 +187,18 @@ void speaker_sound_device::device_post_load() //------------------------------------------------- // This can be triggered by the core (based on emulated time) or via level_w(). -void speaker_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void speaker_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; double volume = m_levels[m_level]; double filtered_volume; attotime sampled_time = attotime::zero; - if (buffer.samples() > 0) + if (stream.samples() > 0) { /* Prepare to update time state */ sampled_time = attotime(0, m_channel_sample_period); - if (buffer.samples() > 1) - sampled_time *= buffer.samples(); + if (stream.samples() > 1) + sampled_time *= stream.samples(); /* Note: since the stream is in the process of being updated, * stream->sample_time() will return the time before the update! (MAME 0.130) @@ -207,19 +206,19 @@ void speaker_sound_device::sound_stream_update(sound_stream &stream, std::vector */ } - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { /* Note that first intermediate sample may be composed... */ filtered_volume = update_interm_samples_get_filtered_volume(volume); /* Composite volume is now quantized to the stream resolution */ - buffer.put(sampindex++, filtered_volume); + stream.put(0, sampindex++, filtered_volume); /* Any additional samples will be homogeneous, however may need filtering across samples: */ - while (sampindex < buffer.samples()) + while (sampindex < stream.samples()) { filtered_volume = update_interm_samples_get_filtered_volume(volume); - buffer.put(sampindex++, filtered_volume); + stream.put(0, sampindex++, filtered_volume); } /* Update the time state */ diff --git a/src/devices/sound/spkrdev.h b/src/devices/sound/spkrdev.h index 24a76d78c4c..175cc1f5996 100644 --- a/src/devices/sound/spkrdev.h +++ b/src/devices/sound/spkrdev.h @@ -32,7 +32,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // Length of anti-aliasing filter kernel, measured in number of intermediate samples diff --git a/src/devices/sound/spu.cpp b/src/devices/sound/spu.cpp index 848e432cb02..e6b5d2e5fa3 100644 --- a/src/devices/sound/spu.cpp +++ b/src/devices/sound/spu.cpp @@ -2769,20 +2769,17 @@ void spu_device::update_timing() // // -void spu_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void spu_device::sound_stream_update(sound_stream &stream) { int16_t temp[44100], *src; - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - generate(temp, outputs[0].samples()*4); // second parameter is bytes, * 2 (size of int16_t) * 2 (stereo) + generate(temp, stream.samples()*4); // second parameter is bytes, * 2 (size of int16_t) * 2 (stereo) src = &temp[0]; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - outL.put_int(i, *src++, 32768); - outR.put_int(i, *src++, 32768); + stream.put_int(0, i, *src++, 32768); + stream.put_int(1, i, *src++, 32768); } } diff --git a/src/devices/sound/spu.h b/src/devices/sound/spu.h index e2641cd5a49..ff51c9c378d 100644 --- a/src/devices/sound/spu.h +++ b/src/devices/sound/spu.h @@ -36,7 +36,7 @@ protected: virtual void device_post_load() override; virtual void device_stop() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; float spu_base_frequency_hz; float linear_rate[108]; diff --git a/src/devices/sound/ssi263hle.cpp b/src/devices/sound/ssi263hle.cpp index 738b6c61084..8ae56fa93f4 100644 --- a/src/devices/sound/ssi263hle.cpp +++ b/src/devices/sound/ssi263hle.cpp @@ -41,7 +41,7 @@ static const u8 PHONEMES_TO_SC01[0x40] = ssi263hle_device::ssi263hle_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, SSI263HLE, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 1) + , device_mixer_interface(mconfig, *this) , m_votrax(*this, "votrax") , m_ar_cb(*this) , m_phoneme_timer(nullptr) @@ -116,7 +116,7 @@ void ssi263hle_device::device_add_mconfig(machine_config &config) { VOTRAX_SC01(config, m_votrax, DERIVED_CLOCK(1, 1)); m_votrax->ar_callback().set(FUNC(ssi263hle_device::votrax_request)); - m_votrax->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_votrax->add_route(ALL_OUTPUTS, *this, 1.0, 0); } TIMER_CALLBACK_MEMBER(ssi263hle_device::phoneme_tick) diff --git a/src/devices/sound/st0016.cpp b/src/devices/sound/st0016.cpp index 39d85aed58b..420ff9955bc 100644 --- a/src/devices/sound/st0016.cpp +++ b/src/devices/sound/st0016.cpp @@ -70,20 +70,17 @@ void st0016_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void st0016_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void st0016_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - - for (int sampleind = 0; sampleind < outputs[0].samples(); sampleind++) + for (int sampleind = 0; sampleind < stream.samples(); sampleind++) { for (int v = 0; v < 8; v++) { // check if voice is activated if (m_voice[v].update()) { - outputs[0].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 8, 32768 << 4); - outputs[1].add_int(sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 8, 32768 << 4); + stream.add_int(0, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_l) >> 8, 32768 << 4); + stream.add_int(1, sampleind, (m_voice[v].m_out * m_voice[v].m_vol_r) >> 8, 32768 << 4); } } } diff --git a/src/devices/sound/st0016.h b/src/devices/sound/st0016.h index 8153e14a288..d40e07b5c6a 100644 --- a/src/devices/sound/st0016.h +++ b/src/devices/sound/st0016.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/stt_sa1.cpp b/src/devices/sound/stt_sa1.cpp index efd9e49e163..29cd61e61ff 100644 --- a/src/devices/sound/stt_sa1.cpp +++ b/src/devices/sound/stt_sa1.cpp @@ -160,22 +160,19 @@ void stt_sa1_device::device_reset() } } -void stt_sa1_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void stt_sa1_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); - for (int v = 0; v < 8; v++) { voice_t &voice = m_voice[v]; - for (int i = 0; i < outputs[0].samples() && voice.enabled; i++) { + for (int i = 0; i < stream.samples() && voice.enabled; i++) { const offs_t offset = voice.addr_cur >> 12; const int sample = s8(read_byte(offset)) << 8; voice.addr_cur += voice.freq; - outputs[0].add_int(i, (sample * voice.vol_l) >> 16, 32768 * 8); - outputs[1].add_int(i, (sample * voice.vol_r) >> 16, 32768 * 8); + stream.add_int(0, i, (sample * voice.vol_l) >> 16, 32768 * 8); + stream.add_int(1, i, (sample * voice.vol_r) >> 16, 32768 * 8); if (voice.addr_cur >= voice.addr_end) { if (!voice.is_looped) { diff --git a/src/devices/sound/stt_sa1.h b/src/devices/sound/stt_sa1.h index 15b41f79a3a..66bc93a4480 100644 --- a/src/devices/sound/stt_sa1.h +++ b/src/devices/sound/stt_sa1.h @@ -28,7 +28,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct voice_t { diff --git a/src/devices/sound/swp00.cpp b/src/devices/sound/swp00.cpp index 17bbfd45ae3..f04161b22b3 100644 --- a/src/devices/sound/swp00.cpp +++ b/src/devices/sound/swp00.cpp @@ -1259,13 +1259,13 @@ double v2f2(s32 value) return (1.0 - (value & 0xffffff) / 33554432.0) / (1 << (value >> 24)); } -void swp00_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swp00_device::sound_stream_update(sound_stream &stream) { const delay_block brev(this, m_rev_buffer); const delay_block bcho(this, m_cho_buffer); const delay_block bvar(this, m_var_buffer); - for(int i=0; i != outputs[0].samples(); i++) { + for(int i=0; i != stream.samples(); i++) { s32 dry_l = 0, dry_r = 0; s32 rev = 0; s32 cho_l = 0, cho_r = 0; @@ -1838,8 +1838,8 @@ void swp00_device::sound_stream_update(sound_stream &stream, std::vector<read_st dry_l += m9v(rev_out_l, m_rev_vol) + m9v(m9(cho_out_l, 0x17), m_cho_vol) + m9v(m9(var_out_l, 0x18), m_var_vol); dry_r += m9v(rev_out_r, m_rev_vol) + m9v(m9(cho_out_r, 0x0e), m_cho_vol) + m9v(m9(var_out_r, 0x0f), m_var_vol); - outputs[0].put_int(i, dry_l, 32768); - outputs[1].put_int(i, dry_r, 32768); + stream.put_int(0, i, dry_l, 32768); + stream.put_int(1, i, dry_r, 32768); m_buffer_offset --; } diff --git a/src/devices/sound/swp00.h b/src/devices/sound/swp00.h index 22d8bc60db4..72730798e8a 100644 --- a/src/devices/sound/swp00.h +++ b/src/devices/sound/swp00.h @@ -21,7 +21,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void rom_bank_pre_change() override; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; diff --git a/src/devices/sound/swp20.cpp b/src/devices/sound/swp20.cpp index 947d2bb8b0a..ed22a0b74ff 100644 --- a/src/devices/sound/swp20.cpp +++ b/src/devices/sound/swp20.cpp @@ -220,9 +220,7 @@ void swp20_device::snd_w(offs_t offset, u8 data) } } -void swp20_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swp20_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); - outputs[1].fill(0); } diff --git a/src/devices/sound/swp20.h b/src/devices/sound/swp20.h index 5d02a24f8cf..1086fd8b792 100644 --- a/src/devices/sound/swp20.h +++ b/src/devices/sound/swp20.h @@ -20,7 +20,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/devices/sound/swp30.cpp b/src/devices/sound/swp30.cpp index 15d87e4233f..d135a77f16c 100644 --- a/src/devices/sound/swp30.cpp +++ b/src/devices/sound/swp30.cpp @@ -1285,10 +1285,10 @@ void swp30_device::state_string_export(const device_state_entry &entry, std::str { } -void swp30_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swp30_device::sound_stream_update(sound_stream &stream) { - outputs[0].put_int_clamp(0, m_meg_output[0], 32768); - outputs[1].put_int_clamp(0, m_meg_output[1], 32768); + stream.put_int_clamp(0, 0, m_meg_output[0], 32768); + stream.put_int_clamp(1, 0, m_meg_output[1], 32768); } void swp30_device::change_mode_attack_decay1(int chan) diff --git a/src/devices/sound/swp30.h b/src/devices/sound/swp30.h index e6b9d8be03e..eb34fb13eec 100644 --- a/src/devices/sound/swp30.h +++ b/src/devices/sound/swp30.h @@ -22,7 +22,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual uint32_t execute_min_cycles() const noexcept override; virtual uint32_t execute_max_cycles() const noexcept override; virtual uint64_t execute_clocks_to_cycles(uint64_t clocks) const noexcept override { return (clocks + 1) / 2; } diff --git a/src/devices/sound/swx00.cpp b/src/devices/sound/swx00.cpp index 1e0bc782777..4643e8e5058 100644 --- a/src/devices/sound/swx00.cpp +++ b/src/devices/sound/swx00.cpp @@ -549,9 +549,9 @@ s32 swx00_sound_device::fpapply(s32 value, s32 sample) return (s64(sample) - ((s64(sample) * ((value >> 9) & 0x7fff)) >> 16)) >> (value >> 24); } -void swx00_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void swx00_sound_device::sound_stream_update(sound_stream &stream) { - for(int i=0; i != outputs[0].samples(); i++) { + for(int i=0; i != stream.samples(); i++) { s32 dry_l = 0, dry_r = 0; s32 rev = 0; s32 cho_l = 0, cho_r = 0; @@ -715,7 +715,7 @@ void swx00_sound_device::sound_stream_update(sound_stream &stream, std::vector<r (void)var_l; (void)var_r; - outputs[0].put_int(i, dry_l, 32768); - outputs[1].put_int(i, dry_r, 32768); + stream.put_int(0, i, dry_l, 32768); + stream.put_int(1, i, dry_r, 32768); } } diff --git a/src/devices/sound/swx00.h b/src/devices/sound/swx00.h index e35ddd0a63a..5e7b78808a6 100644 --- a/src/devices/sound/swx00.h +++ b/src/devices/sound/swx00.h @@ -21,7 +21,7 @@ public: protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; private: diff --git a/src/devices/sound/t6721a.cpp b/src/devices/sound/t6721a.cpp index a094d4dc783..ae4ee8551eb 100644 --- a/src/devices/sound/t6721a.cpp +++ b/src/devices/sound/t6721a.cpp @@ -59,9 +59,8 @@ void t6721a_device::device_start() // our sound stream //------------------------------------------------- -void t6721a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void t6721a_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } diff --git a/src/devices/sound/t6721a.h b/src/devices/sound/t6721a.h index 861c03967da..ed680c0424a 100644 --- a/src/devices/sound/t6721a.h +++ b/src/devices/sound/t6721a.h @@ -65,7 +65,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum diff --git a/src/devices/sound/t6w28.cpp b/src/devices/sound/t6w28.cpp index 9525794e489..bbb483557d8 100644 --- a/src/devices/sound/t6w28.cpp +++ b/src/devices/sound/t6w28.cpp @@ -104,26 +104,21 @@ void t6w28_device::write(offs_t offset, uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void t6w28_device::sound_stream_update(sound_stream &stream) { - int i; - auto &buffer0 = outputs[0]; - auto &buffer1 = outputs[1]; - - /* If the volume is 0, increase the counter */ - for (i = 0;i < 8;i++) + for (int i = 0;i < 8;i++) { if (m_volume[i] == 0) { /* note that I do count += samples, NOT count = samples + 1. You might think */ /* it's the same since the volume is 0, but doing the latter could cause */ /* interferencies when the program is rapidly modulating the volume. */ - if (m_count[i] <= buffer0.samples()*STEP) m_count[i] += buffer0.samples()*STEP; + if (m_count[i] <= stream.samples()*STEP) m_count[i] += stream.samples()*STEP; } } - for (int sampindex = 0; sampindex < buffer0.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int vol[8]; unsigned int out0, out1; @@ -134,7 +129,7 @@ void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_st /* in the 1 position during the sample period. */ vol[0] = vol[1] = vol[2] = vol[3] = vol[4] = vol[5] = vol[6] = vol[7] = 0; - for (i = 2;i < 3;i++) + for (int i = 2;i < 3;i++) { if (m_output[i]) vol[i] += m_count[i]; m_count[i] -= STEP; @@ -161,7 +156,7 @@ void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_st if (m_output[i]) vol[i] -= m_count[i]; } - for (i = 4;i < 7;i++) + for (int i = 4;i < 7;i++) { if (m_output[i]) vol[i] += m_count[i]; m_count[i] -= STEP; @@ -252,8 +247,8 @@ void t6w28_device::sound_stream_update(sound_stream &stream, std::vector<read_st if (out0 > MAX_OUTPUT * STEP) out0 = MAX_OUTPUT * STEP; if (out1 > MAX_OUTPUT * STEP) out1 = MAX_OUTPUT * STEP; - buffer0.put_int(sampindex, out0 / STEP, 32768); - buffer1.put_int(sampindex, out1 / STEP, 32768); + stream.put_int(0, sampindex, out0 / STEP, 32768); + stream.put_int(1, sampindex, out1 / STEP, 32768); } } diff --git a/src/devices/sound/t6w28.h b/src/devices/sound/t6w28.h index 8d90c05bbe6..c0cff413c56 100644 --- a/src/devices/sound/t6w28.h +++ b/src/devices/sound/t6w28.h @@ -18,7 +18,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void set_gain(int gain); diff --git a/src/devices/sound/tc8830f.cpp b/src/devices/sound/tc8830f.cpp index f9f65975347..db60e255f0b 100644 --- a/src/devices/sound/tc8830f.cpp +++ b/src/devices/sound/tc8830f.cpp @@ -82,11 +82,11 @@ void tc8830f_device::device_clock_changed() -void tc8830f_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tc8830f_device::sound_stream_update(sound_stream &stream) { int32_t mix = 0; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { if (m_playing) { @@ -128,7 +128,7 @@ void tc8830f_device::sound_stream_update(sound_stream &stream, std::vector<read_ mix = m_output; } - outputs[0].put_int(i, mix, 32768); + stream.put_int(0, i, mix, 32768); } } diff --git a/src/devices/sound/tc8830f.h b/src/devices/sound/tc8830f.h index fa1a3c8f938..808608e6e64 100644 --- a/src/devices/sound/tc8830f.h +++ b/src/devices/sound/tc8830f.h @@ -32,7 +32,7 @@ protected: virtual void device_post_load() override; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/devices/sound/tiaintf.cpp b/src/devices/sound/tiaintf.cpp index 5a64db7bb4c..d2db180b2b2 100644 --- a/src/devices/sound/tiaintf.cpp +++ b/src/devices/sound/tiaintf.cpp @@ -52,9 +52,9 @@ void tia_device::device_stop() // sound_stream_update - handle a stream update //------------------------------------------------- -void tia_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tia_device::sound_stream_update(sound_stream &stream) { - tia_process(m_chip, outputs[0]); + tia_process(m_chip, stream); } diff --git a/src/devices/sound/tiaintf.h b/src/devices/sound/tiaintf.h index 94e8c8510e9..0ebc0d50433 100644 --- a/src/devices/sound/tiaintf.h +++ b/src/devices/sound/tiaintf.h @@ -24,7 +24,7 @@ protected: virtual void device_stop() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_channel; diff --git a/src/devices/sound/tiasound.cpp b/src/devices/sound/tiasound.cpp index 87fa657bfab..31679c71efb 100644 --- a/src/devices/sound/tiasound.cpp +++ b/src/devices/sound/tiasound.cpp @@ -314,7 +314,7 @@ void tia_write(void *chip, offs_t offset, uint8_t data) /* */ /*****************************************************************************/ -void tia_process(void *_chip, write_stream_view &buffer) +void tia_process(void *_chip, sound_stream &stream) { tia *chip = (tia *)_chip; uint8_t audc0, audc1; @@ -336,7 +336,7 @@ void tia_process(void *_chip, write_stream_view &buffer) div_n_cnt1 = chip->Div_n_cnt[1]; /* loop until the buffer is filled */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { /* Process channel 0 */ if (div_n_cnt0 > 1) @@ -532,7 +532,7 @@ void tia_process(void *_chip, write_stream_view &buffer) chip->Samp_n_cnt += chip->Samp_n_max; /* calculate the latest output value and place in buffer */ - buffer.put_int(sampindex++, outvol_0 + outvol_1, 32768); + stream.put_int(0, sampindex++, outvol_0 + outvol_1, 32768); } } else @@ -543,9 +543,9 @@ void tia_process(void *_chip, write_stream_view &buffer) * byte contains the fractional part */ chip->Samp_n_cnt -= 256; /* calculate the latest output value and place in buffer */ - buffer.put_int(sampindex++, outvol_0 + outvol_1, 32768); + stream.put_int(0, sampindex++, outvol_0 + outvol_1, 32768); } - while ((chip->Samp_n_cnt >= 256) && (sampindex < buffer.samples())); + while ((chip->Samp_n_cnt >= 256) && (sampindex < stream.samples())); /* adjust the sample counter if necessary */ if (chip->Samp_n_cnt < 256) diff --git a/src/devices/sound/tiasound.h b/src/devices/sound/tiasound.h index 2edafdda912..856a06cc1b4 100644 --- a/src/devices/sound/tiasound.h +++ b/src/devices/sound/tiasound.h @@ -41,7 +41,7 @@ void *tia_sound_init(device_t *device, int clock, int sample_rate, int gain); void tia_sound_free(void *chip); -void tia_process(void *chip, write_stream_view &buffer); +void tia_process(void *chip, sound_stream &stream); void tia_write(void *chip, offs_t offset, uint8_t data); #endif // MAME_SOUND_TIASOUND_H diff --git a/src/devices/sound/tms3615.cpp b/src/devices/sound/tms3615.cpp index 3f595c8a97b..5cdf269f77e 100644 --- a/src/devices/sound/tms3615.cpp +++ b/src/devices/sound/tms3615.cpp @@ -49,17 +49,14 @@ void tms3615_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void tms3615_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms3615_device::sound_stream_update(sound_stream &stream) { - auto &buffer8 = outputs[FOOTAGE_8]; - auto &buffer16 = outputs[FOOTAGE_16]; + int samplerate = stream.sample_rate(); - int samplerate = buffer8.sample_rate(); - - constexpr stream_buffer::sample_t VMAX = 1.0f / stream_buffer::sample_t(TMS3615_TONES); - for (int sampindex = 0; sampindex < buffer8.samples(); sampindex++) + constexpr sound_stream::sample_t VMAX = 1.0f / sound_stream::sample_t(TMS3615_TONES); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - stream_buffer::sample_t sum8 = 0, sum16 = 0; + sound_stream::sample_t sum8 = 0, sum16 = 0; for (int tone = 0; tone < TMS3615_TONES; tone++) { @@ -94,8 +91,8 @@ void tms3615_device::sound_stream_update(sound_stream &stream, std::vector<read_ } } - buffer8.put(sampindex, sum8); - buffer16.put(sampindex, sum16); + stream.put(FOOTAGE_8, sampindex, sum8); + stream.put(FOOTAGE_16, sampindex, sum16); } } diff --git a/src/devices/sound/tms3615.h b/src/devices/sound/tms3615.h index bf29b32b9dd..bad0bfa8950 100644 --- a/src/devices/sound/tms3615.h +++ b/src/devices/sound/tms3615.h @@ -28,7 +28,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned TMS3615_TONES = 13; diff --git a/src/devices/sound/tms36xx.cpp b/src/devices/sound/tms36xx.cpp index 08df1d03f51..e969987d129 100644 --- a/src/devices/sound/tms36xx.cpp +++ b/src/devices/sound/tms36xx.cpp @@ -397,19 +397,15 @@ void tms36xx_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void tms36xx_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms36xx_device::sound_stream_update(sound_stream &stream) { int samplerate = m_samplerate; - auto &buffer = outputs[0]; /* no tune played? */ if( !tunes[m_tune_num] || m_voices == 0 ) - { - buffer.fill(0); return; - } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int sum = 0; @@ -443,7 +439,7 @@ void tms36xx_device::sound_stream_update(sound_stream &stream, std::vector<read_ TONE( 0) TONE( 1) TONE( 2) TONE( 3) TONE( 4) TONE( 5) TONE( 6) TONE( 7) TONE( 8) TONE( 9) TONE(10) TONE(11) - buffer.put_int(sampindex, sum, 32768 * m_voices); + stream.put_int(0, sampindex, sum, 32768 * m_voices); } } diff --git a/src/devices/sound/tms36xx.h b/src/devices/sound/tms36xx.h index 307e6787afa..c18d0554615 100644 --- a/src/devices/sound/tms36xx.h +++ b/src/devices/sound/tms36xx.h @@ -63,7 +63,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: // MM6221AA interface functions diff --git a/src/devices/sound/tms5110.cpp b/src/devices/sound/tms5110.cpp index eb09016a035..e2d77d130fc 100644 --- a/src/devices/sound/tms5110.cpp +++ b/src/devices/sound/tms5110.cpp @@ -1192,22 +1192,21 @@ int tms5110_device::romclk_hack_r() ******************************************************************************/ -void tms5110_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms5110_device::sound_stream_update(sound_stream &stream) { int16_t sample_data[MAX_SAMPLE_CHUNK]; - auto &buffer = outputs[0]; /* loop while we still have samples to generate */ - for (int sampindex = 0; sampindex < buffer.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int length = buffer.samples() - sampindex; + int length = stream.samples() - sampindex; if (length > MAX_SAMPLE_CHUNK) length = MAX_SAMPLE_CHUNK; /* generate the samples and copy to the target buffer */ process(sample_data, length); for (int index = 0; index < length; index++) - buffer.put_int(sampindex++, sample_data[index], 32768); + stream.put_int(0, sampindex++, sample_data[index], 32768); } } diff --git a/src/devices/sound/tms5110.h b/src/devices/sound/tms5110.h index 2c9628c3338..0f367323f6d 100644 --- a/src/devices/sound/tms5110.h +++ b/src/devices/sound/tms5110.h @@ -60,7 +60,7 @@ protected: TIMER_CALLBACK_MEMBER(romclk_hack_toggle); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; uint8_t TALK_STATUS() const { return m_SPEN | m_TALKD; } diff --git a/src/devices/sound/tms5220.cpp b/src/devices/sound/tms5220.cpp index f472e9aa86e..77869045bea 100644 --- a/src/devices/sound/tms5220.cpp +++ b/src/devices/sound/tms5220.cpp @@ -2140,20 +2140,19 @@ int tms5220_device::intq_r() // sound_stream_update - handle a stream update //------------------------------------------------- -void tms5220_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tms5220_device::sound_stream_update(sound_stream &stream) { int16_t sample_data[MAX_SAMPLE_CHUNK]; - auto &output = outputs[0]; /* loop while we still have samples to generate */ - for (int sampindex = 0; sampindex < output.samples(); ) + for (int sampindex = 0; sampindex < stream.samples(); ) { - int length = (output.samples() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : output.samples(); + int length = (stream.samples() > MAX_SAMPLE_CHUNK) ? MAX_SAMPLE_CHUNK : stream.samples(); /* generate the samples and copy to the target buffer */ process(sample_data, length); for (int index = 0; index < length; index++) - output.put_int(sampindex++, sample_data[index], 32768); + stream.put_int(0, sampindex++, sample_data[index], 32768); } } diff --git a/src/devices/sound/tms5220.h b/src/devices/sound/tms5220.h index 6aa0494164b..1dee49d8f1f 100644 --- a/src/devices/sound/tms5220.h +++ b/src/devices/sound/tms5220.h @@ -68,7 +68,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(set_io_ready); diff --git a/src/devices/sound/tt5665.cpp b/src/devices/sound/tt5665.cpp index 363481669ff..1949c90e36c 100644 --- a/src/devices/sound/tt5665.cpp +++ b/src/devices/sound/tt5665.cpp @@ -88,24 +88,24 @@ DEFINE_DEVICE_TYPE(TT5665, tt5665_device, "tt5665", "Tontek TT5665 ADPCM Voice Synthesis LSI") // same as MSM6295 -const stream_buffer::sample_t tt5665_device::s_volume_table[16] = +const sound_stream::sample_t tt5665_device::s_volume_table[16] = { - stream_buffer::sample_t(0x20) / stream_buffer::sample_t(0x20), // 0 dB - stream_buffer::sample_t(0x16) / stream_buffer::sample_t(0x20), // -3.2 dB - stream_buffer::sample_t(0x10) / stream_buffer::sample_t(0x20), // -6.0 dB - stream_buffer::sample_t(0x0b) / stream_buffer::sample_t(0x20), // -9.2 dB - stream_buffer::sample_t(0x08) / stream_buffer::sample_t(0x20), // -12.0 dB - stream_buffer::sample_t(0x06) / stream_buffer::sample_t(0x20), // -14.5 dB - stream_buffer::sample_t(0x04) / stream_buffer::sample_t(0x20), // -18.0 dB - stream_buffer::sample_t(0x03) / stream_buffer::sample_t(0x20), // -20.5 dB - stream_buffer::sample_t(0x02) / stream_buffer::sample_t(0x20), // -24.0 dB - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), - stream_buffer::sample_t(0x00) / stream_buffer::sample_t(0x20), + sound_stream::sample_t(0x20) / sound_stream::sample_t(0x20), // 0 dB + sound_stream::sample_t(0x16) / sound_stream::sample_t(0x20), // -3.2 dB + sound_stream::sample_t(0x10) / sound_stream::sample_t(0x20), // -6.0 dB + sound_stream::sample_t(0x0b) / sound_stream::sample_t(0x20), // -9.2 dB + sound_stream::sample_t(0x08) / sound_stream::sample_t(0x20), // -12.0 dB + sound_stream::sample_t(0x06) / sound_stream::sample_t(0x20), // -14.5 dB + sound_stream::sample_t(0x04) / sound_stream::sample_t(0x20), // -18.0 dB + sound_stream::sample_t(0x03) / sound_stream::sample_t(0x20), // -20.5 dB + sound_stream::sample_t(0x02) / sound_stream::sample_t(0x20), // -24.0 dB + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), + sound_stream::sample_t(0x00) / sound_stream::sample_t(0x20), }; @@ -210,16 +210,13 @@ void tt5665_device::device_clock_changed() // our sound stream //------------------------------------------------- -void tt5665_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tt5665_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - outputs[1].fill(0); bool update_daol = false; // iterate over voices and accumulate sample data // loop while we still have samples to generate - for (int s = 0; s < outputs[0].samples(); s++) + for (int s = 0; s < stream.samples(); s++) { // adjust DAOL clock timing m_daol_timing--; @@ -239,8 +236,8 @@ void tt5665_device::sound_stream_update(sound_stream &stream, std::vector<read_s // refresh DAOR output m_voice[b + 4].generate_adpcm(*this, &daor_output); } - outputs[0].put_int(s, m_daol_output, 2048); - outputs[1].put_int(s, daor_output, 2048); + stream.put_int(0, s, m_daol_output, 2048); + stream.put_int(1, s, daor_output, 2048); if (update_daol) { update_daol = false; diff --git a/src/devices/sound/tt5665.h b/src/devices/sound/tt5665.h index 2bbd1c73822..811e2f278e2 100644 --- a/src/devices/sound/tt5665.h +++ b/src/devices/sound/tt5665.h @@ -69,7 +69,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; @@ -87,7 +87,7 @@ private: offs_t m_base_offset; // pointer to the base memory location u32 m_sample; // current sample number u32 m_count; // total samples to play - stream_buffer::sample_t m_volume; // output volume + sound_stream::sample_t m_volume; // output volume }; // configuration state @@ -105,7 +105,7 @@ private: inline int freq_divider() const { return m_ss_state ? 136 : 170; } - static const stream_buffer::sample_t s_volume_table[16]; + static const sound_stream::sample_t s_volume_table[16]; }; diff --git a/src/devices/sound/uda1344.cpp b/src/devices/sound/uda1344.cpp index b8d445ef3b8..3031ea2e75d 100644 --- a/src/devices/sound/uda1344.cpp +++ b/src/devices/sound/uda1344.cpp @@ -88,25 +88,21 @@ void uda1344_device::device_reset() memset(m_bufout, 0, sizeof(uint32_t) * 2); } -void uda1344_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void uda1344_device::sound_stream_update(sound_stream &stream) { - for (int channel = 0; channel < 2 && channel < outputs.size(); channel++) + for (int channel = 0; channel < 2 && channel < stream.output_count(); channel++) { - auto &output = outputs[channel]; uint32_t curout = m_bufout[channel]; uint32_t curin = m_bufin[channel]; // feed as much as we can int sampindex; - for (sampindex = 0; curout != curin && sampindex < output.samples(); sampindex++) + for (sampindex = 0; curout != curin && sampindex < stream.samples(); sampindex++) { - output.put(sampindex, stream_buffer::sample_t(m_buffer[channel][curout]) * m_volume); + stream.put(channel, sampindex, sound_stream::sample_t(m_buffer[channel][curout]) * m_volume); curout = (curout + 1) % BUFFER_SIZE; } - // fill the rest with silence - output.fill(0, sampindex); - // save the new output pointer m_bufout[channel] = curout; } @@ -116,8 +112,8 @@ void uda1344_device::ingest_samples(int16_t left, int16_t right) { const int16_t samples[2] = { left, right }; - const stream_buffer::sample_t sample_scale = 1.0 / 32768.0; - const stream_buffer::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; + const sound_stream::sample_t sample_scale = 1.0 / 32768.0; + const sound_stream::sample_t enable_scale = m_dac_enable ? 1.0 : 0.0; m_stream->update(); @@ -126,7 +122,7 @@ void uda1344_device::ingest_samples(int16_t left, int16_t right) int maxin = (m_bufout[channel] + BUFFER_SIZE - 1) % BUFFER_SIZE; if (m_bufin[channel] != maxin) { - m_buffer[channel][m_bufin[channel]] = stream_buffer::sample_t(samples[channel]) * sample_scale * enable_scale; + m_buffer[channel][m_bufin[channel]] = sound_stream::sample_t(samples[channel]) * sample_scale * enable_scale; m_bufin[channel] = (m_bufin[channel] + 1) % BUFFER_SIZE; } else diff --git a/src/devices/sound/uda1344.h b/src/devices/sound/uda1344.h index 5ba1df90cdf..6cc895e2245 100644 --- a/src/devices/sound/uda1344.h +++ b/src/devices/sound/uda1344.h @@ -30,7 +30,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void ingest_samples(int16_t left, int16_t right); @@ -79,10 +79,10 @@ protected: }; sound_stream *m_stream; - std::vector<stream_buffer::sample_t> m_buffer[2]; + std::vector<sound_stream::sample_t> m_buffer[2]; uint32_t m_bufin[2]; uint32_t m_bufout[2]; - stream_buffer::sample_t m_volume; + sound_stream::sample_t m_volume; double m_frequency; uint8_t m_data_transfer_mode; diff --git a/src/devices/sound/upd65043gfu01.cpp b/src/devices/sound/upd65043gfu01.cpp index 7ef6c9d98de..f8f517b746f 100644 --- a/src/devices/sound/upd65043gfu01.cpp +++ b/src/devices/sound/upd65043gfu01.cpp @@ -205,9 +205,9 @@ void upd65043gfu01_device::update_noise() } //************************************************************************** -void upd65043gfu01_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd65043gfu01_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s16 sample = 0; @@ -244,6 +244,6 @@ void upd65043gfu01_device::sound_stream_update(sound_stream &stream, std::vector if (!BIT(m_control, 4)) sample += m_pcm_buffer[m_pcm_buffer_read & 0x1ff]; - outputs[0].put_int_clamp(i, sample, 1 << 10); + stream.put_int_clamp(0, i, sample, 1 << 10); } } diff --git a/src/devices/sound/upd65043gfu01.h b/src/devices/sound/upd65043gfu01.h index 29c1a74e3a8..482771d9471 100644 --- a/src/devices/sound/upd65043gfu01.h +++ b/src/devices/sound/upd65043gfu01.h @@ -23,7 +23,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: TIMER_CALLBACK_MEMBER(irq_timer); diff --git a/src/devices/sound/upd7752.cpp b/src/devices/sound/upd7752.cpp index 8f8a3a6f9a3..ca0f47c46ea 100644 --- a/src/devices/sound/upd7752.cpp +++ b/src/devices/sound/upd7752.cpp @@ -98,9 +98,8 @@ void upd7752_device::device_stop() // sound_stream_update - handle a stream update //------------------------------------------------- -void upd7752_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd7752_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } //************************************************************************** diff --git a/src/devices/sound/upd7752.h b/src/devices/sound/upd7752.h index c9890e19588..30c663d8fb5 100644 --- a/src/devices/sound/upd7752.h +++ b/src/devices/sound/upd7752.h @@ -30,7 +30,7 @@ protected: virtual void device_stop() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual space_config_vector memory_space_config() const override; private: diff --git a/src/devices/sound/upd7759.cpp b/src/devices/sound/upd7759.cpp index 1579fd8ee39..ff23e9dd6ec 100644 --- a/src/devices/sound/upd7759.cpp +++ b/src/devices/sound/upd7759.cpp @@ -684,19 +684,19 @@ int upd775x_device::busy_r() // sound_stream_update - handle a stream update //------------------------------------------------- -void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd775x_device::sound_stream_update(sound_stream &stream) { - constexpr stream_buffer::sample_t sample_scale = 128.0 / 32768.0; - stream_buffer::sample_t sample = stream_buffer::sample_t(m_sample) * sample_scale; + constexpr sound_stream::sample_t sample_scale = 128.0 / 32768.0; + sound_stream::sample_t sample = sound_stream::sample_t(m_sample) * sample_scale; int32_t clocks_left = m_clocks_left; uint32_t step = m_step; uint32_t pos = m_pos; u32 index = 0; if (m_state != STATE_IDLE) - for ( ; index < outputs[0].samples(); index++) + for ( ; index < stream.samples(); index++) { - outputs[0].put(index, sample); + stream.put(0, index, sample); pos += step; @@ -716,14 +716,14 @@ void upd775x_device::sound_stream_update(sound_stream &stream, std::vector<read_ break; clocks_left = m_clocks_left; - sample = stream_buffer::sample_t(m_sample) * sample_scale; + sample = sound_stream::sample_t(m_sample) * sample_scale; } } } // if we got out early, just zap the rest of the buffer - for (; index < outputs[0].samples(); index++) - outputs[0].put(index, 0); + for (; index < stream.samples(); index++) + stream.put(0, index, 0); m_clocks_left = clocks_left; m_pos = pos; diff --git a/src/devices/sound/upd7759.h b/src/devices/sound/upd7759.h index b45fff6d95e..99720af5983 100644 --- a/src/devices/sound/upd7759.h +++ b/src/devices/sound/upd7759.h @@ -74,7 +74,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void update_adpcm(int data); virtual void advance_state(); diff --git a/src/devices/sound/upd931.cpp b/src/devices/sound/upd931.cpp index f2986ed68cd..9f3d3efad40 100644 --- a/src/devices/sound/upd931.cpp +++ b/src/devices/sound/upd931.cpp @@ -159,9 +159,9 @@ void upd931_device::device_clock_changed() } /**************************************************************************/ -void upd931_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd931_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sample = 0; for (voice_t &voice : m_voice) @@ -172,7 +172,7 @@ void upd931_device::sound_stream_update(sound_stream &stream, std::vector<read_s sample += voice.m_wave_out[0] * (voice.m_env_level[0] >> VOLUME_SHIFT); sample += voice.m_wave_out[1] * (voice.m_env_level[1] >> VOLUME_SHIFT); } - outputs[0].put_int_clamp(i, sample, 1 << 16); + stream.put_int_clamp(0, i, sample, 1 << 16); } } diff --git a/src/devices/sound/upd931.h b/src/devices/sound/upd931.h index a97397fc11b..ea982ac5b58 100644 --- a/src/devices/sound/upd931.h +++ b/src/devices/sound/upd931.h @@ -40,7 +40,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned PITCH_SHIFT = 15; diff --git a/src/devices/sound/upd933.cpp b/src/devices/sound/upd933.cpp index 6167ec2a3c1..e8b3d2e6f2f 100644 --- a/src/devices/sound/upd933.cpp +++ b/src/devices/sound/upd933.cpp @@ -371,9 +371,9 @@ u32 upd933_device::env_rate(u8 data) const } /**************************************************************************/ -void upd933_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd933_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 sample = 0; @@ -385,7 +385,7 @@ void upd933_device::sound_stream_update(sound_stream &stream, std::vector<read_s for (int j : voice_map) sample += update(j); - outputs[0].put_int_clamp(i, sample, 1 << 15); + stream.put_int_clamp(0, i, sample, 1 << 15); m_sample_count++; } } diff --git a/src/devices/sound/upd933.h b/src/devices/sound/upd933.h index b29c2f2c879..1f8049d0dfd 100644 --- a/src/devices/sound/upd933.h +++ b/src/devices/sound/upd933.h @@ -31,7 +31,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_clock_changed() override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned NOTE_SHIFT = 9; diff --git a/src/devices/sound/upd934g.cpp b/src/devices/sound/upd934g.cpp index 1178ef0a930..3d56c102d09 100644 --- a/src/devices/sound/upd934g.cpp +++ b/src/devices/sound/upd934g.cpp @@ -80,7 +80,7 @@ void upd934g_device::device_reset() // our sound stream //------------------------------------------------- -void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void upd934g_device::sound_stream_update(sound_stream &stream) { for (unsigned ch = 0; ch < 4; ch++) { @@ -88,7 +88,7 @@ void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_ { uint16_t end = m_addr[m_channel[ch].playing + 1] - 1; - for (unsigned i = 0; i < outputs[ch].samples(); i++) + for (unsigned i = 0; i < stream.samples(); i++) { int16_t raw = static_cast<int8_t>(read_byte(m_channel[ch].pos)) * 4; @@ -96,18 +96,15 @@ void upd934g_device::sound_stream_update(sound_stream &stream, std::vector<read_ const double adjust[] = { 0, 0.7, 0.4, 1.0 }; raw *= adjust[m_channel[ch].effect]; - outputs[ch].put_int(i, raw, 32768 / 64); + stream.put_int(ch, i, raw, 32768 / 64); if (++m_channel[ch].pos >= end) { m_channel[ch].playing = -1; - outputs[ch].fill(0, i + 1); break; } } } - else - outputs[ch].fill(0); } } diff --git a/src/devices/sound/upd934g.h b/src/devices/sound/upd934g.h index 6652fb62c8e..1a7d9671275 100644 --- a/src/devices/sound/upd934g.h +++ b/src/devices/sound/upd934g.h @@ -34,7 +34,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/devices/sound/va_eg.cpp b/src/devices/sound/va_eg.cpp index 401d5c34197..5a718832d1a 100644 --- a/src/devices/sound/va_eg.cpp +++ b/src/devices/sound/va_eg.cpp @@ -99,23 +99,22 @@ void va_rc_eg_device::device_start() save_item(NAME(m_t_end_approx)); } -void va_rc_eg_device::sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) +void va_rc_eg_device::sound_stream_update(sound_stream &stream) { assert(inputs.size() == 0 && outputs.size() == 1); - write_stream_view &out = outputs[0]; - attotime t = out.start_time(); + attotime t = stream.start_time(); if (t >= m_t_end_approx) { // Avoid expensive get_v() calls if the envelope stage has completed. - out.fill(m_v_end); + stream.fill(0, m_v_end); return; } - const int n = out.samples(); - const attotime dt = out.sample_period(); + const int n = stream.samples(); + const attotime dt = stream.sample_period(); for (int i = 0; i < n; ++i, t += dt) - out.put(i, get_v(t)); + stream.put(0, i, get_v(t)); } void va_rc_eg_device::snapshot() diff --git a/src/devices/sound/va_eg.h b/src/devices/sound/va_eg.h index bd8c00cd722..29675145810 100644 --- a/src/devices/sound/va_eg.h +++ b/src/devices/sound/va_eg.h @@ -39,7 +39,7 @@ public: protected: void device_start() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: // Takes a snapshot of the current voltage into m_v_start and m_t_start. diff --git a/src/devices/sound/va_vca.cpp b/src/devices/sound/va_vca.cpp index d918dd25fba..63ba220ae86 100644 --- a/src/devices/sound/va_vca.cpp +++ b/src/devices/sound/va_vca.cpp @@ -55,17 +55,17 @@ void va_vca_device::device_start() save_item(NAME(m_fixed_gain)); } -void va_vca_device::sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) +void va_vca_device::sound_stream_update(sound_stream &stream) { if (m_has_cv_stream) { - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, inputs[0].get(i) * cv_to_gain(inputs[1].get(i))); + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * cv_to_gain(stream.get(1, i))); } else { - for (int i = 0; i < outputs[0].samples(); i++) - outputs[0].put(i, inputs[0].get(i) * m_fixed_gain); + for (int i = 0; i < stream.samples(); i++) + stream.put(0, i, stream.get(0, i) * m_fixed_gain); } } diff --git a/src/devices/sound/va_vca.h b/src/devices/sound/va_vca.h index ee155426019..9d9c3963ce1 100644 --- a/src/devices/sound/va_vca.h +++ b/src/devices/sound/va_vca.h @@ -37,7 +37,7 @@ public: protected: void device_start() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: float cv_to_gain(float cv) const; diff --git a/src/devices/sound/vgm_visualizer.cpp b/src/devices/sound/vgm_visualizer.cpp index e62ffe07785..13d25bcb6ca 100644 --- a/src/devices/sound/vgm_visualizer.cpp +++ b/src/devices/sound/vgm_visualizer.cpp @@ -54,7 +54,7 @@ DEFINE_DEVICE_TYPE(VGMVIZ, vgmviz_device, "vgmviz", "VGM Visualizer") vgmviz_device::vgmviz_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) : device_t(mconfig, VGMVIZ, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_sound_interface(mconfig, *this) , m_screen(*this, "screen") , m_palette(*this, "palette") { @@ -76,6 +76,7 @@ vgmviz_device::~vgmviz_device() void vgmviz_device::device_start() { + stream_alloc(2, 2, machine().sample_rate()); WDL_fft_init(); fill_window(); m_bitmap.resize(SCREEN_WIDTH, SCREEN_HEIGHT); @@ -283,18 +284,19 @@ void vgmviz_device::cycle_viz_mode() // audio stream and process as necessary //------------------------------------------------- -void vgmviz_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vgmviz_device::sound_stream_update(sound_stream &stream) { - // call the normal interface to actually mix - device_mixer_interface::sound_stream_update(stream, inputs, outputs); + // Passthrough the audio + stream.copy(0, 0); + stream.copy(1, 1); - // now consume the outputs - for (int pos = 0; pos < outputs[0].samples(); pos++) + // now consume the inputs + for (int pos = 0; pos < stream.samples(); pos++) { - for (int i = 0; i < outputs.size(); i++) + for (int i = 0; i < stream.output_count(); i++) { // Original code took 16-bit sample / 65536.0 instead of 32768.0, so multiply by 0.5 here but is it necessary? - const float sample = outputs[i].get(pos) * 0.5f; + const float sample = stream.get(i, pos) * 0.5f; m_audio_buf[m_audio_fill_index][i][m_audio_count[m_audio_fill_index]] = sample + 0.5f; } diff --git a/src/devices/sound/vgm_visualizer.h b/src/devices/sound/vgm_visualizer.h index f201b117461..ee671535a24 100644 --- a/src/devices/sound/vgm_visualizer.h +++ b/src/devices/sound/vgm_visualizer.h @@ -35,7 +35,7 @@ DECLARE_DEVICE_TYPE(VGMVIZ, vgmviz_device) // ======================> vgmviz_device -class vgmviz_device : public device_t, public device_mixer_interface +class vgmviz_device : public device_t, public device_sound_interface { public: // construction/destruction @@ -91,7 +91,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface-level overrides - void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; void update_waveform(); void update_fft(); diff --git a/src/devices/sound/vlm5030.cpp b/src/devices/sound/vlm5030.cpp index 03381d3460f..8f6e3715360 100644 --- a/src/devices/sound/vlm5030.cpp +++ b/src/devices/sound/vlm5030.cpp @@ -498,19 +498,18 @@ void vlm5030_device::st(int state) // sound_stream_update - handle a stream update //------------------------------------------------- -void vlm5030_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vlm5030_device::sound_stream_update(sound_stream &stream) { int interp_effect; int i; int u[11]; - auto &buffer = outputs[0]; /* running */ int sampindex = 0; if (m_phase == PH_RUN || m_phase == PH_STOP) { /* playing speech */ - for ( ; sampindex < buffer.samples(); sampindex++) + for ( ; sampindex < stream.samples(); sampindex++) { int current_val; @@ -603,7 +602,7 @@ void vlm5030_device::sound_stream_update(sound_stream &stream, std::vector<read_ m_x[0] = u[0]; /* clipping, buffering */ - buffer.put_int_clamp(sampindex, u[0], 512); + stream.put_int_clamp(0, sampindex, u[0], 512); /* sample count */ m_sample_count--; @@ -622,7 +621,7 @@ phase_stop: switch (m_phase) { case PH_SETUP: - if (m_sample_count <= buffer.samples()) + if (m_sample_count <= stream.samples()) { m_sample_count = 0; /* logerror("VLM5030 BSY=H\n"); */ @@ -631,11 +630,11 @@ phase_stop: } else { - m_sample_count -= buffer.samples(); + m_sample_count -= stream.samples(); } break; case PH_END: - if (m_sample_count <= buffer.samples()) + if (m_sample_count <= stream.samples()) { m_sample_count = 0; /* logerror("VLM5030 BSY=L\n"); */ @@ -644,10 +643,7 @@ phase_stop: } else { - m_sample_count -= buffer.samples(); + m_sample_count -= stream.samples(); } } - - /* silent buffering */ - buffer.fill(0, sampindex); } diff --git a/src/devices/sound/vlm5030.h b/src/devices/sound/vlm5030.h index ca34110b285..f9d05749882 100644 --- a/src/devices/sound/vlm5030.h +++ b/src/devices/sound/vlm5030.h @@ -34,7 +34,7 @@ protected: virtual void device_post_load() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/votrax.cpp b/src/devices/sound/votrax.cpp index f1da1134415..3ad167f9145 100644 --- a/src/devices/sound/votrax.cpp +++ b/src/devices/sound/votrax.cpp @@ -157,13 +157,13 @@ void votrax_sc01_device::inflection_w(uint8_t data) // for our sound stream //------------------------------------------------- -void votrax_sc01_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void votrax_sc01_device::sound_stream_update(sound_stream &stream) { - for(int i=0; i<outputs[0].samples(); i++) { + for(int i=0; i<stream.samples(); i++) { m_sample_count++; if(m_sample_count & 1) chip_update(); - outputs[0].put(i, analog_calc()); + stream.put(0, i, analog_calc()); } } @@ -596,7 +596,7 @@ void votrax_sc01_device::filters_commit(bool force) LOGMASKED(LOG_FILTER, "filter fa=%x va=%x fc=%x f1=%x f2=%02x f2q=%x f3=%x\n", m_filt_fa, m_filt_va, m_filt_fc, m_filt_f1, m_filt_f2, m_filt_f2q, m_filt_f3); } -stream_buffer::sample_t votrax_sc01_device::analog_calc() +sound_stream::sample_t votrax_sc01_device::analog_calc() { // Voice-only path. // 1. Pick up the pitch wave diff --git a/src/devices/sound/votrax.h b/src/devices/sound/votrax.h index a3b2ab12114..498d6ed36eb 100644 --- a/src/devices/sound/votrax.h +++ b/src/devices/sound/votrax.h @@ -36,7 +36,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(phone_tick); @@ -178,7 +178,7 @@ private: void chip_update(); // Global update called at 20KHz (main/36) void filters_commit(bool force); // Commit the currently computed interpolation values to the filters void phone_commit(); // Commit the current phone id - stream_buffer::sample_t analog_calc(); // Compute one more sample + sound_stream::sample_t analog_calc(); // Compute one more sample }; class votrax_sc01a_device : public votrax_sc01_device diff --git a/src/devices/sound/vrc6.cpp b/src/devices/sound/vrc6.cpp index d9b36f5b8a6..40f2ddf8946 100644 --- a/src/devices/sound/vrc6.cpp +++ b/src/devices/sound/vrc6.cpp @@ -93,16 +93,13 @@ void vrc6snd_device::device_reset() // our sound stream //------------------------------------------------- -void vrc6snd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vrc6snd_device::sound_stream_update(sound_stream &stream) { // check global halt bit if (m_freqctrl & 1) - { - outputs[0].fill(0); return; - } - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // update pulse1 if (m_pulsefrqh[0] & 0x80) @@ -200,7 +197,7 @@ void vrc6snd_device::sound_stream_update(sound_stream &stream, std::vector<read_ // sum 2 4-bit pulses, 1 5-bit saw = unsigned 6 bit output s16 tmp = (s16)(u8)(m_output[0] + m_output[1] + m_output[2]); - outputs[0].put_int(i, tmp, 128); + stream.put_int(0, i, tmp, 128); } } diff --git a/src/devices/sound/vrc6.h b/src/devices/sound/vrc6.h index 9dcc2fa1cee..8ca9102bc2d 100644 --- a/src/devices/sound/vrc6.h +++ b/src/devices/sound/vrc6.h @@ -31,7 +31,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: u8 m_freqctrl, m_pulsectrl[2], m_sawrate, m_master_freq; diff --git a/src/devices/sound/vrender0.cpp b/src/devices/sound/vrender0.cpp index a364ed8ef67..e91fea403b0 100644 --- a/src/devices/sound/vrender0.cpp +++ b/src/devices/sound/vrender0.cpp @@ -205,9 +205,9 @@ device_memory_interface::space_config_vector vr0sound_device::memory_space_confi // for our sound stream //------------------------------------------------- -void vr0sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vr0sound_device::sound_stream_update(sound_stream &stream) { - VR0_RenderAudio(outputs[0], outputs[1]); + VR0_RenderAudio(stream); } u16 vr0sound_device::channel_r(offs_t offset) @@ -493,7 +493,7 @@ void vr0sound_device::channel_t::write(offs_t offset, u16 data, u16 mem_mask) } } -void vr0sound_device::VR0_RenderAudio(write_stream_view &l, write_stream_view &r) +void vr0sound_device::VR0_RenderAudio(sound_stream &stream) { int div; if (m_ChnClkNum) @@ -501,7 +501,7 @@ void vr0sound_device::VR0_RenderAudio(write_stream_view &l, write_stream_view &r else div = 1 << 16; - for (int s = 0; s < l.samples(); s++) + for (int s = 0; s < stream.samples(); s++) { s32 lsample = 0, rsample = 0; for (int i = 0; i <= m_MaxChn; i++) @@ -583,7 +583,7 @@ void vr0sound_device::VR0_RenderAudio(write_stream_view &l, write_stream_view &r lsample += (sample * channel->LChnVol) >> 8; rsample += (sample * channel->RChnVol) >> 8; } - l.put_int_clamp(s, lsample, 32768); - r.put_int_clamp(s, rsample, 32768); + stream.put_int_clamp(0, s, lsample, 32768); + stream.put_int_clamp(1, s, rsample, 32768); } } diff --git a/src/devices/sound/vrender0.h b/src/devices/sound/vrender0.h index 87f16302cf3..5a2d64183f0 100644 --- a/src/devices/sound/vrender0.h +++ b/src/devices/sound/vrender0.h @@ -78,7 +78,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface configuration virtual space_config_vector memory_space_config() const override; @@ -151,7 +151,7 @@ private: u8 m_MaxChn = 0x1f; // Max Channels - 1 u8 m_ChnClkNum = 0; // Clock Number per Channel u16 m_Ctrl = 0; // 0x602 Control Functions - void VR0_RenderAudio(write_stream_view &l, write_stream_view &r); + void VR0_RenderAudio(sound_stream &stream); }; DECLARE_DEVICE_TYPE(SOUND_VRENDER0, vr0sound_device) diff --git a/src/devices/sound/wave.cpp b/src/devices/sound/wave.cpp index 1a53aaa95f7..3540d3a08fa 100644 --- a/src/devices/sound/wave.cpp +++ b/src/devices/sound/wave.cpp @@ -45,7 +45,7 @@ void wave_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void wave_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void wave_device::sound_stream_update(sound_stream &stream) { cassette_state state = m_cass->get_state() & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER); @@ -53,21 +53,16 @@ void wave_device::sound_stream_update(sound_stream &stream, std::vector<read_str { cassette_image *cassette = m_cass->get_image(); double time_index = m_cass->get_position(); - double duration = double(outputs[0].samples()) / outputs[0].sample_rate(); + double duration = double(stream.samples()) / stream.sample_rate(); - if (m_sample_buf.size() < outputs[0].samples()) - m_sample_buf.resize(outputs[0].samples()); + if (m_sample_buf.size() < stream.samples()) + m_sample_buf.resize(stream.samples()); for (int ch = 0; ch < 2; ch++) { - cassette->get_samples(ch, time_index, duration, outputs[ch].samples(), 2, &m_sample_buf[0], cassette_image::WAVEFORM_16BIT); - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - outputs[ch].put_int(sampindex, m_sample_buf[sampindex], 32768); + cassette->get_samples(ch, time_index, duration, stream.samples(), 2, &m_sample_buf[0], cassette_image::WAVEFORM_16BIT); + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) + stream.put_int(ch, sampindex, m_sample_buf[sampindex], 32768); } } - else - { - outputs[0].fill(0); - outputs[1].fill(0); - } } diff --git a/src/devices/sound/wave.h b/src/devices/sound/wave.h index 0d2db370f66..723c0b93fb6 100644 --- a/src/devices/sound/wave.h +++ b/src/devices/sound/wave.h @@ -36,7 +36,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: required_device<cassette_image_device> m_cass; diff --git a/src/devices/sound/x1_010.cpp b/src/devices/sound/x1_010.cpp index 2947ed66654..0c5a4accfaa 100644 --- a/src/devices/sound/x1_010.cpp +++ b/src/devices/sound/x1_010.cpp @@ -206,16 +206,10 @@ void x1_010_device::word_w(offs_t offset, u16 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void x1_010_device::sound_stream_update(sound_stream &stream) { - // mixer buffer zero clear - outputs[0].fill(0); - outputs[1].fill(0); - // if (m_sound_enable == 0) return; - auto &bufL = outputs[0]; - auto &bufR = outputs[1]; for (int ch = 0; ch < NUM_CHANNELS; ch++) { X1_010_CHANNEL *reg = (X1_010_CHANNEL *)&(m_reg[ch*sizeof(X1_010_CHANNEL)]); @@ -239,7 +233,7 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s LOGMASKED(LOG_SOUND, "Play sample %p - %p, channel %X volume %d:%d freq %X step %X offset %X\n", start, end, ch, volL, volR, freq, smp_step, smp_offs); } - for (int i = 0; i < bufL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { const u32 delta = smp_offs >> 4; // sample ended? @@ -249,8 +243,8 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s break; } const s8 data = (s8)(read_byte(start+delta)); - bufL.add_int(i, data * volL, 32768 * 256); - bufR.add_int(i, data * volR, 32768 * 256); + stream.add_int(0, i, data * volL, 32768 * 256); + stream.add_int(1, i, data * volR, 32768 * 256); smp_offs += smp_step; } m_smp_offset[ch] = smp_offs; @@ -271,7 +265,7 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s LOGMASKED(LOG_SOUND, "Play waveform %X, channel %X volume %X freq %4X step %X offset %X\n", reg->volume, ch, reg->end, freq, smp_step, smp_offs); } - for (int i = 0; i < bufL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { const u32 delta = env_offs >> 10; // Envelope one shot mode @@ -284,8 +278,8 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s const int volL = ((vol >> 4) & 0xf) * VOL_BASE; const int volR = ((vol >> 0) & 0xf) * VOL_BASE; const s8 data = (s8)(m_reg[start + ((smp_offs >> 10) & 0x7f)]); - bufL.add_int(i, data * volL, 32768 * 256); - bufR.add_int(i, data * volR, 32768 * 256); + stream.add_int(0, i, data * volL, 32768 * 256); + stream.add_int(1, i, data * volR, 32768 * 256); smp_offs += smp_step; env_offs += env_step; } @@ -294,10 +288,4 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s } } } - - for (int i = 0; i < bufL.samples(); i++) - { - bufL.put(i, std::clamp(bufL.getraw(i), -1.0f, 1.0f)); - bufR.put(i, std::clamp(bufR.getraw(i), -1.0f, 1.0f)); - } } diff --git a/src/devices/sound/x1_010.h b/src/devices/sound/x1_010.h index 2b206210dd6..1c636d0bd98 100644 --- a/src/devices/sound/x1_010.h +++ b/src/devices/sound/x1_010.h @@ -26,7 +26,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/xt446.cpp b/src/devices/sound/xt446.cpp index 8136f43ed90..93a7c9687fa 100644 --- a/src/devices/sound/xt446.cpp +++ b/src/devices/sound/xt446.cpp @@ -37,7 +37,7 @@ ROM_END xt446_device::xt446_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, XT446, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_maincpu(*this, "maincpu") , m_swp30(*this, "swp30") { @@ -91,7 +91,7 @@ void xt446_device::device_add_mconfig(machine_config &config) SWP30(config, m_swp30); m_swp30->set_addrmap(AS_DATA, &xt446_device::swp30_map); - m_swp30->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_swp30->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_swp30->add_route(0, *this, 1.0, 0); + m_swp30->add_route(1, *this, 1.0, 1); } diff --git a/src/devices/sound/ym2154.cpp b/src/devices/sound/ym2154.cpp index b52c4e49532..7d7c8bdd420 100644 --- a/src/devices/sound/ym2154.cpp +++ b/src/devices/sound/ym2154.cpp @@ -245,16 +245,10 @@ TIMER_CALLBACK_MEMBER(ym2154_device::delayed_irq) // sound_stream_update - generate sound data //------------------------------------------------- -void ym2154_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ym2154_device::sound_stream_update(sound_stream &stream) { static const uint16_t voltable[8] = { 0x7fa,0x751,0x6b5,0x627,0x5a4,0x52c,0x4be,0x45a }; - auto &outl = outputs[0]; - auto &outr = outputs[1]; - - outl.fill(0); - outr.fill(0); - for (int chan = 0; chan < 12; chan++) { auto &channel = m_channel[chan]; @@ -279,7 +273,7 @@ void ym2154_device::sound_stream_update(sound_stream &stream, std::vector<read_s rvol = voltable[rvol & 7] >> (rvol >> 3); auto &source = space(chan / 6); - for (int sampindex = 0; sampindex < outl.samples() && (channel.m_pos >> ADDR_SHIFT) <= channel.m_end; sampindex++) + for (int sampindex = 0; sampindex < stream.samples() && (channel.m_pos >> ADDR_SHIFT) <= channel.m_end; sampindex++) { uint8_t raw = source.read_byte(channel.m_pos++); @@ -291,8 +285,8 @@ void ym2154_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (BIT(raw, 7)) sample = -sample; - outl.add_int(sampindex, sample * lvol, 0x2000 * 0x800); - outr.add_int(sampindex, sample * rvol, 0x2000 * 0x800); + stream.add_int(0, sampindex, sample * lvol, 0x2000 * 0x800); + stream.add_int(1, sampindex, sample * rvol, 0x2000 * 0x800); } } } diff --git a/src/devices/sound/ym2154.h b/src/devices/sound/ym2154.h index 65eeb8d3a0c..f74225dd3d3 100644 --- a/src/devices/sound/ym2154.h +++ b/src/devices/sound/ym2154.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // memory space configuration virtual space_config_vector memory_space_config() const override; diff --git a/src/devices/sound/ymf271.cpp b/src/devices/sound/ymf271.cpp index 3f748656d91..aaa11319381 100644 --- a/src/devices/sound/ymf271.cpp +++ b/src/devices/sound/ymf271.cpp @@ -566,7 +566,7 @@ void ymf271_device::set_feedback(int slotnum, int64_t inp) // sound_stream_update - handle a stream update //------------------------------------------------- -void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymf271_device::sound_stream_update(sound_stream &stream) { int i, j; int op; @@ -599,7 +599,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (m_slots[slot1].active) { - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int64_t output1 = 0, output2 = 0, output3 = 0, output4 = 0; int64_t phase_mod1, phase_mod2, phase_mod3; @@ -833,7 +833,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s mixp = &m_mix_buffer[0]; if (m_slots[slot1].active) { - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int64_t output1 = 0, output3 = 0; int64_t phase_mod1, phase_mod3; @@ -900,7 +900,7 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (m_slots[slot1].active) { - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { int64_t output1 = 0, output2 = 0, output3 = 0; int64_t phase_mod1, phase_mod3; @@ -1006,29 +1006,29 @@ void ymf271_device::sound_stream_update(sound_stream &stream, std::vector<read_s } mixp = &m_mix_buffer[0]; - update_pcm(j + (3*12), mixp, outputs[0].samples()); + update_pcm(j + (3*12), mixp, stream.samples()); break; } // PCM case 3: { - update_pcm(j + (0*12), mixp, outputs[0].samples()); - update_pcm(j + (1*12), mixp, outputs[0].samples()); - update_pcm(j + (2*12), mixp, outputs[0].samples()); - update_pcm(j + (3*12), mixp, outputs[0].samples()); + update_pcm(j + (0*12), mixp, stream.samples()); + update_pcm(j + (1*12), mixp, stream.samples()); + update_pcm(j + (2*12), mixp, stream.samples()); + update_pcm(j + (3*12), mixp, stream.samples()); break; } } } mixp = &m_mix_buffer[0]; - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { - outputs[0].put_int(i, *mixp++, 32768 << 2); - outputs[1].put_int(i, *mixp++, 32768 << 2); - outputs[2].put_int(i, *mixp++, 32768 << 2); - outputs[3].put_int(i, *mixp++, 32768 << 2); + stream.put_int(0, i, *mixp++, 32768 << 2); + stream.put_int(1, i, *mixp++, 32768 << 2); + stream.put_int(2, i, *mixp++, 32768 << 2); + stream.put_int(3, i, *mixp++, 32768 << 2); } } diff --git a/src/devices/sound/ymf271.h b/src/devices/sound/ymf271.h index 535631d664b..489e0f87143 100644 --- a/src/devices/sound/ymf271.h +++ b/src/devices/sound/ymf271.h @@ -27,7 +27,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/ymfm_mame.h b/src/devices/sound/ymfm_mame.h index e6400e76d6c..fa64d3c5ab9 100644 --- a/src/devices/sound/ymfm_mame.h +++ b/src/devices/sound/ymfm_mame.h @@ -240,9 +240,9 @@ protected: } // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override + virtual void sound_stream_update(sound_stream &stream) override { - update_internal(outputs); + update_internal(stream); } // update streams @@ -253,15 +253,15 @@ protected: } // internal update helper - void update_internal(std::vector<write_stream_view> &outputs, int output_shift = 0) + void update_internal(sound_stream &stream, int output_shift = 0) { // local buffer to hold samples constexpr int MAX_SAMPLES = 256; typename ChipClass::output_data output[MAX_SAMPLES]; // parameters - int const outcount = std::min(outputs.size(), std::size(output[0].data)); - int const numsamples = outputs[0].samples(); + int const outcount = std::min(stream.output_count(), u32(std::size(output[0].data))); + int const numsamples = stream.samples(); // generate the FM/ADPCM stream for (int sampindex = 0; sampindex < numsamples; sampindex += MAX_SAMPLES) @@ -272,7 +272,7 @@ protected: { int eff_outnum = (outnum + output_shift) % OUTPUTS; for (int index = 0; index < cursamples; index++) - outputs[eff_outnum].put_int(sampindex + index, output[index].data[outnum], 32768); + stream.put_int(eff_outnum, sampindex + index, output[index].data[outnum], 32768); } } } @@ -302,17 +302,17 @@ public: protected: // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override + virtual void sound_stream_update(sound_stream &stream) override { // ymfm outputs FM first, then SSG, while MAME traditionally // wants SSG streams first; to do this, we rotate the outputs // by the number of SSG output channels - parent::update_internal(outputs, ChipClass::SSG_OUTPUTS); + parent::update_internal(stream, ChipClass::SSG_OUTPUTS); // for the single-output case, also apply boost the gain to better match // previous version, which summed instead of averaged the outputs if (ChipClass::SSG_OUTPUTS == 1) - outputs[0].apply_gain(3.0); + stream.apply_output_gain(0, 3.0); } }; diff --git a/src/devices/sound/ymopl.cpp b/src/devices/sound/ymopl.cpp index 92e9eb99928..e6c1c588734 100644 --- a/src/devices/sound/ymopl.cpp +++ b/src/devices/sound/ymopl.cpp @@ -174,10 +174,10 @@ void ymf278b_device::ymfm_external_write(ymfm::access_class type, uint32_t offse // default address space //------------------------------------------------- -void ymf278b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymf278b_device::sound_stream_update(sound_stream &stream) { // rotate the outputs so that the DO2 outputs are first - parent::update_internal(outputs, 2); + parent::update_internal(stream, 2); } diff --git a/src/devices/sound/ymopl.h b/src/devices/sound/ymopl.h index f0f44e9b5ac..a3831364175 100644 --- a/src/devices/sound/ymopl.h +++ b/src/devices/sound/ymopl.h @@ -109,7 +109,7 @@ protected: virtual void rom_bank_pre_change() override; // sound overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // ADPCM read/write callbacks diff --git a/src/devices/sound/ymz280b.cpp b/src/devices/sound/ymz280b.cpp index 8eced2f7fa8..6873048624f 100644 --- a/src/devices/sound/ymz280b.cpp +++ b/src/devices/sound/ymz280b.cpp @@ -417,16 +417,10 @@ int ymz280b_device::generate_pcm16(YMZ280BVoice *voice, s16 *buffer, int samples // sound_stream_update - handle a stream update //------------------------------------------------- -void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymz280b_device::sound_stream_update(sound_stream &stream) { - auto &lacc = outputs[0]; - auto &racc = outputs[1]; int v; - /* clear out the accumulator */ - lacc.fill(0); - racc.fill(0); - /* loop over voices */ for (v = 0; v < 8; v++) { @@ -437,7 +431,7 @@ void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_ s32 sampindex = 0; u32 new_samples, samples_left; u32 final_pos; - int remaining = lacc.samples(); + int remaining = stream.samples(); int lvol = voice->output_left; int rvol = voice->output_right; @@ -454,8 +448,8 @@ void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_ while (remaining > 0 && voice->output_pos < FRAC_ONE) { int interp_sample = ((s32(prev) * (FRAC_ONE - voice->output_pos)) + (s32(curr) * voice->output_pos)) >> FRAC_BITS; - lacc.add_int(sampindex, interp_sample * lvol / 2, 32768 * 256); - racc.add_int(sampindex, interp_sample * rvol / 2, 32768 * 256); + stream.add_int(0, sampindex, interp_sample * lvol / 2, 32768 * 256); + stream.add_int(1, sampindex, interp_sample * rvol / 2, 32768 * 256); sampindex++; voice->output_pos += voice->output_step; remaining--; @@ -519,8 +513,8 @@ void ymz280b_device::sound_stream_update(sound_stream &stream, std::vector<read_ while (remaining > 0 && voice->output_pos < FRAC_ONE) { int interp_sample = ((s32(prev) * (FRAC_ONE - voice->output_pos)) + (s32(curr) * voice->output_pos)) >> FRAC_BITS; - lacc.add_int(sampindex, interp_sample * lvol / 2, 32768 * 256); - racc.add_int(sampindex, interp_sample * rvol / 2, 32768 * 256); + stream.add_int(0, sampindex, interp_sample * lvol / 2, 32768 * 256); + stream.add_int(1, sampindex, interp_sample * rvol / 2, 32768 * 256); sampindex++; voice->output_pos += voice->output_step; remaining--; diff --git a/src/devices/sound/ymz280b.h b/src/devices/sound/ymz280b.h index 1d6f95b1b17..a5c3d754ac9 100644 --- a/src/devices/sound/ymz280b.h +++ b/src/devices/sound/ymz280b.h @@ -35,7 +35,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_rom_interface overrides virtual void rom_bank_pre_change() override; diff --git a/src/devices/sound/ymz770.cpp b/src/devices/sound/ymz770.cpp index 9c3abac4a17..f175cac853d 100644 --- a/src/devices/sound/ymz770.cpp +++ b/src/devices/sound/ymz770.cpp @@ -182,12 +182,9 @@ void ymz770_device::device_reset() // our sound stream //------------------------------------------------- -void ymz770_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void ymz770_device::sound_stream_update(sound_stream &stream) { - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - for (int i = 0; i < outL.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { sequencer(); @@ -280,8 +277,8 @@ retry: } if (m_mute) mixr = mixl = 0; - outL.put_int(i, mixl, 32768); - outR.put_int(i, mixr, 32768); + stream.put_int(0, i, mixl, 32768); + stream.put_int(1, i, mixr, 32768); } } diff --git a/src/devices/sound/ymz770.h b/src/devices/sound/ymz770.h index f9bf1eab823..70b110029b9 100644 --- a/src/devices/sound/ymz770.h +++ b/src/devices/sound/ymz770.h @@ -33,7 +33,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void internal_reg_write(uint8_t reg, uint8_t data); virtual uint32_t get_phrase_offs(int phrase) { return m_rom[(4 * phrase) + 1] << 16 | m_rom[(4 * phrase) + 2] << 8 | m_rom[(4 * phrase) + 3]; } diff --git a/src/devices/sound/zsg2.cpp b/src/devices/sound/zsg2.cpp index 786afbd475e..c1a93d874ca 100644 --- a/src/devices/sound/zsg2.cpp +++ b/src/devices/sound/zsg2.cpp @@ -283,9 +283,9 @@ void zsg2_device::filter_samples(zchan *ch) // sound_stream_update - handle a stream update //------------------------------------------------- -void zsg2_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void zsg2_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { int32_t mix[4] = {}; @@ -355,7 +355,7 @@ void zsg2_device::sound_stream_update(sound_stream &stream, std::vector<read_str } for (int output = 0; output < 4; output++) - outputs[output].put_int_clamp(i, mix[output], 32768); + stream.put_int_clamp(output, i, mix[output], 32768); } m_sample_count++; } diff --git a/src/devices/sound/zsg2.h b/src/devices/sound/zsg2.h index 91a06e27a2e..0595208a142 100644 --- a/src/devices/sound/zsg2.h +++ b/src/devices/sound/zsg2.h @@ -29,7 +29,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: const uint16_t STATUS_ACTIVE = 0x8000; diff --git a/src/devices/video/315_5124.cpp b/src/devices/video/315_5124.cpp index 8bfef88e451..3d4f2817ffd 100644 --- a/src/devices/video/315_5124.cpp +++ b/src/devices/video/315_5124.cpp @@ -257,7 +257,7 @@ sega315_5124_device::sega315_5124_device(const machine_config &mconfig, device_t : device_t(mconfig, type, tag, owner, clock) , device_memory_interface(mconfig, *this) , device_video_interface(mconfig, *this) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_hcounter_divide(1) , m_cram_size(cram_size) , m_line_timing(line_timing) @@ -2094,7 +2094,7 @@ void sega315_5124_device::device_add_mconfig(machine_config &config) { PALETTE(config, m_palette_lut, FUNC(sega315_5124_device::sega315_5124_palette), SEGA315_5124_PALETTE_SIZE); - SEGAPSG(config, m_snsnd, DERIVED_CLOCK(1, 3)).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + SEGAPSG(config, m_snsnd, DERIVED_CLOCK(1, 3)).add_route(ALL_OUTPUTS, *this, 1.0, 0); } void sega315_5246_device::device_add_mconfig(machine_config &config) @@ -2121,8 +2121,8 @@ void sega315_5377_device::device_add_mconfig(machine_config &config) m_palette_lut->set_init(FUNC(sega315_5377_device::sega315_5377_palette)); GAMEGEAR(config.replace(), m_snsnd, DERIVED_CLOCK(1, 3)); - m_snsnd->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_snsnd->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_snsnd->add_route(0, *this, 1.0, 0); + m_snsnd->add_route(1, *this, 1.0, 1); } //------------------------------------------------- diff --git a/src/devices/video/315_5313.cpp b/src/devices/video/315_5313.cpp index f48468963be..86c3436de01 100644 --- a/src/devices/video/315_5313.cpp +++ b/src/devices/video/315_5313.cpp @@ -245,7 +245,7 @@ void sega315_5313_device::device_add_mconfig(machine_config &config) { sega315_5313_mode4_device::device_add_mconfig(config); - SEGAPSG(config.replace(), m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); + SEGAPSG(config.replace(), m_snsnd, DERIVED_CLOCK(1, 15)).add_route(ALL_OUTPUTS, *this, 0.5, 0); PALETTE(config, m_gfx_palette, palette_device::BLACK).set_entries(PALETTE_PER_FRAME); PALETTE(config, m_gfx_palette_shadow, palette_device::BLACK).set_entries(PALETTE_PER_FRAME); diff --git a/src/devices/video/i8244.cpp b/src/devices/video/i8244.cpp index 3a1fb8c696f..b92b7ce9c56 100644 --- a/src/devices/video/i8244.cpp +++ b/src/devices/video/i8244.cpp @@ -769,16 +769,16 @@ u32 i8244_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, con SOUND ***************************************************************************/ -void i8244_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void i8244_device::sound_stream_update(sound_stream &stream) { u8 volume = m_vdc.s.sound & 0xf; - stream_buffer::sample_t sample_on = (m_sh_output & m_vdc.s.sound >> 7) * 0.5; + sound_stream::sample_t sample_on = (m_sh_output & m_vdc.s.sound >> 7) * 0.5; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // clock duty cycle m_sh_duty = (m_sh_duty + 1) & 0xf; - outputs[0].put(i, (m_sh_duty < volume) ? sample_on : 0.0); + stream.put(0, i, (m_sh_duty < volume) ? sample_on : 0.0); } } diff --git a/src/devices/video/i8244.h b/src/devices/video/i8244.h index 5b631e9b2b5..a231eff3030 100644 --- a/src/devices/video/i8244.h +++ b/src/devices/video/i8244.h @@ -112,7 +112,7 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(hblank_start); TIMER_CALLBACK_MEMBER(vblank_start); diff --git a/src/emu/audio_effects/aeffect.cpp b/src/emu/audio_effects/aeffect.cpp new file mode 100644 index 00000000000..dcff278099f --- /dev/null +++ b/src/emu/audio_effects/aeffect.cpp @@ -0,0 +1,46 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "aeffect.h" +#include "filter.h" +#include "compressor.h" +#include "reverb.h" +#include "eq.h" + +const char *const audio_effect::effect_names[COUNT] = { + "Filters", + "Compressor", + "Reverb", + "Equalizer" +}; + +audio_effect *audio_effect::create(int type, u32 sample_rate, audio_effect *def) +{ + switch(type) { + case FILTER: return new audio_effect_filter (sample_rate, def); + case COMPRESSOR: return new audio_effect_compressor(sample_rate, def); + case REVERB: return new audio_effect_reverb (sample_rate, def); + case EQ: return new audio_effect_eq (sample_rate, def); + } + return nullptr; +} + + +void audio_effect::copy(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) const +{ + u32 samples = src.available_samples(); + dest.prepare_space(samples); + u32 channels = src.channels(); + for(u32 channel = 0; channel != channels; channel++) { + const sample_t *srcd = src.ptrs(channel, 0); + sample_t *destd = dest.ptrw(channel, 0); + std::copy(srcd, srcd + samples, destd); + } + dest.commit(samples); +} + +u32 audio_effect::history_size() const +{ + return 0; +} diff --git a/src/emu/audio_effects/aeffect.h b/src/emu/audio_effects/aeffect.h new file mode 100644 index 00000000000..72e6279f1e6 --- /dev/null +++ b/src/emu/audio_effects/aeffect.h @@ -0,0 +1,43 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#pragma once + +#ifndef MAME_EMU_AUDIO_EFFECTS_AEFFECT_H +#define MAME_EMU_AUDIO_EFFECTS_AEFFECT_H + +class audio_effect +{ +public: + using sample_t = sound_stream::sample_t; + + enum { + FILTER, + COMPRESSOR, + REVERB, + EQ, + COUNT + }; + + static const char *const effect_names[COUNT]; + + static audio_effect *create(int type, u32 sample_rate, audio_effect *def = nullptr); + + audio_effect(u32 sample_rate, audio_effect *def) : m_default(def), m_sample_rate(sample_rate) {} + virtual ~audio_effect() = default; + + void copy(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) const; + + virtual int type() const = 0; + virtual u32 history_size() const; + virtual void apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) = 0; + virtual void config_load(util::xml::data_node const *ef_node) = 0; + virtual void config_save(util::xml::data_node *ef_node) const = 0; + virtual void default_changed() = 0; + +protected: + audio_effect *m_default; + u32 m_sample_rate; +}; + +#endif diff --git a/src/emu/audio_effects/compressor.cpp b/src/emu/audio_effects/compressor.cpp new file mode 100644 index 00000000000..06c054a4837 --- /dev/null +++ b/src/emu/audio_effects/compressor.cpp @@ -0,0 +1,28 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "compressor.h" +#include "xmlfile.h" + +audio_effect_compressor::audio_effect_compressor(u32 sample_rate, audio_effect *def) : audio_effect(sample_rate, def) +{ +} + + +void audio_effect_compressor::config_load(util::xml::data_node const *ef_node) +{ +} + +void audio_effect_compressor::config_save(util::xml::data_node *ef_node) const +{ +} + +void audio_effect_compressor::default_changed() +{ +} + +void audio_effect_compressor::apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) +{ + copy(src, dest); +} diff --git a/src/emu/audio_effects/compressor.h b/src/emu/audio_effects/compressor.h new file mode 100644 index 00000000000..551212f34e5 --- /dev/null +++ b/src/emu/audio_effects/compressor.h @@ -0,0 +1,24 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#pragma once + +#ifndef MAME_EMU_AUDIO_EFFECTS_COMPRESSOR_H +#define MAME_EMU_AUDIO_EFFECTS_COMPRESSOR_H + +#include "aeffect.h" + +class audio_effect_compressor : public audio_effect +{ +public: + audio_effect_compressor(u32 sample_rate, audio_effect *def); + virtual ~audio_effect_compressor() = default; + + virtual int type() const override { return COMPRESSOR; } + virtual void apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) override; + virtual void config_load(util::xml::data_node const *ef_node) override; + virtual void config_save(util::xml::data_node *ef_node) const override; + virtual void default_changed() override; +}; + +#endif diff --git a/src/emu/audio_effects/eq.cpp b/src/emu/audio_effects/eq.cpp new file mode 100644 index 00000000000..799b2f8c9b5 --- /dev/null +++ b/src/emu/audio_effects/eq.cpp @@ -0,0 +1,331 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "eq.h" +#include "xmlfile.h" + +// This effect implements a parametric EQ using peak and shelf filters + +// Formulas taken from (with some fixes): + +// [Zölzer 2011] "DAFX: Digital Audio Effects", Udo Zölzer, Second Edition, Wiley publishing, 2011 (Tables 2.3 and 2.4) +// [Zölzer 2008] "Digital Audio Signal Processing", Udo Zölzer, Second Edition, Wiley publishing, 2008 (Tables 5.3, 5.4 and 5.5) + +audio_effect_eq::audio_effect_eq(u32 sample_rate, audio_effect *def) : audio_effect(sample_rate, def) +{ + // Minimal init to avoid using uninitialized values when reset_* + // recomputes filters + + for(u32 band = 0; band != BANDS; band++) { + m_q[band] = 0.7; + m_f[band] = 1000; + m_db[band] = 0; + } + + reset_mode(); + reset_low_shelf(); + reset_high_shelf(); + for(u32 band = 0; band != BANDS; band++) { + reset_q(band); + reset_f(band); + reset_db(band); + } +} + +void audio_effect_eq::reset_mode() +{ + audio_effect_eq *d = static_cast<audio_effect_eq *>(m_default); + m_isset_mode = false; + m_mode = d ? d->mode() : 1; +} + +void audio_effect_eq::reset_q(u32 band) +{ + audio_effect_eq *d = static_cast<audio_effect_eq *>(m_default); + m_isset_q[band] = false; + m_q[band] = d ? d->q(band) : 0.7; + build_filter(band); +} + +void audio_effect_eq::reset_f(u32 band) +{ + static const u32 defs[BANDS] = { 80, 200, 500, 3200, 8000 }; + audio_effect_eq *d = static_cast<audio_effect_eq *>(m_default); + m_isset_f[band] = false; + m_f[band] = d ? d->f(band) : defs[band]; + build_filter(band); +} + +void audio_effect_eq::reset_db(u32 band) +{ + audio_effect_eq *d = static_cast<audio_effect_eq *>(m_default); + m_isset_db[band] = false; + m_db[band] = d ? d->db(band) : 0; + build_filter(band); +} + +void audio_effect_eq::reset_low_shelf() +{ + audio_effect_eq *d = static_cast<audio_effect_eq *>(m_default); + m_isset_low_shelf = false; + m_low_shelf = d ? d->low_shelf() : true; + build_filter(0); +} + +void audio_effect_eq::reset_high_shelf() +{ + audio_effect_eq *d = static_cast<audio_effect_eq *>(m_default); + m_isset_high_shelf = false; + m_high_shelf = d ? d->high_shelf() : true; + build_filter(BANDS-1); +} + +void audio_effect_eq::config_load(util::xml::data_node const *ef_node) +{ + if(ef_node->has_attribute("mode")) { + m_mode = ef_node->get_attribute_int("mode", 0); + m_isset_mode = true; + } else + reset_mode(); + + if(ef_node->has_attribute("low_shelf")) { + m_low_shelf = ef_node->get_attribute_int("low_shelf", 0); + m_isset_low_shelf = true; + } else + reset_low_shelf(); + + if(ef_node->has_attribute("high_shelf")) { + m_high_shelf = ef_node->get_attribute_int("high_shelf", 0); + m_isset_high_shelf = true; + } else + reset_high_shelf(); + + for(u32 band = 0; band != BANDS; band++) { + if(ef_node->has_attribute(util::string_format("q%d", band+1).c_str())) { + m_q[band] = ef_node->get_attribute_float(util::string_format("q%d", band+1).c_str(), 0); + m_isset_q[band] = true; + } else + reset_q(band); + + if(ef_node->has_attribute(util::string_format("f%d", band+1).c_str())) { + m_f[band] = ef_node->get_attribute_float(util::string_format("f%d", band+1).c_str(), 0); + m_isset_f[band] = true; + } else + reset_f(band); + + if(ef_node->has_attribute(util::string_format("db%d", band+1).c_str())) { + m_db[band] = ef_node->get_attribute_float(util::string_format("db%d", band+1).c_str(), 0); + m_isset_db[band] = true; + } else + reset_db(band); + } +} + +void audio_effect_eq::config_save(util::xml::data_node *ef_node) const +{ + if(m_isset_mode) + ef_node->set_attribute_int("mode", m_mode); + if(m_isset_low_shelf) + ef_node->set_attribute_int("low_shelf", m_low_shelf); + if(m_isset_high_shelf) + ef_node->set_attribute_int("high_shelf", m_high_shelf); + for(u32 band = 0; band != BANDS; band++) { + if(m_isset_q[band]) + ef_node->set_attribute_float(util::string_format("q%d", band+1).c_str(), m_q[band]); + if(m_isset_f[band]) + ef_node->set_attribute_float(util::string_format("f%d", band+1).c_str(), m_f[band]); + if(m_isset_db[band]) + ef_node->set_attribute_float(util::string_format("db%d", band+1).c_str(), m_db[band]); + } +} + +void audio_effect_eq::default_changed() +{ + if(!m_default) + return; + if(!m_isset_mode) + reset_mode(); + if(!m_isset_low_shelf) + reset_low_shelf(); + if(!m_isset_high_shelf) + reset_high_shelf(); + for(u32 band = 0; band != BANDS; band++) { + if(!m_isset_q[band]) + reset_q(band); + if(!m_isset_f[band]) + reset_f(band); + if(!m_isset_db[band]) + reset_db(band); + } +} + +void audio_effect_eq::set_mode(u32 mode) +{ + m_isset_mode = true; + m_mode = mode; +} + +void audio_effect_eq::set_q(u32 band, float q) +{ + m_isset_q[band] = true; + m_q[band] = q; + build_filter(band); +} + +void audio_effect_eq::set_f(u32 band, float f) +{ + m_isset_f[band] = true; + m_f[band] = f; + build_filter(band); +} + +void audio_effect_eq::set_db(u32 band, float db) +{ + m_isset_db[band] = true; + m_db[band] = db; + build_filter(band); +} + +void audio_effect_eq::set_low_shelf(bool active) +{ + m_isset_low_shelf = true; + m_low_shelf = active; + build_filter(0); +} + +void audio_effect_eq::set_high_shelf(bool active) +{ + m_isset_high_shelf = true; + m_high_shelf = active; + build_filter(BANDS-1); +} + +void audio_effect_eq::build_filter(u32 band) +{ + if(band == 0 && m_low_shelf) { + build_low_shelf(band); + return; + } + if(band == BANDS-1 && m_high_shelf) { + build_high_shelf(band); + return; + } + build_peak(band); +} + +void audio_effect_eq::build_low_shelf(u32 band) +{ + auto &fi = m_filter[band]; + if(m_db[band] == 0) { + fi.clear(); + return; + } + + float V = pow(10, abs(m_db[band])/20); + float K = tan(M_PI*m_f[band]/m_sample_rate); + float K2 = K*K; + + if(m_db[band] > 0) { + float d = 1 + sqrt(2)*K + K2; + fi.m_b0 = (1 + sqrt(2*V)*K + V*K2)/d; + fi.m_b1 = 2*(V*K2-1)/d; + fi.m_b2 = (1 - sqrt(2*V)*K + V*K2)/d; + fi.m_a1 = 2*(K2-1)/d; + fi.m_a2 = (1 - sqrt(2)*K + K2)/d; + } else { + float d = 1 + sqrt(2*V)*K + V*K2; + fi.m_b0 = (1 + sqrt(2)*K + K2)/d; + fi.m_b1 = 2*(K2-1)/d; + fi.m_b2 = (1 - sqrt(2)*K + K2)/d; + fi.m_a1 = 2*(V*K2-1)/d; + fi.m_a2 = (1 - sqrt(2*V)*K + V*K2)/d; + } +} + +void audio_effect_eq::build_high_shelf(u32 band) +{ + auto &fi = m_filter[band]; + if(m_db[band] == 0) { + fi.clear(); + return; + } + + float V = pow(10, m_db[band]/20); + float K = tan(M_PI*m_f[band]/m_sample_rate); + float K2 = K*K; + + if(m_db[band] > 0) { + float d = 1 + sqrt(2)*K + K2; + fi.m_b0 = (V + sqrt(2*V)*K + K2)/d; + fi.m_b1 = 2*(K2-V)/d; + fi.m_b2 = (V - sqrt(2*V)*K + K2)/d; + fi.m_a1 = 2*(K2-1)/d; + fi.m_a2 = (1 - sqrt(2)*K + K2)/d; + } else { + float d = 1 + sqrt(2*V)*K + V*K2; + fi.m_b0 = V*(1 + sqrt(2)*K + K2)/d; + fi.m_b1 = 2*V*(K2-1)/d; + fi.m_b2 = V*(1 - sqrt(2)*K + K2)/d; + fi.m_a1 = 2*(V*K2-1)/d; + fi.m_a2 = (1 - sqrt(2*V)*K + V*K2)/d; + } +} + +void audio_effect_eq::build_peak(u32 band) +{ + auto &fi = m_filter[band]; + if(m_db[band] == 0) { + fi.clear(); + return; + } + + float V = pow(10, m_db[band]/20); + float K = tan(M_PI*m_f[band]/m_sample_rate); + float K2 = K*K; + float Q = m_q[band]; + + if(m_db[band] > 0) { + float d = 1 + K/Q + K2; + fi.m_b0 = (1 + V*K/Q + K2)/d; + fi.m_b1 = 2*(K2-1)/d; + fi.m_b2 = (1 - V*K/Q + K2)/d; + fi.m_a1 = fi.m_b1; + fi.m_a2 = (1 - K/Q + K2)/d; + } else { + float d = 1 + K/(V*Q) + K2; + fi.m_b0 = (1 + K/Q + K2)/d; + fi.m_b1 = 2*(K2-1)/d; + fi.m_b2 = (1 - K/Q + K2)/d; + fi.m_a1 = fi.m_b1; + fi.m_a2 = (1 - K/(V*Q) + K2)/d; + } +} + + +void audio_effect_eq::apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) +{ + if(m_mode == 0) { + copy(src, dest); + return; + } + + u32 samples = src.available_samples(); + dest.prepare_space(samples); + u32 channels = src.channels(); + if(m_history.empty()) + m_history.resize(channels); + + for(u32 channel = 0; channel != channels; channel++) { + const sample_t *srcd = src.ptrs(channel, 0); + sample_t *destd = dest.ptrw(channel, 0); + for(u32 sample = 0; sample != samples; sample++) { + m_history[channel][0].push(*srcd++); + for(u32 band = 0; band != BANDS; band++) + m_filter[band].apply(m_history[channel][band], m_history[channel][band+1]); + *destd++ = m_history[channel][BANDS].m_v0; + } + } + + dest.commit(samples); +} diff --git a/src/emu/audio_effects/eq.h b/src/emu/audio_effects/eq.h new file mode 100644 index 00000000000..919d5292837 --- /dev/null +++ b/src/emu/audio_effects/eq.h @@ -0,0 +1,84 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#pragma once + +#ifndef MAME_EMU_AUDIO_EFFECTS_EQ_H +#define MAME_EMU_AUDIO_EFFECTS_EQ_H + +#include "aeffect.h" + +class audio_effect_eq : public audio_effect +{ +public: + enum { BANDS = 5 }; + + audio_effect_eq(u32 sample_rate, audio_effect *def); + virtual ~audio_effect_eq() = default; + + virtual int type() const override { return EQ; } + virtual void apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) override; + virtual void config_load(util::xml::data_node const *ef_node) override; + virtual void config_save(util::xml::data_node *ef_node) const override; + virtual void default_changed() override; + + void set_mode(u32 mode); + void set_q(u32 band, float q); + void set_f(u32 band, float f); + void set_db(u32 band, float db); + void set_low_shelf(bool active); + void set_high_shelf(bool active); + + u32 mode() const { return m_mode; } + float q(u32 band) const { return m_q[band]; } + float f(u32 band) const { return m_f[band]; } + float db(u32 band) const { return m_db[band]; } + bool low_shelf() const { return m_low_shelf; } + bool high_shelf() const { return m_high_shelf; } + + bool isset_mode() const { return m_isset_mode; } + bool isset_q(u32 band) const { return m_isset_q[band]; } + bool isset_f(u32 band) const { return m_isset_f[band]; } + bool isset_db(u32 band) const { return m_isset_db[band]; } + bool isset_low_shelf() const { return m_isset_low_shelf; } + bool isset_high_shelf() const { return m_isset_high_shelf; } + + void reset_mode(); + void reset_q(u32 band); + void reset_f(u32 band); + void reset_db(u32 band); + void reset_low_shelf(); + void reset_high_shelf(); + +private: + struct history { + float m_v0, m_v1, m_v2; + history() { m_v0 = m_v1 = m_v2 = 0; } + void push(float v) { m_v2 = m_v1; m_v1 = m_v0; m_v0 = v; } + }; + + struct filter { + float m_a1, m_a2, m_b0, m_b1, m_b2; + void clear() { m_a1 = 0; m_a2 = 0; m_b0 = 1; m_b1 = 0; m_b2 = 0; } + void apply(history &x, history &y) const { + y.push(m_b0 * x.m_v0 + m_b1 * x.m_v1 + m_b2 * x.m_v2 - m_a1 * y.m_v0 - m_a2 * y.m_v1); + } + }; + + u32 m_mode; + float m_q[BANDS], m_f[BANDS], m_db[BANDS]; + bool m_low_shelf, m_high_shelf; + std::array<filter, BANDS> m_filter; + std::vector<std::array<history, BANDS+1>> m_history; + + bool m_isset_mode, m_isset_low_shelf, m_isset_high_shelf; + bool m_isset_q[BANDS], m_isset_f[BANDS], m_isset_db[BANDS]; + + void build_filter(u32 band); + + void build_low_shelf(u32 band); + void build_high_shelf(u32 band); + void build_peak(u32 band); +}; + +#endif diff --git a/src/emu/audio_effects/filter.cpp b/src/emu/audio_effects/filter.cpp new file mode 100644 index 00000000000..70cf7ddc967 --- /dev/null +++ b/src/emu/audio_effects/filter.cpp @@ -0,0 +1,259 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "filter.h" +#include "xmlfile.h" + +// This effect implements a couple of very standard biquad filters, +// one lowpass and one highpass. + +// Formulas taken from: + +// [Zölzer 2011] "DAFX: Digital Audio Effects", Udo Zölzer, Second Edition, Wiley publishing, 2011 (Table 2.2) + + +audio_effect_filter::audio_effect_filter(u32 sample_rate, audio_effect *def) : audio_effect(sample_rate, def) +{ + // Minimal init to avoid using uninitialized values when reset_* + // recomputes filters + m_fl = m_fh = 1000; + m_ql = m_qh = 0.7; + + reset_lowpass_active(); + reset_highpass_active(); + reset_fl(); + reset_fh(); + reset_ql(); + reset_qh(); +} + +void audio_effect_filter::reset_lowpass_active() +{ + audio_effect_filter *d = static_cast<audio_effect_filter *>(m_default); + m_isset_lowpass_active = false; + m_lowpass_active = d ? d->lowpass_active() : false; + build_lowpass(); +} + +void audio_effect_filter::reset_highpass_active() +{ + audio_effect_filter *d = static_cast<audio_effect_filter *>(m_default); + m_isset_highpass_active = false; + m_highpass_active = d ? d->highpass_active() : true; + build_highpass(); +} + +void audio_effect_filter::reset_fl() +{ + audio_effect_filter *d = static_cast<audio_effect_filter *>(m_default); + m_isset_fl = false; + m_fl = d ? d->fl() : 8000; + build_lowpass(); +} + +void audio_effect_filter::reset_ql() +{ + audio_effect_filter *d = static_cast<audio_effect_filter *>(m_default); + m_isset_ql = false; + m_ql = d ? d->ql() : 0.7; + build_lowpass(); +} + +void audio_effect_filter::reset_fh() +{ + audio_effect_filter *d = static_cast<audio_effect_filter *>(m_default); + m_isset_fh = false; + m_fh = d ? d->fh() : 40; + build_highpass(); +} + +void audio_effect_filter::reset_qh() +{ + audio_effect_filter *d = static_cast<audio_effect_filter *>(m_default); + m_isset_qh = false; + m_qh = d ? d->qh() : 0.7; + build_highpass(); +} + +void audio_effect_filter::config_load(util::xml::data_node const *ef_node) +{ + if(ef_node->has_attribute("lowpass_active")) { + m_lowpass_active = ef_node->get_attribute_int("lowpass_active", 0); + m_isset_lowpass_active = true; + } else + reset_lowpass_active(); + + if(ef_node->has_attribute("fl")) { + m_fl = ef_node->get_attribute_float("fl", 0); + m_isset_fl = true; + } else + reset_fl(); + + if(ef_node->has_attribute("ql")) { + m_ql = ef_node->get_attribute_float("ql", 0); + m_isset_ql = true; + } else + reset_ql(); + + if(ef_node->has_attribute("highpass_active")) { + m_highpass_active = ef_node->get_attribute_int("highpass_active", 0); + m_isset_highpass_active = true; + } else + reset_highpass_active(); + + if(ef_node->has_attribute("fh")) { + m_fh = ef_node->get_attribute_float("fh", 0); + m_isset_fh = true; + } else + reset_fh(); + + if(ef_node->has_attribute("qh")) { + m_qh = ef_node->get_attribute_float("qh", 0); + m_isset_qh = true; + } else + reset_qh(); +} + +void audio_effect_filter::config_save(util::xml::data_node *ef_node) const +{ + if(m_isset_lowpass_active) + ef_node->set_attribute_int("lowpass_active", m_lowpass_active); + if(m_isset_fl) + ef_node->set_attribute_float("fl", m_fl); + if(m_isset_ql) + ef_node->set_attribute_float("ql", m_ql); + if(m_isset_highpass_active) + ef_node->set_attribute_int("highpass_active", m_highpass_active); + if(m_isset_fh) + ef_node->set_attribute_float("fh", m_fh); + if(m_isset_qh) + ef_node->set_attribute_float("qh", m_qh); +} + +void audio_effect_filter::default_changed() +{ + if(!m_isset_lowpass_active) + reset_lowpass_active(); + if(!m_isset_highpass_active) + reset_highpass_active(); + if(!m_isset_fl) + reset_fl(); + if(!m_isset_fh) + reset_fh(); + if(!m_isset_ql) + reset_ql(); + if(!m_isset_qh) + reset_qh(); +} + +void audio_effect_filter::apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) +{ + if(!m_lowpass_active && !m_highpass_active) { + copy(src, dest); + return; + } + + u32 samples = src.available_samples(); + dest.prepare_space(samples); + u32 channels = src.channels(); + if(m_history.empty()) + m_history.resize(channels); + + for(u32 channel = 0; channel != channels; channel++) { + const sample_t *srcd = src.ptrs(channel, 0); + sample_t *destd = dest.ptrw(channel, 0); + for(u32 sample = 0; sample != samples; sample++) { + m_history[channel][0].push(*srcd++); + m_filter[0].apply(m_history[channel][0], m_history[channel][1]); + m_filter[1].apply(m_history[channel][1], m_history[channel][2]); + *destd++ = m_history[channel][2].m_v0; + } + } + + dest.commit(samples); + +} + +void audio_effect_filter::set_lowpass_active(bool active) +{ + m_isset_lowpass_active = true; + m_lowpass_active = active; + build_lowpass(); +} + +void audio_effect_filter::set_highpass_active(bool active) +{ + m_isset_highpass_active = true; + m_highpass_active = active; + build_highpass(); +} + +void audio_effect_filter::set_fl(float f) +{ + m_isset_fl = true; + m_fl = f; + build_lowpass(); +} + +void audio_effect_filter::set_fh(float f) +{ + m_isset_fh = true; + m_fh = f; + build_highpass(); +} + +void audio_effect_filter::set_ql(float q) +{ + m_isset_ql = true; + m_ql = q; + build_lowpass(); +} + +void audio_effect_filter::set_qh(float q) +{ + m_isset_qh = true; + m_qh = q; + build_highpass(); +} + +void audio_effect_filter::build_highpass() +{ + auto &fi = m_filter[0]; + if(!m_highpass_active) { + fi.clear(); + return; + } + + float K = tan(M_PI*m_fh/m_sample_rate); + float K2 = K*K; + float Q = m_qh; + + float d = K2*Q + K + Q; + fi.m_b0 = Q/d; + fi.m_b1 = -2*Q/d; + fi.m_b2 = fi.m_b0; + fi.m_a1 = 2*Q*(K2-1)/d; + fi.m_a2 = (K2*Q - K + Q)/d; +} + +void audio_effect_filter::build_lowpass() +{ + auto &fi = m_filter[1]; + if(!m_lowpass_active) { + fi.clear(); + return; + } + + float K = tan(M_PI*m_fl/m_sample_rate); + float K2 = K*K; + float Q = m_ql; + + float d = K2*Q + K + Q; + fi.m_b0 = K2*Q/d; + fi.m_b1 = 2*K2*Q /d; + fi.m_b2 = fi.m_b0; + fi.m_a1 = 2*Q*(K2-1)/d; + fi.m_a2 = (K2*Q - K + Q)/d; +} + diff --git a/src/emu/audio_effects/filter.h b/src/emu/audio_effects/filter.h new file mode 100644 index 00000000000..13463bd6b4b --- /dev/null +++ b/src/emu/audio_effects/filter.h @@ -0,0 +1,78 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#pragma once + +#ifndef MAME_EMU_AUDIO_EFFECTS_FILTER_H +#define MAME_EMU_AUDIO_EFFECTS_FILTER_H + +#include "aeffect.h" + +class audio_effect_filter : public audio_effect +{ +public: + audio_effect_filter(u32 sample_rate, audio_effect *def); + virtual ~audio_effect_filter() = default; + + virtual int type() const override { return FILTER; } + virtual void apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) override; + virtual void config_load(util::xml::data_node const *ef_node) override; + virtual void config_save(util::xml::data_node *ef_node) const override; + virtual void default_changed() override; + + void set_lowpass_active(bool active); + void set_highpass_active(bool active); + void set_fl(float f); + void set_fh(float f); + void set_ql(float q); + void set_qh(float q); + + bool lowpass_active() const { return m_lowpass_active; } + bool highpass_active() const { return m_highpass_active; } + float fl() const { return m_fl; } + float fh() const { return m_fh; } + float ql() const { return m_ql; } + float qh() const { return m_qh; } + + bool isset_lowpass_active() const { return m_isset_lowpass_active; } + bool isset_highpass_active() const { return m_isset_highpass_active; } + bool isset_fl() const { return m_isset_fl; } + bool isset_fh() const { return m_isset_fh; } + bool isset_ql() const { return m_isset_ql; } + bool isset_qh() const { return m_isset_qh; } + + void reset_lowpass_active(); + void reset_highpass_active(); + void reset_fl(); + void reset_fh(); + void reset_ql(); + void reset_qh(); + +private: + struct history { + float m_v0, m_v1, m_v2; + history() { m_v0 = m_v1 = m_v2 = 0; } + void push(float v) { m_v2 = m_v1; m_v1 = m_v0; m_v0 = v; } + }; + + struct filter { + float m_a1, m_a2, m_b0, m_b1, m_b2; + void clear() { m_a1 = 0; m_a2 = 0; m_b0 = 1; m_b1 = 0; m_b2 = 0; } + void apply(history &x, history &y) const { + y.push(m_b0 * x.m_v0 + m_b1 * x.m_v1 + m_b2 * x.m_v2 - m_a1 * y.m_v0 - m_a2 * y.m_v1); + } + }; + + bool m_isset_lowpass_active, m_isset_highpass_active; + bool m_isset_fl, m_isset_fh, m_isset_ql, m_isset_qh; + + bool m_lowpass_active, m_highpass_active; + float m_fl, m_fh, m_ql, m_qh; + std::array<filter, 2> m_filter; + std::vector<std::array<history, 3>> m_history; + + void build_lowpass(); + void build_highpass(); +}; + +#endif diff --git a/src/emu/audio_effects/reverb.cpp b/src/emu/audio_effects/reverb.cpp new file mode 100644 index 00000000000..c7f231a9d92 --- /dev/null +++ b/src/emu/audio_effects/reverb.cpp @@ -0,0 +1,28 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#include "emu.h" +#include "reverb.h" +#include "xmlfile.h" + +audio_effect_reverb::audio_effect_reverb(u32 sample_rate, audio_effect *def) : audio_effect(sample_rate, def) +{ +} + + +void audio_effect_reverb::config_load(util::xml::data_node const *ef_node) +{ +} + +void audio_effect_reverb::config_save(util::xml::data_node *ef_node) const +{ +} + +void audio_effect_reverb::default_changed() +{ +} + +void audio_effect_reverb::apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) +{ + copy(src, dest); +} diff --git a/src/emu/audio_effects/reverb.h b/src/emu/audio_effects/reverb.h new file mode 100644 index 00000000000..36aaabb697b --- /dev/null +++ b/src/emu/audio_effects/reverb.h @@ -0,0 +1,24 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#pragma once + +#ifndef MAME_EMU_AUDIO_EFFECTS_REVERB_H +#define MAME_EMU_AUDIO_EFFECTS_REVERB_H + +#include "aeffect.h" + +class audio_effect_reverb : public audio_effect +{ +public: + audio_effect_reverb(u32 sample_rate, audio_effect *def); + virtual ~audio_effect_reverb() = default; + + virtual int type() const override { return REVERB; } + virtual void apply(const emu::detail::output_buffer_flat<sample_t> &src, emu::detail::output_buffer_flat<sample_t> &dest) override; + virtual void config_load(util::xml::data_node const *ef_node) override; + virtual void config_save(util::xml::data_node *ef_node) const override; + virtual void default_changed() override; +}; + +#endif diff --git a/src/emu/device.cpp b/src/emu/device.cpp index 7239e798be2..1a66094bde9 100644 --- a/src/emu/device.cpp +++ b/src/emu/device.cpp @@ -545,7 +545,7 @@ void device_t::start() state_registrations = machine().save().registration_count() - state_registrations; device_execute_interface *exec; device_sound_interface *sound; - if (state_registrations == 0 && (interface(exec) || interface(sound)) && type() != SPEAKER) + if (state_registrations == 0 && (interface(exec) || interface(sound)) && type() != SPEAKER && type() != MICROPHONE) { logerror("Device did not register any state to save!\n"); if ((machine().system().flags & MACHINE_SUPPORTS_SAVE) != 0) diff --git a/src/emu/disound.cpp b/src/emu/disound.cpp index 83d2c2bf084..54428126c9d 100644 --- a/src/emu/disound.cpp +++ b/src/emu/disound.cpp @@ -23,9 +23,10 @@ device_sound_interface::device_sound_interface(const machine_config &mconfig, device_t &device) : device_interface(device, "sound"), - m_outputs(0), - m_auto_allocated_inputs(0), - m_specified_inputs_mask(0) + m_sound_requested_inputs_mask(0), + m_sound_requested_outputs_mask(0), + m_sound_requested_inputs(0), + m_sound_requested_outputs(0) { } @@ -43,25 +44,20 @@ device_sound_interface::~device_sound_interface() // add_route - send sound output to a consumer //------------------------------------------------- -device_sound_interface &device_sound_interface::add_route(u32 output, const char *target, double gain, u32 input, u32 mixoutput) +device_sound_interface &device_sound_interface::add_route(u32 output, const char *target, double gain, u32 channel) { - return add_route(output, device().mconfig().current_device(), target, gain, input, mixoutput); + return add_route(output, device().mconfig().current_device(), target, gain, channel); } -device_sound_interface &device_sound_interface::add_route(u32 output, device_sound_interface &target, double gain, u32 input, u32 mixoutput) +device_sound_interface &device_sound_interface::add_route(u32 output, device_sound_interface &target, double gain, u32 channel) { - return add_route(output, target.device(), DEVICE_SELF, gain, input, mixoutput); + return add_route(output, target.device(), DEVICE_SELF, gain, channel); } -device_sound_interface &device_sound_interface::add_route(u32 output, speaker_device &target, double gain, u32 input, u32 mixoutput) -{ - return add_route(output, target, DEVICE_SELF, gain, input, mixoutput); -} - -device_sound_interface &device_sound_interface::add_route(u32 output, device_t &base, const char *target, double gain, u32 input, u32 mixoutput) +device_sound_interface &device_sound_interface::add_route(u32 output, device_t &base, const char *target, double gain, u32 channel) { assert(!device().started()); - m_route_list.emplace_back(sound_route{ output, input, mixoutput, float(gain), base, target }); + m_route_list.emplace_back(sound_route{ output, channel, float(gain), base, target, nullptr }); return *this; } @@ -71,45 +67,41 @@ device_sound_interface &device_sound_interface::add_route(u32 output, device_t & // associated with this device //------------------------------------------------- -sound_stream *device_sound_interface::stream_alloc(int inputs, int outputs, int sample_rate) -{ - return device().machine().sound().stream_alloc(*this, inputs, outputs, sample_rate, stream_update_delegate(&device_sound_interface::sound_stream_update, this), STREAM_DEFAULT_FLAGS); -} - sound_stream *device_sound_interface::stream_alloc(int inputs, int outputs, int sample_rate, sound_stream_flags flags) { - return device().machine().sound().stream_alloc(*this, inputs, outputs, sample_rate, stream_update_delegate(&device_sound_interface::sound_stream_update, this), flags); + sound_stream *stream = device().machine().sound().stream_alloc(*this, inputs, outputs, sample_rate, stream_update_delegate(&device_sound_interface::sound_stream_update, this), flags); + m_sound_streams.push_back(stream); + return stream; } + //------------------------------------------------- // inputs - return the total number of inputs -// for the given device +// forthe given device //------------------------------------------------- int device_sound_interface::inputs() const { // scan the list counting streams we own and summing their inputs int inputs = 0; - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - inputs += stream->input_count(); + for(sound_stream *stream : m_sound_streams) + inputs += stream->input_count(); return inputs; } //------------------------------------------------- // outputs - return the total number of outputs -// for the given device +// forthe given device //------------------------------------------------- int device_sound_interface::outputs() const { // scan the list counting streams we own and summing their outputs int outputs = 0; - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - outputs += stream->output_count(); + for(auto *stream : m_sound_streams) + outputs += stream->output_count(); return outputs; } @@ -120,24 +112,19 @@ int device_sound_interface::outputs() const // on that stream //------------------------------------------------- -sound_stream *device_sound_interface::input_to_stream_input(int inputnum, int &stream_inputnum) const +std::pair<sound_stream *, int> device_sound_interface::input_to_stream_input(int inputnum) const { assert(inputnum >= 0); + int orig_inputnum = inputnum; - // scan the list looking for streams owned by this device - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - { - if (inputnum < stream->input_count()) - { - stream_inputnum = inputnum; - return stream.get(); - } - inputnum -= stream->input_count(); - } + // scan the list looking forstreams owned by this device + for(auto *stream : m_sound_streams) { + if(inputnum < stream->input_count()) + return std::make_pair(stream, inputnum); + inputnum -= stream->input_count(); + } - // not found - return nullptr; + fatalerror("Requested input %d on sound device %s which only has %d.", orig_inputnum, device().tag(), inputs()); } @@ -147,24 +134,19 @@ sound_stream *device_sound_interface::input_to_stream_input(int inputnum, int &s // on that stream //------------------------------------------------- -sound_stream *device_sound_interface::output_to_stream_output(int outputnum, int &stream_outputnum) const +std::pair<sound_stream *, int> device_sound_interface::output_to_stream_output(int outputnum) const { assert(outputnum >= 0); + int orig_outputnum = outputnum; - // scan the list looking for streams owned by this device - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - { - if (outputnum < stream->output_count()) - { - stream_outputnum = outputnum; - return stream.get(); - } - outputnum -= stream->output_count(); - } + // scan the list looking forstreams owned by this device + for(auto *stream : m_sound_streams) { + if(outputnum < stream->output_count()) + return std::make_pair(stream, outputnum); + outputnum -= stream->output_count(); + } - // not found - return nullptr; + fatalerror("Requested output %d on sound device %s which only has %d.", orig_outputnum, device().tag(), outputs()); } @@ -175,9 +157,8 @@ sound_stream *device_sound_interface::output_to_stream_output(int outputnum, int float device_sound_interface::input_gain(int inputnum) const { - int stream_inputnum; - sound_stream *stream = input_to_stream_input(inputnum, stream_inputnum); - return (stream != nullptr) ? stream->input(stream_inputnum).gain() : 0.0f; + auto [stream, input] = input_to_stream_input(inputnum); + return stream->input_gain(input); } @@ -188,9 +169,32 @@ float device_sound_interface::input_gain(int inputnum) const float device_sound_interface::output_gain(int outputnum) const { - int stream_outputnum; - sound_stream *stream = output_to_stream_output(outputnum, stream_outputnum); - return (stream != nullptr) ? stream->output(stream_outputnum).gain() : 0.0f; + auto [stream, output] = output_to_stream_output(outputnum); + return stream->output_gain(output); +} + + +//------------------------------------------------- +// user_output_gain - return the user gain for the device +//------------------------------------------------- + +float device_sound_interface::user_output_gain() const +{ + if(!outputs()) + fatalerror("Requested user output gain on sound device %s which has no outputs.", device().tag()); + return m_sound_streams.front()->user_output_gain(); +} + + +//------------------------------------------------- +// user_output_gain - return the user gain on the given +// output index of the device +//------------------------------------------------- + +float device_sound_interface::user_output_gain(int outputnum) const +{ + auto [stream, output] = output_to_stream_output(outputnum); + return stream->user_output_gain(output); } @@ -201,10 +205,8 @@ float device_sound_interface::output_gain(int outputnum) const void device_sound_interface::set_input_gain(int inputnum, float gain) { - int stream_inputnum; - sound_stream *stream = input_to_stream_input(inputnum, stream_inputnum); - if (stream != nullptr) - stream->input(stream_inputnum).set_gain(gain); + auto [stream, input] = input_to_stream_input(inputnum); + stream->set_input_gain(input, gain); } @@ -216,45 +218,66 @@ void device_sound_interface::set_input_gain(int inputnum, float gain) void device_sound_interface::set_output_gain(int outputnum, float gain) { // handle ALL_OUTPUTS as a special case - if (outputnum == ALL_OUTPUTS) + if(outputnum == ALL_OUTPUTS) { - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - for (int num = 0; num < stream->output_count(); num++) - stream->output(num).set_gain(gain); + if(!outputs()) + fatalerror("Requested setting output gain on sound device %s which has no outputs.", device().tag()); + for(auto *stream : m_sound_streams) + for(int num = 0; num < stream->output_count(); num++) + stream->set_output_gain(num, gain); } // look up the stream and stream output index else { - int stream_outputnum; - sound_stream *stream = output_to_stream_output(outputnum, stream_outputnum); - if (stream != nullptr) - stream->output(stream_outputnum).set_gain(gain); + auto [stream, output] = output_to_stream_output(outputnum); + stream->set_output_gain(output, gain); } } +//------------------------------------------------- +// user_set_output_gain - set the user gain on the device +//------------------------------------------------- + +void device_sound_interface::set_user_output_gain(float gain) +{ + if(!outputs()) + fatalerror("Requested setting user output gain on sound device %s which has no outputs.", device().tag()); + for(auto *stream : m_sound_streams) + stream->set_user_output_gain(gain); +} + + + +//------------------------------------------------- +// set_user_output_gain - set the user gain on the given +// output index of the device +//------------------------------------------------- + +void device_sound_interface::set_user_output_gain(int outputnum, float gain) +{ + auto [stream, output] = output_to_stream_output(outputnum); + stream->set_user_output_gain(output, gain); +} + //------------------------------------------------- -// inputnum_from_device - return the input number -// that is connected to the given device's output +// set_route_gain - set the gain on a route //------------------------------------------------- -int device_sound_interface::inputnum_from_device(device_t &source_device, int outputnum) const +void device_sound_interface::set_route_gain(int source_channel, device_sound_interface *target, int target_channel, float gain) { - int overall = 0; - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - for (int inputnum = 0; inputnum < stream->input_count(); inputnum++, overall++) - { - auto &input = stream->input(inputnum); - if (input.valid() && &input.source().stream().device() == &source_device && input.source().index() == outputnum) - return overall; - } - return -1; + auto [sstream, schan] = output_to_stream_output(source_channel); + auto [tstream, tchan] = target->input_to_stream_input(target_channel); + tstream->update(); + if(tstream->set_route_gain(sstream, schan, tchan, gain)) + return; + + fatalerror("Trying to change the gain on a non-existant route between %s channel %d and %s channel %d\n", device().tag(), source_channel, target->device().tag(), target_channel); } + //------------------------------------------------- // interface_validity_check - validation for a // device after the configuration has been @@ -264,16 +287,16 @@ int device_sound_interface::inputnum_from_device(device_t &source_device, int ou void device_sound_interface::interface_validity_check(validity_checker &valid) const { // loop over all the routes - for (sound_route const &route : routes()) + for(sound_route const &route : routes()) { // find a device with the requested tag device_t const *const target = route.m_base.get().subdevice(route.m_target); - if (!target) + if(!target) osd_printf_error("Attempting to route sound to non-existent device '%s'\n", route.m_base.get().subtag(route.m_target)); - // if it's not a speaker or a sound device, error + // ifit's not a speaker or a sound device, error device_sound_interface const *sound; - if (target && (target->type() != SPEAKER) && !target->interface(sound)) + if(target && !target->interface(sound)) osd_printf_error("Attempting to route sound to a non-sound device '%s' (%s)\n", target->tag(), target->name()); } } @@ -284,240 +307,68 @@ void device_sound_interface::interface_validity_check(validity_checker &valid) c // devices are started //------------------------------------------------- -void device_sound_interface::interface_pre_start() +void device_sound_interface::sound_before_devices_init() { - // scan all the sound devices - sound_interface_enumerator iter(device().machine().root_device()); - for (device_sound_interface const &sound : iter) - { - // scan each route on the device - for (sound_route const &route : sound.routes()) - { - device_t *const target_device = route.m_base.get().subdevice(route.m_target); - if (target_device == &device()) - { - // see if we are the target of this route; if we are, make sure the source device is started - if (!sound.device().started()) - throw device_missing_dependencies(); - if (route.m_input != AUTO_ALLOC_INPUT) - m_specified_inputs_mask |= 1 << route.m_input; - } - } - } - - // now iterate through devices again and assign any auto-allocated inputs - m_auto_allocated_inputs = 0; - for (device_sound_interface &sound : iter) - { - // scan each route on the device - for (sound_route &route : sound.routes()) - { - // see if we are the target of this route - device_t *const target_device = route.m_base.get().subdevice(route.m_target); - if (target_device == &device() && route.m_input == AUTO_ALLOC_INPUT) - { - route.m_input = m_auto_allocated_inputs; - m_auto_allocated_inputs += (route.m_output == ALL_OUTPUTS) ? sound.outputs() : 1; - } + for(sound_route &route : routes()) { + device_t *dev = route.m_base.get().subdevice(route.m_target); + dev->interface(route.m_interface); + if(route.m_output != ALL_OUTPUTS && m_sound_requested_outputs <= route.m_output) { + m_sound_requested_outputs_mask |= u64(1) << route.m_output; + m_sound_requested_outputs = route.m_output + 1; } + route.m_interface->sound_request_input(route.m_input); } } - -//------------------------------------------------- -// interface_post_start - verify that state was -// properly set up -//------------------------------------------------- - -void device_sound_interface::interface_post_start() +void device_sound_interface::sound_after_devices_init() { - // iterate over all the sound devices - for (device_sound_interface &sound : sound_interface_enumerator(device().machine().root_device())) - { - // scan each route on the device - for (sound_route const &route : sound.routes()) - { - // if we are the target of this route, hook it up - device_t *const target_device = route.m_base.get().subdevice(route.m_target); - if (target_device == &device()) - { - // iterate over all outputs, matching any that apply - int inputnum = route.m_input; - int const numoutputs = sound.outputs(); - for (int outputnum = 0; outputnum < numoutputs; outputnum++) - if (route.m_output == outputnum || route.m_output == ALL_OUTPUTS) - { - // find the output stream to connect from - int streamoutputnum; - sound_stream *const outputstream = sound.output_to_stream_output(outputnum, streamoutputnum); - if (!outputstream) - fatalerror("Sound device '%s' specifies route for nonexistent output #%d\n", sound.device().tag(), outputnum); - - // find the input stream to connect to - int streaminputnum; - sound_stream *const inputstream = input_to_stream_input(inputnum++, streaminputnum); - if (!inputstream) - fatalerror("Sound device '%s' targeted output #%d to nonexistent device '%s' input %d\n", sound.device().tag(), outputnum, device().tag(), inputnum - 1); - - // set the input - inputstream->set_input(streaminputnum, outputstream, streamoutputnum, route.m_gain); - } - } + for(sound_route &route : routes()) { + auto [si, ii] = route.m_interface->input_to_stream_input(route.m_input); + if(!si) + fatalerror("Requesting sound route to device %s input %d which doesn't exist\n", route.m_interface->device().tag(), route.m_input); + if(route.m_output != ALL_OUTPUTS) { + auto [so, io] = output_to_stream_output(route.m_output); + if(!so) + fatalerror("Requesting sound route from device %s output %d which doesn't exist\n", device().tag(), route.m_output); + si->add_bw_route(so, io, ii, route.m_gain); + so->add_fw_route(si, ii, io); + + } else { + for(sound_stream *so : m_sound_streams) + for(int io = 0; io != so->output_count(); io ++) { + si->add_bw_route(so, io, ii, route.m_gain); + so->add_fw_route(si, ii, io); + } } } } - -//------------------------------------------------- -// interface_pre_reset - called prior to -// resetting the device -//------------------------------------------------- - -void device_sound_interface::interface_pre_reset() -{ - // update all streams on this device prior to reset - for (auto &stream : device().machine().sound().streams()) - if (&stream->device() == &device()) - stream->update(); -} - - -//------------------------------------------------- -// sound_stream_update - default implementation -// that should be overridden -//------------------------------------------------- - -void device_sound_interface::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void device_sound_interface::sound_request_input(u32 input) { - throw emu_fatalerror("sound_stream_update called but not overridden by owning class"); + m_sound_requested_inputs_mask |= u64(1) << input; + if(m_sound_requested_inputs <= input) + m_sound_requested_inputs = input + 1; } - - -//************************************************************************** -// SIMPLE DERIVED MIXER INTERFACE -//************************************************************************** - -//------------------------------------------------- -// device_mixer_interface - constructor -//------------------------------------------------- - -device_mixer_interface::device_mixer_interface(const machine_config &mconfig, device_t &device, int outputs) - : device_sound_interface(mconfig, device), - m_outputs(outputs), - m_mixer_stream(nullptr) +device_mixer_interface::device_mixer_interface(const machine_config &mconfig, device_t &device) : + device_sound_interface(mconfig, device) { } - -//------------------------------------------------- -// ~device_mixer_interface - destructor -//------------------------------------------------- - device_mixer_interface::~device_mixer_interface() { } - -//------------------------------------------------- -// interface_pre_start - perform startup prior -// to the device startup -//------------------------------------------------- - void device_mixer_interface::interface_pre_start() { - // call our parent - device_sound_interface::interface_pre_start(); - - // no inputs? that's weird - if (m_auto_allocated_inputs == 0) - { - device().logerror("Warning: mixer \"%s\" has no inputs\n", device().tag()); - return; - } - - // generate the output map - m_outputmap.resize(m_auto_allocated_inputs); - - // iterate through all routes that point to us and note their mixer output - for (device_sound_interface const &sound : sound_interface_enumerator(device().machine().root_device())) - { - for (sound_route const &route : sound.routes()) - { - // see if we are the target of this route - device_t *const target_device = route.m_base.get().subdevice(route.m_target); - if (target_device == &device() && route.m_input < m_auto_allocated_inputs) - { - int const count = (route.m_output == ALL_OUTPUTS) ? sound.outputs() : 1; - for (int output = 0; output < count; output++) - m_outputmap[route.m_input + output] = route.m_mixoutput; - } - } - } - - // keep a small buffer handy for tracking cleared buffers - m_output_clear.resize(m_outputs); - - // allocate the mixer stream - m_mixer_stream = stream_alloc(m_auto_allocated_inputs, m_outputs, device().machine().sample_rate(), STREAM_DEFAULT_FLAGS); -} - - -//------------------------------------------------- -// interface_post_load - after we load a save -// state be sure to update the mixer stream's -// output sample rate -//------------------------------------------------- - -void device_mixer_interface::interface_post_load() -{ - // mixer stream could be null if no inputs were specified - if (m_mixer_stream != nullptr) - m_mixer_stream->set_sample_rate(device().machine().sample_rate()); - - // call our parent - device_sound_interface::interface_post_load(); + u32 ni = get_sound_requested_inputs(); + u32 no = get_sound_requested_outputs(); + u32 nc = ni > no ? ni : no; + for(u32 i = 0; i != nc; i++) + stream_alloc(1, 1, SAMPLE_RATE_ADAPTIVE); } - -//------------------------------------------------- -// sound_stream_update - mix all inputs to one -// output -//------------------------------------------------- - -void device_mixer_interface::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void device_mixer_interface::sound_stream_update(sound_stream &stream) { - // special case: single input, single output, same rate - if (inputs.size() == 1 && outputs.size() == 1 && inputs[0].sample_rate() == outputs[0].sample_rate()) - { - outputs[0] = inputs[0]; - return; - } - - // reset the clear flags - std::fill(std::begin(m_output_clear), std::end(m_output_clear), false); - - // loop over inputs - for (int inputnum = 0; inputnum < m_auto_allocated_inputs; inputnum++) - { - // skip if the gain is 0 - auto &input = inputs[inputnum]; - if (input.gain() == 0) - continue; - - // either store or accumulate - int outputnum = m_outputmap[inputnum]; - auto &output = outputs[outputnum]; - if (!m_output_clear[outputnum]) - output.copy(input); - else - output.add(input); - - m_output_clear[outputnum] = true; - } - - // clear anything unused - for (int outputnum = 0; outputnum < m_outputs; outputnum++) - if (!m_output_clear[outputnum]) - outputs[outputnum].fill(0); + stream.copy(0, 0); } diff --git a/src/emu/disound.h b/src/emu/disound.h index e48ba290bc6..3d96d677d50 100644 --- a/src/emu/disound.h +++ b/src/emu/disound.h @@ -26,7 +26,6 @@ //************************************************************************** constexpr int ALL_OUTPUTS = 65535; // special value indicating all outputs for the current chip -constexpr int AUTO_ALLOC_INPUT = 65535; @@ -34,8 +33,6 @@ constexpr int AUTO_ALLOC_INPUT = 65535; // TYPE DEFINITIONS //************************************************************************** -class read_stream_view; -class write_stream_view; enum sound_stream_flags : u32; @@ -43,73 +40,85 @@ enum sound_stream_flags : u32; class device_sound_interface : public device_interface { + friend class sound_manager; + public: class sound_route { public: u32 m_output; // output index, or ALL_OUTPUTS u32 m_input; // target input index - u32 m_mixoutput; // target mixer output float m_gain; // gain std::reference_wrapper<device_t> m_base; // target search base std::string m_target; // target tag + device_sound_interface *m_interface; // target device interface }; // construction/destruction device_sound_interface(const machine_config &mconfig, device_t &device); virtual ~device_sound_interface(); - virtual bool issound() { return true; } /// HACK: allow devices to hide from the ui - // configuration access std::vector<sound_route> const &routes() const { return m_route_list; } // configuration helpers template <typename T, bool R> - device_sound_interface &add_route(u32 output, const device_finder<T, R> &target, double gain, u32 input = AUTO_ALLOC_INPUT, u32 mixoutput = 0) + device_sound_interface &add_route(u32 output, const device_finder<T, R> &target, double gain, u32 channel = 0) { const std::pair<device_t &, const char *> ft(target.finder_target()); - return add_route(output, ft.first, ft.second, gain, input, mixoutput); + return add_route(output, ft.first, ft.second, gain, channel); } - device_sound_interface &add_route(u32 output, const char *target, double gain, u32 input = AUTO_ALLOC_INPUT, u32 mixoutput = 0); - device_sound_interface &add_route(u32 output, device_sound_interface &target, double gain, u32 input = AUTO_ALLOC_INPUT, u32 mixoutput = 0); - device_sound_interface &add_route(u32 output, speaker_device &target, double gain, u32 input = AUTO_ALLOC_INPUT, u32 mixoutput = 0); + device_sound_interface &add_route(u32 output, const char *target, double gain, u32 channel = 0); + device_sound_interface &add_route(u32 output, device_sound_interface &target, double gain, u32 channel = 0); device_sound_interface &reset_routes() { m_route_list.clear(); return *this; } // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs); + virtual void sound_stream_update(sound_stream &stream) = 0; // stream creation - sound_stream *stream_alloc(int inputs, int outputs, int sample_rate); - sound_stream *stream_alloc(int inputs, int outputs, int sample_rate, sound_stream_flags flags); + sound_stream *stream_alloc(int inputs, int outputs, int sample_rate, sound_stream_flags flags = sound_stream_flags(0)); // helpers int inputs() const; int outputs() const; - sound_stream *input_to_stream_input(int inputnum, int &stream_inputnum) const; - sound_stream *output_to_stream_output(int outputnum, int &stream_outputnum) const; + std::pair<sound_stream *, int> input_to_stream_input(int inputnum) const; + std::pair<sound_stream *, int> output_to_stream_output(int outputnum) const; float input_gain(int inputnum) const; float output_gain(int outputnum) const; + float user_output_gain() const; + float user_output_gain(int outputnum) const; void set_input_gain(int inputnum, float gain); void set_output_gain(int outputnum, float gain); - int inputnum_from_device(device_t &device, int outputnum = 0) const; + void set_user_output_gain(float gain); + void set_user_output_gain(int outputnum, float gain); + void set_route_gain(int source_channel, device_sound_interface *target, int target_channel, float gain); protected: // configuration access std::vector<sound_route> &routes() { return m_route_list; } - device_sound_interface &add_route(u32 output, device_t &base, const char *tag, double gain, u32 input, u32 mixoutput); + device_sound_interface &add_route(u32 output, device_t &base, const char *tag, double gain, u32 channel); // optional operation overrides virtual void interface_validity_check(validity_checker &valid) const override; - virtual void interface_pre_start() override; - virtual void interface_post_start() override; - virtual void interface_pre_reset() override; + + u32 get_sound_requested_inputs() const { return m_sound_requested_inputs; } + u32 get_sound_requested_outputs() const { return m_sound_requested_outputs; } + u64 get_sound_requested_inputs_mask() const { return m_sound_requested_inputs_mask; } + u64 get_sound_requested_outputs_mask() const { return m_sound_requested_outputs_mask; } + +private: + void sound_request_input(u32 input); // internal state std::vector<sound_route> m_route_list; // list of sound routes - int m_outputs; // number of outputs from this instance - int m_auto_allocated_inputs; // number of auto-allocated inputs targeting us - u32 m_specified_inputs_mask; // mask of inputs explicitly specified (not counting auto-allocated) + std::vector<sound_stream *> m_sound_streams; + u64 m_sound_requested_inputs_mask; + u64 m_sound_requested_outputs_mask; + u32 m_sound_requested_inputs; + u32 m_sound_requested_outputs; + + void sound_before_devices_init(); + void sound_after_devices_init(); }; // iterator @@ -123,22 +132,15 @@ class device_mixer_interface : public device_sound_interface { public: // construction/destruction - device_mixer_interface(const machine_config &mconfig, device_t &device, int outputs = 1); + device_mixer_interface(const machine_config &mconfig, device_t &device); virtual ~device_mixer_interface(); protected: // optional operation overrides virtual void interface_pre_start() override; - virtual void interface_post_load() override; // sound interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; - - // internal state - u8 m_outputs; // number of outputs - std::vector<u8> m_outputmap; // map of inputs to outputs - std::vector<bool> m_output_clear; // flag for tracking cleared buffers - sound_stream *m_mixer_stream; // mixing stream + virtual void sound_stream_update(sound_stream &stream) override; }; // iterator diff --git a/src/emu/emufwd.h b/src/emu/emufwd.h index 89e15e4c541..cf14dcb8163 100644 --- a/src/emu/emufwd.h +++ b/src/emu/emufwd.h @@ -235,7 +235,9 @@ class sound_manager; class sound_stream; // declared in speaker.h +class sound_io_device; class speaker_device; +class microphone_device; // declared in tilemap.h class tilemap_device; diff --git a/src/emu/inpttype.h b/src/emu/inpttype.h index 22aaf0258bc..92d4cbd2be1 100644 --- a/src/emu/inpttype.h +++ b/src/emu/inpttype.h @@ -300,6 +300,8 @@ enum ioport_type : osd::u32 IPT_UI_FAVORITES, IPT_UI_EXPORT, IPT_UI_AUDIT, + IPT_UI_MIXER_ADD_FULL, + IPT_UI_MIXER_ADD_CHANNEL, // additional OSD-specified UI port types (up to 16) IPT_OSD_1, diff --git a/src/emu/inpttype.ipp b/src/emu/inpttype.ipp index 4749827c3d5..c51afa8ce31 100644 --- a/src/emu/inpttype.ipp +++ b/src/emu/inpttype.ipp @@ -926,6 +926,8 @@ namespace { INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FAVORITES, N_p("input-name", "UI Add/Remove Favorite"), input_seq(KEYCODE_LALT, KEYCODE_F) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_EXPORT, N_p("input-name", "UI Export List"), input_seq(KEYCODE_LALT, KEYCODE_E) ) \ INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_AUDIT, N_p("input-name", "UI Audit Media"), input_seq(KEYCODE_F1, input_seq::not_code, KEYCODE_LSHIFT, input_seq::not_code, KEYCODE_RSHIFT) ) \ + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_MIXER_ADD_FULL, N_p("input-name", "UI Audio add full mapping"), input_seq(KEYCODE_F) ) \ + INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_MIXER_ADD_CHANNEL, N_p("input-name", "UI Audio add channel mapping"), input_seq(KEYCODE_C) ) \ CORE_INPUT_TYPES_END() #define CORE_INPUT_TYPES_OSD \ diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 573c1b9e095..0b403ae0477 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -212,7 +212,9 @@ void running_machine::start() add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&running_machine::reset_all_devices, this)); add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&running_machine::stop_all_devices, this)); save().register_presave(save_prepost_delegate(FUNC(running_machine::presave_all_devices), this)); + m_sound->before_devices_init(); start_all_devices(); + m_sound->after_devices_init(); save().register_postload(save_prepost_delegate(FUNC(running_machine::postload_all_devices), this)); // save outputs created before start time diff --git a/src/emu/recording.cpp b/src/emu/recording.cpp index d9c25c57767..3cc9fc158b3 100644 --- a/src/emu/recording.cpp +++ b/src/emu/recording.cpp @@ -146,7 +146,10 @@ movie_recording::ptr movie_recording::create(running_machine &machine, screen_de // if we successfully create a recording, set the current time and return it if (result) + { result->set_next_frame_time(machine.time()); + result->set_channel_count(machine.sound().outputs_count()); + } return result; } @@ -190,7 +193,7 @@ bool avi_movie_recording::initialize(running_machine &machine, std::unique_ptr<e info.audio_timescale = machine.sample_rate(); info.audio_sampletime = 1; info.audio_numsamples = 0; - info.audio_channels = 2; + info.audio_channels = machine.sound().outputs_count(); info.audio_samplebits = 16; info.audio_samplerate = machine.sample_rate(); @@ -225,9 +228,9 @@ bool avi_movie_recording::add_sound_to_recording(const s16 *sound, int numsample auto profile = g_profiler.start(PROFILER_MOVIE_REC); // write the next frame - avi_file::error avierr = m_avi_file->append_sound_samples(0, sound + 0, numsamples, 1); - if (avierr == avi_file::error::NONE) - avierr = m_avi_file->append_sound_samples(1, sound + 1, numsamples, 1); + avi_file::error avierr = avi_file::error::NONE; + for (int channel = 0; channel != m_channels && avierr == avi_file::error::NONE; channel ++) + avierr = m_avi_file->append_sound_samples(channel, sound + channel, numsamples, m_channels-1); return avierr == avi_file::error::NONE; } diff --git a/src/emu/recording.h b/src/emu/recording.h index 0a26c5c7db8..98798063a73 100644 --- a/src/emu/recording.h +++ b/src/emu/recording.h @@ -50,6 +50,7 @@ public: screen_device *screen() { return m_screen; } attotime frame_period() { return m_frame_period; } void set_next_frame_time(attotime time) { m_next_frame_time = time; } + void set_channel_count(int channels) { m_channels = channels; } attotime next_frame_time() const { return m_next_frame_time; } // methods @@ -63,6 +64,8 @@ public: static const char *format_file_extension(format fmt); protected: + int m_channels; // count of audio channels + // ctor movie_recording(screen_device *screen); movie_recording(const movie_recording &) = delete; diff --git a/src/emu/resampler.cpp b/src/emu/resampler.cpp new file mode 100644 index 00000000000..b95fe80dfba --- /dev/null +++ b/src/emu/resampler.cpp @@ -0,0 +1,317 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Audio resampler + +#include "emu.h" +#include "resampler.h" + +// How an accurate resampler works ? + +// Resampling uses a number of well-known theorems we are not trying +// to prove here. + +// Samping theorem. A digital signal sampled at frequency fs is +// equivalent to an analog signal where all frequencies are between 0 +// and fs/2. Equivalent here means that the samples are unique given +// the analog signal, the analog sugnal is unique given the samples, +// and going analog -> digital -> analog is perfect. + +// That gives us point one: resampling from fs to ft is, semantically, +// reconstructing the analog signal from the fs sampling, removing all +// frequencies over ft/2, then sampling at ft. + + +// Up-sampling theorem. Take a digital signal at frequency fs, and k +// an integer > 1. Create a new digital signal at frequency fs*k by +// alternatively taking one sample from the original signal and adding +// k-1 zeroes. If one recreates the corresponding analog signal and +// removes all frequencies over fs/2, then it will be identical to the +// original analog signal, up to a constant multiplier on the +// amplitude. For the curious the frequencies over fs/2 get copies of +// the original spectrum with inversions, e.g. the frequency fs/2-a is +// copied at fs/2+a, then it's not inverted at fs..fs*1.5, inverted +// again between fs*1.5 and fs*2, etc. + +// A corollary is that if one starts for an analog signal with no +// frequencies over fs/2, samples it at fs, then up-samples to fs*k by +// adding zeroes, remove (filter) from the upsampled signal all +// frequencies over fs/2 then reconstruct the analog signal you get a +// result identical to the original signal. It's a perfect +// upsampling, assuming the filtering is perfect. + + +// Down-sampling theorem. Take a digital signal at frequency ft*k, +// with k and integer > 1. Create a new digital signal at frequency +// ft by alternatively taking one sample from the original signal and +// dropping k-1 samples. If the original signal had no frequency over +// ft/2, then the reconstructed analog signal is identical to the +// original one, up to a constant multiplier on the amplitude. So it +// is a perfect downsampling assuming the original signal has nothing +// over ft/2. For the curious if there are frequencies over ft/2, +// they end up added to the lower frequencies with inversions. The +// frequency ft/2+a is added to ft/2-a, etc (signal to upsampling, +// only the other way around). + +// The corollary there is that if one starts with a ft*k digital +// signal, filters out everything over ft/2, then keeps only one +// sample every k, then reconstruct the analog signal, you get the +// original analog signal with frequencies over ft/2 removed, which is +// reasonable given they are not representable at sampling frequency +// ft anyway. As such it is called perfect because it's the best +// possible result in any case. + +// Incidentally, the parasite audible frequencies added with the +// wrapping when the original is insufficiently filtered before +// dropping the samples are called aliasing, as in the high barely +// audible frequencies that was there but not noticed gets aliased to +// a very audible and annoying lower frequency. + + +// As a result, the recipe to go from frequency fs to ft for a digital +// signal is: + +// - find a frequency fm = ks*fs = kt*ft with ks and kt integers. +// When fs and ft are integers (our case), the easy solution is +// fm = fs * ft / gcd(fs, ft) + +// - up-sample the original signal x(t) into xm(t) with: +// xm(ks*t) = x(t) +// xm(other) = 0 + +// - filter the resulting fm Hz signal to remove all frequencies above +// fs/2. This is also called "lowpass at fs/2" + +// - lowpass at ft/2 + +// - down-sample the fm signal into the resulting y(t) signal by: +// y(t) = xm(kt*t) + +// And, assuming the filtering is perfect (it isn't, of course), the +// result is a perfect resampling. + +// Now to optimize all that. The first point is that an ideal lowpass +// at fs/2 followed by an ideal lowpass at ft/2 is strictly equivalent +// to an ideal lowpass at min(fs/2, ft/2). So only one filter is +// needed. + +// The second point depends on the type of filter used. In our case +// the filter type known as FIR has a big advantage. A FIR filter +// computes the output signal as a finite ponderated sum on the values +// of the input signal only (also called a convolution). E.g. +// y(t) = sum(k=0, n-1) a[k] * x[t-k] +// where a[0..n-1] are constants called the coefficients of the filter. + +// Why this type of filter is pertinent shows up when building the +// complete computation: + +// y(t) = filter(xm)[kt*t] +// = sum(k=0, n-1) a[k] * xm[kt*t - k] +// = sum(k=0, n-1) a[k] * | x[(kt*t-k)/ks] when kt*t-k is divisible by ks +// | 0 otherwise +// = sum(k=(kt*t) mod ks, n-1, step=ks) a[k] * x[(kt*t-k)/ks] + +// (noting p = (kt*t) mode ks, and a // b integer divide of a by b) +// = sum(k=0, (n-1 - p))//ks) a[k*ks + p] x[(kt*t) // ks) - k] + +// Splitting the filter coefficients in ks phases ap[0..ks-1] where +// ap[p][k] = a[p + ks*k], and noting t0 = (k*kt) // ks: + +// y(t) = sum(k=0, len(ap[p])-1) ap[p][k] * x[t0-k] + +// So we can take a big FIR filter and split it into ks interpolation +// filters and just apply the correct one at each sample. We can make +// things even easier by ensuring that the size of every interpolation +// filter is the same. + +// The art of creating the big FIR filter so that it doesn't change +// the signal too much is complicated enough that entire books have +// been written on the topic. We use here a simple solution which is +// to use a so-called zero-phase filter, which is a symmetrical filter +// which looks into the future to filter out the frequencies without +// changing the phases, and shift it in the past by half its length, +// making it causal (e.g. not looking into the future anymore). It is +// then called linear-phase, and has a latency of exactly half its +// length. The filter itself is made very traditionally, by +// multiplying a sinc by a Hann window. + +// The filter size is selected by maximizing the latency to 5ms and +// capping the length at 400, which experimentally seems to ensure a +// sharp rejection of more than 100dB in every case. + +// Finally, remember that up and downsampling steps multiply the +// amplitude by a constant (upsampling divides by k, downsamply +// multiply by k in fact). To compensate for that and numerical +// errors the easiest way to to normalize each phase-filter +// independently to ensure the sum of their coefficients is 1. It is +// easy to see why it works: a constant input signal must be +// transformed into a constant output signal at the exact same level. +// Having the sum of coefficients being 1 ensures that. + + +audio_resampler::audio_resampler(u32 fs, u32 ft) +{ + m_ft = ft; + m_fs = fs; + + // Compute the multiplier for fs and ft to reach the common frequency + u32 gcd = compute_gcd(fs, ft); + m_ftm = fs / gcd; + m_fsm = ft / gcd; + + // Compute the per-phase filter length to limit the latency to 5ms and capping it + m_order_per_lane = u32(fs * 0.005 * 2); + if(m_order_per_lane > 400) + m_order_per_lane = 400; + + // Reduce the number of phases to be less than 200 + m_phase_shift = 0; + while(((m_fsm - 1) >> m_phase_shift) >= 200) + m_phase_shift ++; + + m_phases = ((m_fsm - 1) >> m_phase_shift) + 1; + + // Compute the global filter length + u32 filter_length = m_order_per_lane * m_phases; + if((filter_length & 1) == 0) + filter_length --; + u32 hlen = filter_length / 2; + + // Prepare the per-phase filters + m_coefficients.resize(m_phases); + for(u32 i = 0; i != m_phases; i++) + m_coefficients[i].resize(m_order_per_lane, 0.0); + + // Select the filter cutoff. Keep it in audible range. + double cutoff = std::min(fs/2.0, ft/2.0); + if(cutoff > 20000) + cutoff = 20000; + + // Compute the filter and send the coefficients to the appropriate phase + auto set_filter = [this](u32 i, float v) { m_coefficients[i % m_phases][i / m_phases] = v; }; + + double wc = 2 * M_PI * cutoff / (double(fs) * m_fsm / (1 << m_phase_shift)); + double a = wc / M_PI; + for(u32 i = 1; i != hlen; i++) { + double win = cos(i*M_PI/hlen/2); + win = win*win; + double s = a * sin(i*wc)/(i*wc) * win; + + set_filter(hlen-1+i, s); + set_filter(hlen-1-i, s); + } + set_filter(hlen-1, a); + + // Normalize the per-phase filters + for(u32 i = 0; i != m_phases; i++) { + float s = 0; + for(u32 j = 0; j != m_order_per_lane; j++) + s += m_coefficients[i][j]; + s = 1/s; + for(u32 j = 0; j != m_order_per_lane; j++) + m_coefficients[i][j] *= s; + } + + // Compute the phase shift from one sample to the next + m_delta = m_ftm % m_fsm; + m_skip = m_ftm / m_fsm; +} + +u32 audio_resampler::compute_gcd(u32 fs, u32 ft) +{ + u32 v1 = fs > ft ? fs : ft; + u32 v2 = fs > ft ? ft : fs; + while(v2) { + u32 v3 = v1 % v2; + v1 = v2; + v2 = v3; + } + return v1; +} + +void audio_resampler::apply(const emu::detail::output_buffer_flat<sample_t> &src, std::vector<sample_t> &dest, u64 dest_sample, u32 srcc, float gain, u32 samples) const +{ + u32 seconds = dest_sample / m_ft; + u32 dsamp = dest_sample % m_ft; + u32 ssamp = (u64(dsamp) * m_fs) / m_ft; + u64 ssample = ssamp + u64(m_fs) * seconds; + u32 phase = (dsamp * m_ftm) % m_fsm; + + const sample_t *s = src.ptrs(srcc, ssample - src.sync_sample()); + sample_t *d = dest.data(); + for(u32 sample = 0; sample != samples; sample++) { + sample_t acc = 0; + const sample_t *s1 = s; + const float *filter = m_coefficients[phase >> m_phase_shift].data(); + for(u32 k = 0; k != m_order_per_lane; k++) + acc += *filter++ * *s1--; + *d++ += acc * gain; + phase += m_delta; + s += m_skip; + while(phase >= m_fsm) { + phase -= m_fsm; + s ++; + } + } +} + +void audio_resampler::apply(const emu::detail::output_buffer_interleaved<s16> &src, std::vector<sample_t> &dest, u64 dest_sample, u32 srcc, float gain, u32 samples) const +{ + u32 seconds = dest_sample / m_ft; + u32 dsamp = dest_sample % m_ft; + u32 ssamp = (u64(dsamp) * m_fs) / m_ft; + u64 ssample = ssamp + u64(m_fs) * seconds; + u32 phase = (dsamp * m_ftm) % m_fsm; + + gain /= 32768; + + const s16 *s = src.ptrs(srcc, ssample - src.sync_sample()); + sample_t *d = dest.data(); + int step = src.channels(); + for(u32 sample = 0; sample != samples; sample++) { + sample_t acc = 0; + const s16 *s1 = s; + const float *filter = m_coefficients[phase >> m_phase_shift].data(); + for(u32 k = 0; k != m_order_per_lane; k++) { + acc += *filter++ * *s1; + s1 -= step; + } + *d++ += acc * gain; + phase += m_delta; + s += m_skip * step; + while(phase >= m_fsm) { + phase -= m_fsm; + s += step; + } + } +} + + +void audio_resampler::apply(const emu::detail::output_buffer_flat<sample_t> &src, std::vector<s16> &dest, u32 destc, int dchannels, u64 dest_sample, u32 srcc, float gain, u32 samples) const +{ + u32 seconds = dest_sample / m_ft; + u32 dsamp = dest_sample % m_ft; + u32 ssamp = (u64(dsamp) * m_fs) / m_ft; + u64 ssample = ssamp + u64(m_fs) * seconds; + u32 phase = (dsamp * m_ftm) % m_fsm; + + gain *= 32768; + + const sample_t *s = src.ptrs(srcc, ssample - src.sync_sample()); + s16 *d = dest.data() + destc; + for(u32 sample = 0; sample != samples; sample++) { + sample_t acc = 0; + const sample_t *s1 = s; + const float *filter = m_coefficients[phase >> m_phase_shift].data(); + for(u32 k = 0; k != m_order_per_lane; k++) + acc += *filter++ * *s1--; + *d += acc * gain; + d += dchannels; + phase += m_delta; + s += m_skip; + while(phase >= m_fsm) { + phase -= m_fsm; + s ++; + } + } +} diff --git a/src/emu/resampler.h b/src/emu/resampler.h new file mode 100644 index 00000000000..c1b2f88f3e9 --- /dev/null +++ b/src/emu/resampler.h @@ -0,0 +1,35 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Audio resampler + +#pragma once + +#ifndef MAME_EMU_RESAMPLER_H +#define MAME_EMU_RESAMPLER_H + +#include "sound.h" + +class audio_resampler +{ +public: + using sample_t = sound_stream::sample_t; + + audio_resampler(u32 fs, u32 ft); + + u32 history_size() const { return m_order_per_lane; } + + void apply(const emu::detail::output_buffer_flat<sample_t> &src, std::vector<sample_t> &dest, u64 dest_sample, u32 srcc, float gain, u32 samples) const; + void apply(const emu::detail::output_buffer_interleaved<s16> &src, std::vector<sample_t> &dest, u64 dest_sample, u32 srcc, float gain, u32 samples) const; + void apply(const emu::detail::output_buffer_flat<sample_t> &src, std::vector<s16> &dest, u32 destc, int dchannels, u64 dest_sample, u32 srcc, float gain, u32 samples) const; + +private: + u32 m_order_per_lane, m_ftm, m_fsm, m_ft, m_fs, m_delta, m_skip, m_phases, m_phase_shift; + + std::vector<std::vector<float>> m_coefficients; + + static u32 compute_gcd(u32 fs, u32 ft); +}; + +#endif + diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index c9626855197..2cad8289f80 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -10,6 +10,9 @@ #include "emu.h" +#include "audio_effects/aeffect.h" +#include "resampler.h" + #include "config.h" #include "emuopts.h" #include "main.h" @@ -20,1632 +23,2441 @@ #include "osdepend.h" +#include <algorithm> //************************************************************************** // DEBUGGING //************************************************************************** -//#define VERBOSE 1 -#define LOG_OUTPUT_FUNC osd_printf_debug +#define LOG_OUTPUT_FUNC m_machine.logerror -#include "logmacro.h" +#define LOG_OSD_INFO (1U << 1) +#define LOG_MAPPING (1U << 2) +#define LOG_OSD_STREAMS (1U << 3) +#define LOG_ORDER (1U << 4) + +#define VERBOSE -1 -#define LOG_OUTPUT_WAV (0) +#include "logmacro.h" -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** const attotime sound_manager::STREAMS_UPDATE_ATTOTIME = attotime::from_hz(STREAMS_UPDATE_FREQUENCY); -//************************************************************************** -// STREAM BUFFER -//************************************************************************** -//------------------------------------------------- -// stream_buffer - constructor -//------------------------------------------------- -stream_buffer::stream_buffer(u32 sample_rate) : - m_end_second(0), - m_end_sample(0), - m_sample_rate(sample_rate), - m_sample_attos((sample_rate == 0) ? ATTOSECONDS_PER_SECOND : ((ATTOSECONDS_PER_SECOND + sample_rate - 1) / sample_rate)), - m_buffer(sample_rate) -{ -} +//**// Output buffer management +// Output buffers store samples produced every system-wide update. +// They give access to a window of samples produced before the update, +// and ensure that enough space is available to fit the update. -//------------------------------------------------- -// stream_buffer - destructor -//------------------------------------------------- -stream_buffer::~stream_buffer() +template<typename S> emu::detail::output_buffer_interleaved<S>::output_buffer_interleaved(u32 buffer_size, u32 channels) : + m_buffer(channels*buffer_size, 0), + m_sync_sample(0), + m_write_position(0), + m_sync_position(0), + m_history(0), + m_channels(channels) { -#if (SOUND_DEBUG) - if (m_wav_file) - flush_wav(); -#endif } +template<typename S> void emu::detail::output_buffer_interleaved<S>::set_buffer_size(u32 buffer_size) +{ + m_buffer.resize(m_channels*buffer_size, 0); +} -//------------------------------------------------- -// set_sample_rate - set a new sample rate for -// this buffer -//------------------------------------------------- - -void stream_buffer::set_sample_rate(u32 rate, bool resample) +template<typename S> void emu::detail::output_buffer_interleaved<S>::prepare_space(u32 samples) { - // skip if nothing is actually changing - if (rate == m_sample_rate) + if(!m_channels) return; - // force resampling off if coming to or from an invalid rate, or if we're at time 0 (startup) - sound_assert(rate >= SAMPLE_RATE_MINIMUM - 1); - if (rate < SAMPLE_RATE_MINIMUM || m_sample_rate < SAMPLE_RATE_MINIMUM || (m_end_second == 0 && m_end_sample == 0)) - resample = false; - - // note the time and period of the current buffer (end_time is AFTER the final sample) - attotime prevperiod = sample_period(); - attotime prevend = end_time(); - - // compute the time and period of the new buffer - attotime newperiod = attotime(0, (ATTOSECONDS_PER_SECOND + rate - 1) / rate); - attotime newend = attotime(prevend.seconds(), (prevend.attoseconds() / newperiod.attoseconds()) * newperiod.attoseconds()); - - // buffer a short runway of previous samples; in order to support smooth - // sample rate changes (needed by, e.g., Q*Bert's Votrax), we buffer a few - // samples at the previous rate, and then reconstitute them resampled - // (via simple point sampling) at the new rate. The litmus test is the - // voice when jumping off the edge in Q*Bert; without this extra effort - // it is crackly and/or glitchy at times - sample_t buffer[64]; - int buffered_samples = std::min(m_sample_rate, std::min(rate, u32(std::size(buffer)))); - - // if the new rate is lower, downsample into our holding buffer; - // otherwise just copy into our holding buffer for later upsampling - bool new_rate_higher = (rate > m_sample_rate); - if (resample) - { - if (!new_rate_higher) - backfill_downsample(&buffer[0], buffered_samples, newend, newperiod); - else - { - u32 end = m_end_sample; - for (int index = 0; index < buffered_samples; index++) - { - end = prev_index(end); -#if (SOUND_DEBUG) - // multiple resamples can occur before clearing out old NaNs so - // neuter them for this specific case - if (std::isnan(m_buffer[end])) - buffer[index] = 0; - else -#endif - buffer[index] = get(end); - } - } + // Check if potential overflow, bring data back up front if needed + u32 buffer_size = m_buffer.size() / m_channels; + if(m_write_position + samples > buffer_size) { + u32 source_start = (m_sync_position - m_history) * m_channels; + u32 source_end = m_write_position * m_channels; + std::copy(m_buffer.begin() + source_start, m_buffer.begin() + source_end, m_buffer.begin()); + m_write_position -= m_sync_position - m_history; + m_sync_position = m_history; } - // ensure our buffer is large enough to hold a full second at the new rate - if (m_buffer.size() < rate) - m_buffer.resize(rate); - - // set the new rate - m_sample_rate = rate; - m_sample_attos = newperiod.attoseconds(); + // Clear the destination range + u32 fill_start = m_write_position * m_channels; + u32 fill_end = (m_write_position + samples) * m_channels; + std::fill(m_buffer.begin() + fill_start, m_buffer.begin() + fill_end, 0.0); +} - // compute the new end sample index based on the buffer time - m_end_sample = time_to_buffer_index(prevend, false, true); +template<typename S> void emu::detail::output_buffer_interleaved<S>::commit(u32 samples) +{ + m_write_position += samples; +} - // if the new rate is higher, upsample from our temporary buffer; - // otherwise just copy our previously-downsampled data - if (resample) - { -#if (SOUND_DEBUG) - // for aggressive debugging, fill the buffer with NANs to catch anyone - // reading beyond what we resample below - fill(NAN); -#endif - - if (new_rate_higher) - backfill_upsample(&buffer[0], buffered_samples, prevend, prevperiod); - else - { - u32 end = m_end_sample; - for (int index = 0; index < buffered_samples; index++) - { - end = prev_index(end); - put(end, buffer[index]); - } - } - } +template<typename S> void emu::detail::output_buffer_interleaved<S>::sync() +{ + m_sync_sample += m_write_position - m_sync_position; + m_sync_position = m_write_position; +} - // if not resampling, clear the buffer - else - fill(0); +template<typename S> emu::detail::output_buffer_flat<S>::output_buffer_flat(u32 buffer_size, u32 channels) : + m_buffer(channels), + m_sync_sample(0), + m_write_position(0), + m_sync_position(0), + m_history(0), + m_channels(channels) +{ + for(auto &b : m_buffer) + b.resize(buffer_size, 0); } +template<typename S> void emu::detail::output_buffer_flat<S>::register_save_state(device_t &device, const char *id1, const char *id2) +{ + auto &save = device.machine().save(); -//------------------------------------------------- -// open_wav - open a WAV file for logging purposes -//------------------------------------------------- + for(unsigned int i=0; i != m_buffer.size(); i++) + save.save_item(&device, id1, id2, i, NAME(m_buffer[i])); -#if (SOUND_DEBUG) -void stream_buffer::open_wav(char const *filename) -{ - // always open at 48k so that sound programs can handle it - // re-sample as needed - m_wav_file = util::wav_open(filename, 48000, 1); -} -#endif + save.save_item(&device, id1, id2, 0, NAME(m_sync_sample)); + save.save_item(&device, id1, id2, 0, NAME(m_write_position)); + save.save_item(&device, id1, id2, 0, NAME(m_sync_position)); + save.save_item(&device, id1, id2, 0, NAME(m_history)); +} -//------------------------------------------------- -// flush_wav - flush data to the WAV file -//------------------------------------------------- +template<typename S> void emu::detail::output_buffer_flat<S>::set_buffer_size(u32 buffer_size) +{ + for(auto &b : m_buffer) + b.resize(buffer_size, 0); +} -#if (SOUND_DEBUG) -void stream_buffer::flush_wav() +template<typename S> void emu::detail::output_buffer_flat<S>::prepare_space(u32 samples) { - // skip if no file - if (!m_wav_file) + if(!m_channels) return; - // grab a view of the data from the last-written point - read_stream_view view(this, m_last_written, m_end_sample, 1.0f); - m_last_written = m_end_sample; + // Check if potential overflow, bring data back up front if needed + u32 buffer_size = m_buffer[0].size(); + if(m_write_position + samples > buffer_size) { + u32 source_start = m_sync_position - m_history; + u32 source_end = m_write_position; + for(u32 channel = 0; channel != m_channels; channel++) + std::copy(m_buffer[channel].begin() + source_start, m_buffer[channel].begin() + source_end, m_buffer[channel].begin()); + m_write_position -= source_start; + m_sync_position = m_history; + } - // iterate over chunks for conversion - s16 buffer[1024]; - for (int samplebase = 0; samplebase < view.samples(); samplebase += std::size(buffer)) - { - // clamp to the buffer size - int cursamples = view.samples() - samplebase; - if (cursamples > std::size(buffer)) - cursamples = std::size(buffer); + // Clear the destination range + u32 fill_start = m_write_position; + u32 fill_end = m_write_position + samples; + for(u32 channel = 0; channel != m_channels; channel++) + std::fill(m_buffer[channel].begin() + fill_start, m_buffer[channel].begin() + fill_end, 0.0); +} - // convert and fill - for (int sampindex = 0; sampindex < cursamples; sampindex++) - buffer[sampindex] = s16(view.get(samplebase + sampindex) * 32768.0); +template<typename S> void emu::detail::output_buffer_flat<S>::commit(u32 samples) +{ + m_write_position += samples; +} - // write to the WAV - util::wav_add_data_16(*m_wav_file, buffer, cursamples); - } +template<typename S> void emu::detail::output_buffer_flat<S>::sync() +{ + m_sync_sample += m_write_position - m_sync_position; + m_sync_position = m_write_position; } -#endif +template<typename S> void emu::detail::output_buffer_flat<S>::set_history(u32 history) +{ + m_history = history; + if(m_sync_position < m_history) { + u32 delta = m_history - m_sync_position; + if(m_write_position) + for(u32 channel = 0; channel != m_channels; channel++) { + std::copy_backward(m_buffer[channel].begin(), m_buffer[channel].begin() + m_write_position, m_buffer[channel].begin() + m_write_position + delta); + std::fill(m_buffer[channel].begin() + 1, m_buffer[channel].begin() + delta, m_buffer[channel][0]); + } + else + for(u32 channel = 0; channel != m_channels; channel++) + std::fill(m_buffer[channel].begin(), m_buffer[channel].begin() + m_history, 0.0); -//------------------------------------------------- -// index_time - return the attotime of a given -// index within the buffer -//------------------------------------------------- + m_write_position += delta; + m_sync_position = m_history; + } +} -attotime stream_buffer::index_time(s32 index) const +template<typename S> void emu::detail::output_buffer_flat<S>::resample(u32 previous_rate, u32 next_rate, attotime sync_time, attotime now) { - index = clamp_index(index); - return attotime(m_end_second - ((index > m_end_sample) ? 1 : 0), index * m_sample_attos); -} + if(!m_write_position) + return; + auto si = [](attotime time, u32 rate) -> s64 { + return time.m_seconds * rate + ((time.m_attoseconds / 100000000) * rate) / 10000000000; + }; + + auto cv = [](u32 source_rate, u32 dest_rate, s64 time) -> std::pair<s64, double> { + s64 sec = time / source_rate; + s64 prem = time % source_rate; + double nrem = double(prem * dest_rate) / double(source_rate); + s64 cyc = s64(nrem); + return std::make_pair(sec * dest_rate + cyc, nrem - cyc); + }; + + // Compute what will be the new start, sync and write positions (if it fits) + s64 nsync = si(sync_time, next_rate); + s64 nwrite = si(now, next_rate); + s64 pbase = m_sync_sample - m_sync_position; // Beware, pbase can be negative at startup due to history size + auto [nbase, nbase_dec] = cv(previous_rate, next_rate, pbase < 0 ? 0 : pbase); + nbase += 1; + if(nbase > nsync) + nbase = nsync; + + u32 space = m_buffer[0].size(); + if(nwrite - nbase > space) { + nbase = nwrite - space; + if(nbase > nsync) + fatalerror("Stream buffer too small, can't proceed, rate change %d -> %d, space=%d\n", previous_rate, next_rate, space); + } -//------------------------------------------------- -// time_to_buffer_index - given an attotime, -// return the buffer index corresponding to it -//------------------------------------------------- + auto [ppos, pdec] = cv(next_rate, previous_rate, nbase); + if(ppos < pbase || ppos >= pbase + m_write_position) + fatalerror("Something went very wrong, ppos=%d, pbase=%d, pbase+wp=%d\n", ppos, pbase, pbase + m_write_position); -u32 stream_buffer::time_to_buffer_index(attotime time, bool round_up, bool allow_expansion) -{ - // compute the sample index within the second - int sample = (time.attoseconds() + (round_up ? (m_sample_attos - 1) : 0)) / m_sample_attos; - sound_assert(sample >= 0 && sample <= size()); + double step = double(previous_rate) / double(next_rate); + u32 pindex = ppos - pbase; + u32 nend = nwrite - nbase; - // if the time is past the current end, make it the end - if (time.seconds() > m_end_second || (time.seconds() == m_end_second && sample > m_end_sample)) - { - sound_assert(allow_expansion); + // Warning: don't try to be too clever, the m_buffer storage is + // registered in the save state system, so it must not move or + // change size + + std::vector<S> copy(m_write_position); + for(u32 channel = 0; channel != m_channels; channel++) { + std::copy(m_buffer[channel].begin(), m_buffer[channel].begin() + m_write_position, copy.begin()); - m_end_sample = sample; - m_end_second = time.m_seconds; + // Interpolate the buffer contents - // due to round_up, we could tweak over the line into the next second - if (sample >= size()) - { - m_end_sample -= size(); - m_end_second++; + for(u32 nindex = 0; nindex != nend; nindex++) { + u32 pi0 = std::clamp(pindex, 0U, m_write_position - 1); + u32 pi1 = std::clamp(pindex + 1, 0U, m_write_position - 1); + m_buffer[channel][nindex] = copy[pi0] * (1-pdec) + copy[pi1] * pdec; + + pdec += step; + if(pdec >= 1) { + int s = s32(pdec); + pindex += s; + pdec -= s; + } } } - // if the time is before the start, fail - if (time.seconds() + 1 < m_end_second || (time.seconds() + 1 == m_end_second && sample < m_end_sample)) - throw emu_fatalerror("Attempt to create an out-of-bounds view"); + m_sync_sample = nsync; + m_sync_position = m_sync_sample - nbase; + m_write_position = nend; - return clamp_index(sample); + // history and the associated resizes are taken into account later } +template class emu::detail::output_buffer_flat<sound_stream::sample_t>; +template class emu::detail::output_buffer_interleaved<s16>; -//------------------------------------------------- -// backfill_downsample - this is called BEFORE -// the sample rate change to downsample from the -// end of the current buffer into a temporary -// holding location -//------------------------------------------------- -void stream_buffer::backfill_downsample(sample_t *dest, int samples, attotime newend, attotime newperiod) -{ - // compute the time of the first sample to be backfilled; start one period before - attotime time = newend - newperiod; +// Not inline because with the unique_ptr it would require audio_effect in emu.h - // loop until we run out of buffered data - int dstindex; - for (dstindex = 0; dstindex < samples && time.seconds() >= 0; dstindex++) - { - u32 srcindex = time_to_buffer_index(time, false); -#if (SOUND_DEBUG) - // multiple resamples can occur before clearing out old NaNs so - // neuter them for this specific case - if (std::isnan(m_buffer[srcindex])) - dest[dstindex] = 0; - else -#endif - dest[dstindex] = get(srcindex); - time -= newperiod; - } - for ( ; dstindex < samples; dstindex++) - dest[dstindex] = 0; +sound_manager::effect_step::effect_step(u32 buffer_size, u32 channels) : m_buffer(buffer_size, channels) +{ } -//------------------------------------------------- -// backfill_upsample - this is called AFTER the -// sample rate change to take a copied buffer -// of samples at the old rate and upsample them -// to the new (current) rate -//------------------------------------------------- +//**// Streams and routes -void stream_buffer::backfill_upsample(sample_t const *src, int samples, attotime prevend, attotime prevperiod) +sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags) : + m_device(device), + m_output_buffer(0, outputs), + m_sample_rate(sample_rate == SAMPLE_RATE_INPUT_ADAPTIVE || sample_rate == SAMPLE_RATE_OUTPUT_ADAPTIVE || sample_rate == SAMPLE_RATE_ADAPTIVE ? 0 : sample_rate), + m_input_count(inputs), + m_output_count(outputs), + m_input_adaptive(sample_rate == SAMPLE_RATE_INPUT_ADAPTIVE || sample_rate == SAMPLE_RATE_ADAPTIVE), + m_output_adaptive(sample_rate == SAMPLE_RATE_OUTPUT_ADAPTIVE || sample_rate == SAMPLE_RATE_ADAPTIVE), + m_synchronous((flags & STREAM_SYNCHRONOUS) != 0), + m_started(false), + m_sync_timer(nullptr), + m_callback(std::move(callback)) { - // compute the time of the first sample to be backfilled; start one period before - attotime time = end_time() - sample_period(); - - // also adjust the buffered sample end time to point to the sample time of the - // final sample captured - prevend -= prevperiod; + sound_assert(outputs > 0 || inputs > 0); - // loop until we run out of buffered data - u32 end = m_end_sample; - int srcindex = 0; - while (1) - { - // if our backfill time is before the current buffered sample time, - // back up until we have a sample that covers this time - while (time < prevend && srcindex < samples) - { - prevend -= prevperiod; - srcindex++; - } + // create a name + m_name = m_device.name(); + m_name += " '"; + m_name += m_device.tag(); + m_name += "'"; - // stop when we run out of source - if (srcindex >= samples) - break; + // create an update timer for synchronous streams + if(synchronous()) + m_sync_timer = m_device.timer_alloc(FUNC(sound_stream::sync_update), this); - // write this sample at the pevious position - end = prev_index(end); - put(end, src[srcindex]); + // create the gain vectors + m_input_channel_gain.resize(m_input_count, 1.0); + m_output_channel_gain.resize(m_output_count, 1.0); + m_user_output_channel_gain.resize(m_output_count, 1.0); + m_user_output_gain = 1.0; - // back up to the next sample time - time -= sample_period(); - } } +sound_stream::~sound_stream() +{ +} +void sound_stream::add_bw_route(sound_stream *source, int output, int input, float gain) +{ + m_bw_routes.emplace_back(route_bw(source, output, input, gain)); +} -//************************************************************************** -// SOUND STREAM OUTPUT -//************************************************************************** - -//------------------------------------------------- -// sound_stream_output - constructor -//------------------------------------------------- +void sound_stream::add_fw_route(sound_stream *target, int input, int output) +{ + m_fw_routes.emplace_back(route_fw(target, input, output)); +} -sound_stream_output::sound_stream_output() : - m_stream(nullptr), - m_index(0), - m_gain(1.0) +bool sound_stream::set_route_gain(sound_stream *source, int source_channel, int target_channel, float gain) { + for(auto &r : m_bw_routes) + if(r.m_source == source && r.m_output == source_channel && r.m_input == target_channel) { + r.m_gain = gain; + return true; + } + return false; } +std::vector<sound_stream *> sound_stream::sources() const +{ + std::vector<sound_stream *> streams; + for(const route_bw &route : m_bw_routes) { + sound_stream *stream = route.m_source; + for(const sound_stream *s : streams) + if(s == stream) + goto already; + streams.push_back(stream); + already:; + } + return streams; +} -//------------------------------------------------- -// init - initialization -//------------------------------------------------- +std::vector<sound_stream *> sound_stream::targets() const +{ + std::vector<sound_stream *> streams; + for(const route_fw &route : m_fw_routes) { + sound_stream *stream = route.m_target; + for(const sound_stream *s : streams) + if(s == stream) + goto already; + streams.push_back(stream); + already:; + } + return streams; +} -void sound_stream_output::init(sound_stream &stream, u32 index, char const *tag) +void sound_stream::register_state() { - // set the passed-in data - m_stream = &stream; - m_index = index; + // create a unique tag for saving + m_state_tag = string_format("%d", m_device.machine().sound().unique_id()); + auto &save = m_device.machine().save(); + + save.save_item(&m_device, "stream.sound_stream", m_state_tag.c_str(), 0, NAME(m_sample_rate)); + if(m_input_count) + save.save_item(&m_device, "stream.sound_stream", m_state_tag.c_str(), 0, NAME(m_input_channel_gain)); + if(m_output_count) + save.save_item(&m_device, "stream.sound_stream", m_state_tag.c_str(), 0, NAME(m_output_channel_gain)); + // user gains go to .cfg files, not state files - // save our state - auto &save = stream.device().machine().save(); - save.save_item(&stream.device(), "stream.output", tag, index, NAME(m_gain)); + m_output_buffer.register_save_state(m_device, "stream.sound_stream.output_buffer", m_state_tag.c_str()); -#if (LOG_OUTPUT_WAV) - std::string filename = stream.device().machine().basename(); - filename += stream.device().tag(); - for (int index = 0; index < filename.size(); index++) - if (filename[index] == ':') - filename[index] = '_'; - if (dynamic_cast<default_resampler_stream *>(&stream) != nullptr) - filename += "_resampler"; - filename += "_OUT_"; - char buf[10]; - sprintf(buf, "%d", index); - filename += buf; - filename += ".wav"; - m_buffer.open_wav(filename.c_str()); -#endif + for(unsigned int i=0; i != m_bw_routes.size(); i++) + save.save_item(&m_device, "stream.sound_stream", m_state_tag.c_str(), i, m_bw_routes[i].m_gain, "route_gain"); } -//------------------------------------------------- -// name - return the friendly name of this output -//------------------------------------------------- +void sound_stream::compute_dependants() +{ + m_dependant_streams.clear(); + for(const route_bw &r : m_bw_routes) + r.m_source->add_dependants(m_dependant_streams); +} -std::string sound_stream_output::name() const +void sound_stream::add_dependants(std::vector<sound_stream *> &deps) { - // start with our owning stream's name - std::ostringstream str; - util::stream_format(str, "%s Ch.%d", m_stream->name(), m_stream->output_base() + m_index); - return str.str(); + for(const route_bw &r : m_bw_routes) + r.m_source->add_dependants(deps); + for(sound_stream *dep : deps) + if(dep == this) + return; + deps.push_back(this); } -//------------------------------------------------- -// optimize_resampler - optimize resamplers by -// either returning the native rate or another -// input's resampler if they can be reused -//------------------------------------------------- +//**// Stream sample rate -sound_stream_output &sound_stream_output::optimize_resampler(sound_stream_output *input_resampler) +void sound_stream::set_sample_rate(u32 new_rate) { - // if no resampler, or if the resampler rate matches our rate, return ourself - if (input_resampler == nullptr || buffer_sample_rate() == input_resampler->buffer_sample_rate()) - return *this; - - // scan our list of resamplers to see if there's another match - for (auto &resampler : m_resampler_list) - if (resampler->buffer_sample_rate() == input_resampler->buffer_sample_rate()) - return *resampler; - - // add the input to our list and return the one we were given back - m_resampler_list.push_back(input_resampler); - return *input_resampler; + m_input_adaptive = m_output_adaptive = false; + internal_set_sample_rate(new_rate); } +void sound_stream::internal_set_sample_rate(u32 new_rate) +{ + if(m_started) { + update(); + m_output_buffer.resample(m_sample_rate, new_rate, m_sync_time, m_device.machine().time()); + m_sample_rate = new_rate; + for(const route_fw &r : m_fw_routes) + r.m_target->create_resamplers(); + create_resamplers(); + lookup_history_sizes(); + } else + m_sample_rate = new_rate; +} -//************************************************************************** -// SOUND STREAM INPUT -//************************************************************************** +bool sound_stream::try_solving_frequency() +{ + if(frequency_is_solved()) + return false; -//------------------------------------------------- -// sound_stream_input - constructor -//------------------------------------------------- + if(input_adaptive() && !output_adaptive()) { + u32 freq = 0; + for(const route_bw &r : m_bw_routes) { + if(!r.m_source->frequency_is_solved()) + return false; + if(freq < r.m_source->sample_rate()) + freq = r.m_source->sample_rate(); + } + m_sample_rate = freq; + return true; + + } else if(output_adaptive() && !input_adaptive()) { + u32 freq = 0; + for(const route_fw &r : m_fw_routes) { + if(!r.m_target->frequency_is_solved()) + return false; + if(freq < r.m_target->sample_rate()) + freq = r.m_target->sample_rate(); + } + m_sample_rate = freq; + return true; + + } else { + u32 freqbw = 0; + for(const route_bw &r : m_bw_routes) { + if(!r.m_source->frequency_is_solved()) { + freqbw = 0; + break; + } + if(freqbw < r.m_source->sample_rate()) + freqbw = r.m_source->sample_rate(); + } + u32 freqfw = 0; + for(const route_fw &r : m_fw_routes) { + if(!r.m_target->frequency_is_solved()) { + freqfw = 0; + break; + } + if(freqfw < r.m_target->sample_rate()) + freqfw = r.m_target->sample_rate(); + } + if(!freqbw && !freqfw) + return false; -sound_stream_input::sound_stream_input() : - m_owner(nullptr), - m_native_source(nullptr), - m_resampler_source(nullptr), - m_index(0), - m_gain(1.0), - m_user_gain(1.0) -{ + m_sample_rate = freqfw > freqbw ? freqfw : freqbw; + return true; + } } -//------------------------------------------------- -// init - initialization -//------------------------------------------------- +//**// Stream flow and updates -void sound_stream_input::init(sound_stream &stream, u32 index, char const *tag, sound_stream_output *resampler) +void sound_stream::init() { - // set the passed-in values - m_owner = &stream; - m_index = index; - m_resampler_source = resampler; - - // save our state - auto &save = stream.device().machine().save(); - save.save_item(&stream.device(), "stream.input", tag, index, NAME(m_gain)); - save.save_item(&stream.device(), "stream.input", tag, index, NAME(m_user_gain)); -} + // Ensure the buffer size is non-zero, since a stream can be started at any time + u32 bsize = m_sample_rate ? m_sample_rate : 48000; + m_input_buffer.resize(m_input_count); + for(auto &b : m_input_buffer) + b.resize(bsize); + m_output_buffer.set_buffer_size(bsize); -//------------------------------------------------- -// name - return the friendly name of this input -//------------------------------------------------- + m_samples_to_update = 0; + m_started = true; + if(synchronous()) + reprime_sync_timer(); +} -std::string sound_stream_input::name() const +u64 sound_stream::get_current_sample_index() const { - // start with our owning stream's name - std::ostringstream str; - util::stream_format(str, "%s", m_owner->name()); - - // if we have a source, indicate where the sound comes from by device name and tag - if (valid()) - util::stream_format(str, " <- %s", m_native_source->name()); - return str.str(); + attotime now = m_device.machine().time(); + return now.m_seconds * m_sample_rate + ((now.m_attoseconds / 1000000000) * m_sample_rate) / 1000000000; } +void sound_stream::update() +{ + if(!is_active()) + return; -//------------------------------------------------- -// set_source - wire up the output source for -// our consumption -//------------------------------------------------- + // Find out where we are and how much we have to do + u64 idx = get_current_sample_index(); + m_samples_to_update = idx - m_output_buffer.write_sample(); -void sound_stream_input::set_source(sound_stream_output *source) -{ - m_native_source = source; - if (m_resampler_source != nullptr) - m_resampler_source->stream().set_input(0, &source->stream(), source->index()); -} + if(m_samples_to_update <= 0) + return; + // If there's anything to do, well, do it, starting with the dependencies + for(auto &stream : m_dependant_streams) + stream->update_nodeps(); -//------------------------------------------------- -// update - update our source's stream to the -// current end time and return a view to its -// contents -//------------------------------------------------- + do_update(); +} -read_stream_view sound_stream_input::update(attotime start, attotime end) +void sound_stream::update_nodeps() { - // shouldn't get here unless valid - sound_assert(valid()); - - // pick an optimized resampler - sound_stream_output &source = m_native_source->optimize_resampler(m_resampler_source); + if(!is_active()) + return; - // if not using our own resampler, keep it up to date in case we need to invoke it later - if (m_resampler_source != nullptr && &source != m_resampler_source) - m_resampler_source->set_end_time(end); + // Find out where we are and how much we have to do + u64 idx = get_current_sample_index(); + m_samples_to_update = idx - m_output_buffer.write_sample(); + if(m_samples_to_update <= 0) + return; - // update the source, returning a view of the needed output over the start and end times - return source.stream().update_view(start, end, source.index()).apply_gain(m_gain * m_user_gain * source.gain()); + // If there's anything to do, well, do it + do_update(); } +void sound_stream::create_resamplers() +{ + if(!is_active()) { + for(auto &r : m_bw_routes) + r.m_resampler = nullptr; + return; + } -//------------------------------------------------- -// apply_sample_rate_changes - tell our sources -// to apply any sample rate changes, informing -// them of our current rate -//------------------------------------------------- + for(auto &r : m_bw_routes) + if(r.m_source->is_active() && r.m_source->sample_rate() != m_sample_rate) + r.m_resampler = m_device.machine().sound().get_resampler(r.m_source->sample_rate(), m_sample_rate); + else + r.m_resampler = nullptr; +} -void sound_stream_input::apply_sample_rate_changes(u32 updatenum, u32 downstream_rate) +void sound_stream::lookup_history_sizes() { - // shouldn't get here unless valid - sound_assert(valid()); + u32 history = 0; + for(auto &r : m_fw_routes) { + u32 h = r.m_target->get_history_for_bw_route(this, r.m_output); + if(h > history) + history = h; + } - // if we have a resampler, tell it (and it will tell the native source) - if (m_resampler_source != nullptr) - m_resampler_source->stream().apply_sample_rate_changes(updatenum, downstream_rate); + m_output_buffer.set_history(history); +} - // otherwise, just tell the native source directly - else - m_native_source->stream().apply_sample_rate_changes(updatenum, downstream_rate); +u32 sound_stream::get_history_for_bw_route(const sound_stream *source, u32 channel) const +{ + u32 history = 0; + for(auto &r : m_bw_routes) + if(r.m_source == source && r.m_output == channel && r.m_resampler) { + u32 h = r.m_resampler->history_size(); + if(h > history) + history = h; + } + return history; } +void sound_stream::do_update() +{ + // Mix in all the inputs (if any) + if(m_input_count) { + for(auto &b : m_input_buffer) + std::fill(b.begin(), b.begin() + m_samples_to_update, 0.0); + for(const auto &r : m_bw_routes) { + if(!r.m_source->is_active()) + continue; + + float gain = r.m_source->m_user_output_gain * r.m_source->m_output_channel_gain[r.m_output] * r.m_source->m_user_output_channel_gain[r.m_output] * r.m_gain * m_input_channel_gain[r.m_input]; + auto &db = m_input_buffer[r.m_input]; + if(r.m_resampler) + r.m_resampler->apply(r.m_source->m_output_buffer, db, m_output_buffer.write_sample(), r.m_output, gain, m_samples_to_update); + + else { + const sample_t *sb = r.m_source->m_output_buffer.ptrs(r.m_output, m_output_buffer.write_sample() - r.m_source->m_output_buffer.sync_sample()); + for(u32 i = 0; i != m_samples_to_update; i++) + db[i] += sb[i] * gain; + } + } + } + // Prepare the output space (if any) + m_output_buffer.prepare_space(m_samples_to_update); -//************************************************************************** -// SOUND STREAM -//************************************************************************** + // Call the callback + m_callback(*this); -//------------------------------------------------- -// sound_stream - private common constructor -//------------------------------------------------- + // Update the indexes + m_output_buffer.commit(m_samples_to_update); +} -sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, sound_stream_flags flags) : - m_device(device), - m_next(nullptr), - m_sample_rate((sample_rate < SAMPLE_RATE_MINIMUM) ? (SAMPLE_RATE_MINIMUM - 1) : (sample_rate < SAMPLE_RATE_OUTPUT_ADAPTIVE) ? sample_rate : 48000), - m_pending_sample_rate(SAMPLE_RATE_INVALID), - m_last_sample_rate_update(0), - m_input_adaptive(sample_rate == SAMPLE_RATE_INPUT_ADAPTIVE), - m_output_adaptive(sample_rate == SAMPLE_RATE_OUTPUT_ADAPTIVE), - m_synchronous((flags & STREAM_SYNCHRONOUS) != 0), - m_resampling_disabled((flags & STREAM_DISABLE_INPUT_RESAMPLING) != 0), - m_sync_timer(nullptr), - m_last_update_end_time(attotime::zero), - m_input(inputs), - m_input_view(inputs), - m_empty_buffer(100), - m_output_base(output_base), - m_output(outputs), - m_output_view(outputs) +void sound_stream::sync(attotime now) { - sound_assert(outputs > 0); + m_sync_time = now; + m_output_buffer.sync(); +} + - // create a name - m_name = m_device.name(); - m_name += " '"; - m_name += m_device.tag(); - m_name += "'"; - // create a unique tag for saving - std::string state_tag = string_format("%d", m_device.machine().sound().unique_id()); - auto &save = m_device.machine().save(); - save.save_item(&m_device, "stream.sound_stream", state_tag.c_str(), 0, NAME(m_sample_rate)); - save.save_item(&m_device, "stream.sound_stream", state_tag.c_str(), 0, NAME(m_last_update_end_time)); - save.register_postload(save_prepost_delegate(FUNC(sound_stream::postload), this)); - save.register_presave(save_prepost_delegate(FUNC(sound_stream::presave), this)); - // initialize all inputs - for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) - { - // allocate a resampler stream if needed, and get a pointer to its output - sound_stream_output *resampler = nullptr; - if (!m_resampling_disabled) - { - m_resampler_list.push_back(std::make_unique<default_resampler_stream>(m_device)); - resampler = &m_resampler_list.back()->m_output[0]; - } - // add the new input - m_input[inputnum].init(*this, inputnum, state_tag.c_str(), resampler); - } - // initialize all outputs - for (unsigned int outputnum = 0; outputnum < m_output.size(); outputnum++) - m_output[outputnum].init(*this, outputnum, state_tag.c_str()); - // create an update timer for synchronous streams - if (synchronous()) - m_sync_timer = m_device.timer_alloc(FUNC(sound_stream::sync_update), this); - // force an update to the sample rates - sample_rate_changed(); -} -//------------------------------------------------- -// sound_stream - constructor -//------------------------------------------------- -sound_stream::sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags) : - sound_stream(device, inputs, outputs, output_base, sample_rate, flags) +attotime sound_stream::sample_to_time(u64 index) const { - m_callback_ex = std::move(callback); + attotime res = attotime::zero; + res.m_seconds = index / m_sample_rate; + u64 remain = index % m_sample_rate; + res.m_attoseconds = ((remain * 1000000000) / m_sample_rate) * 1000000000; + return res; } -//------------------------------------------------- -// ~sound_stream - destructor -//------------------------------------------------- +//**// Synchronous stream updating -sound_stream::~sound_stream() +void sound_stream::reprime_sync_timer() { + if(!is_active()) + return; + + u64 next_sample = m_output_buffer.write_sample() + 1; + attotime next_time = sample_to_time(next_sample); + next_time.m_attoseconds += 1000000000; // Go to the next nanosecond + m_sync_timer->adjust(next_time - m_device.machine().time()); } - -//------------------------------------------------- -// set_sample_rate - set the sample rate on a -// given stream -//------------------------------------------------- - -void sound_stream::set_sample_rate(u32 new_rate) +void sound_stream::sync_update(s32) { - // we will update this on the next global update - if (new_rate != sample_rate()) - m_pending_sample_rate = new_rate; + update(); + reprime_sync_timer(); } -//------------------------------------------------- -// set_input - configure a stream's input -//------------------------------------------------- - -void sound_stream::set_input(int index, sound_stream *input_stream, int output_index, float gain) +//**// Sound manager and stream allocation +sound_manager::sound_manager(running_machine &machine) : + m_machine(machine), + m_update_timer(nullptr), + m_last_sync_time(attotime::zero), + m_effects_thread(nullptr), + m_effects_done(false), + m_master_gain(1.0), + m_muted(0), + m_nosound_mode(machine.osd().no_sound()), + m_unique_id(0), + m_wavfile() { - LOG("stream_set_input(%p, '%s', %d, %p, %d, %f)\n", (void *)this, m_device.tag(), - index, (void *)input_stream, output_index, gain); + // register callbacks + machine.configuration().config_register( + "mixer", + configuration_manager::load_delegate(&sound_manager::config_load, this), + configuration_manager::save_delegate(&sound_manager::config_save, this)); + machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(&sound_manager::pause, this)); + machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(&sound_manager::resume, this)); + machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&sound_manager::reset, this)); + machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&sound_manager::stop_recording, this)); - // make sure it's a valid input - if (index >= m_input.size()) - fatalerror("stream_set_input attempted to configure nonexistent input %d (%d max)\n", index, int(m_input.size())); + // register global states + // machine.save().save_item(NAME(m_last_update)); - // make sure it's a valid output - if (input_stream != nullptr && output_index >= input_stream->m_output.size()) - fatalerror("stream_set_input attempted to use a nonexistent output %d (%d max)\n", output_index, int(m_output.size())); + // start the periodic update flushing timer + m_update_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(sound_manager::update), this)); + m_update_timer->adjust(STREAMS_UPDATE_ATTOTIME, 0, STREAMS_UPDATE_ATTOTIME); - // wire it up - m_input[index].set_source((input_stream != nullptr) ? &input_stream->m_output[output_index] : nullptr); - m_input[index].set_gain(gain); + // mark the generation as "just starting" + m_osd_info.m_generation = 0xffffffff; +} - // update sample rates now that we know the input - sample_rate_changed(); +sound_manager::~sound_manager() +{ + if(m_effects_thread) { + m_effects_done = true; + m_effects_condition.notify_all(); + m_effects_thread->join(); + m_effects_thread = nullptr; + } } +sound_stream *sound_manager::stream_alloc(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags) +{ + m_stream_list.push_back(std::make_unique<sound_stream>(device, inputs, outputs, sample_rate, callback, flags)); + return m_stream_list.back().get(); +} -//------------------------------------------------- -// update - force a stream to update to -// the current emulated time -//------------------------------------------------- -void sound_stream::update() +//**// Sound system initialization + +void sound_manager::before_devices_init() { - // ignore any update requests if we're already up to date - attotime start = m_output[0].end_time(); - attotime end = m_device.machine().time(); - if (start >= end) - return; + // Inform the targets of the existence of the routes + for(device_sound_interface &sound : sound_interface_enumerator(machine().root_device())) + sound.sound_before_devices_init(); - // regular update then - update_view(start, end); + m_machine.save().register_postload(save_prepost_delegate(FUNC(sound_manager::postload), this)); } +void sound_manager::postload() +{ + std::unique_lock<std::mutex> lock(m_effects_mutex); + attotime now = machine().time(); + for(osd_output_stream &stream : m_osd_output_streams) { + stream.m_last_sync = rate_and_time_to_index(now, stream.m_rate); + stream.m_samples = 0; + } +} -//------------------------------------------------- -// update_view - force a stream to update to -// the current emulated time and return a view -// to the generated samples from the given -// output number -//------------------------------------------------- - -read_stream_view sound_stream::update_view(attotime start, attotime end, u32 outputnum) +void sound_manager::after_devices_init() { - sound_assert(start <= end); - sound_assert(outputnum < m_output.size()); + // Link all the streams together + for(device_sound_interface &sound : sound_interface_enumerator(machine().root_device())) + sound.sound_after_devices_init(); + + // Resolve the frequencies + int need_to_solve = 0; + for(auto &stream : m_stream_list) + if(!stream->frequency_is_solved()) + need_to_solve ++; + + while(need_to_solve) { + int prev_need_to_solve = need_to_solve; + for(auto &stream : m_stream_list) + if(!stream->frequency_is_solved() && stream->try_solving_frequency()) + need_to_solve --; + if(need_to_solve == prev_need_to_solve) + break; + } - // clean up parameters for when the asserts go away - if (outputnum >= m_output.size()) - outputnum = 0; - if (start > end) - start = end; + if(need_to_solve) { + u32 def = machine().sample_rate(); + for(auto &stream : m_stream_list) + if(!stream->frequency_is_solved()) + stream->internal_set_sample_rate(def); + } - auto profile = g_profiler.start(PROFILER_SOUND); + // Have all streams create their buffers and other initializations + for(auto &stream : m_stream_list) + stream->init(); + + // Detect loops and order streams for full update at the same time + // Check the number of sources for each stream + std::map<sound_stream *, int> depcounts; + for(auto &stream : m_stream_list) + depcounts[stream.get()] = stream->sources().size(); + + // Start from all the ones that don't depend on anything + std::vector<sound_stream *> ready_streams; + for(auto &dpc : depcounts) + if(dpc.second == 0) + ready_streams.push_back(dpc.first); + + // Handle all the ready streams in a lifo matter (better for cache when generating sound) + while(!ready_streams.empty()) { + sound_stream *stream = ready_streams.back(); + // add the stream to the update order + m_ordered_streams.push_back(stream); + ready_streams.resize(ready_streams.size() - 1); + // reduce the depcount for all the streams that depend on the updated stream + for(sound_stream *target : stream->targets()) + if(!--depcounts[target]) + // when the depcount is zero, a stream is ready to be updated + ready_streams.push_back(target); + } + + // If not all streams ended up in the sorted list, we have a loop + if(m_ordered_streams.size() != m_stream_list.size()) { + // Apply the same algorithm from the other side to the + // remaining streams to only keep the ones in the loop + + std::map<sound_stream *, int> inverted_depcounts; + for(auto &dpc : depcounts) + if(dpc.second) + inverted_depcounts[dpc.first] = dpc.first->targets().size(); + for(auto &dpc : inverted_depcounts) + if(dpc.second == 0) + ready_streams.push_back(dpc.first); + while(!ready_streams.empty()) { + sound_stream *stream = ready_streams.back(); + ready_streams.resize(ready_streams.size() - 1); + for(sound_stream *source : stream->sources()) + if(!--inverted_depcounts[source]) + ready_streams.push_back(source); + } + std::string stream_names; + for(auto &dpc : inverted_depcounts) + if(dpc.second) + stream_names += ' ' + dpc.first->name(); + fatalerror("Loop detected in stream routes:%s", stream_names); + } - // reposition our start to coincide with the current buffer end - attotime update_start = m_output[outputnum].end_time(); - if (update_start <= end) - { - // create views for all the outputs - for (unsigned int outindex = 0; outindex < m_output.size(); outindex++) - m_output_view[outindex] = m_output[outindex].view(update_start, end); - - // skip if nothing to do - u32 samples = m_output_view[0].samples(); - sound_assert(samples >= 0); - if (samples != 0 && m_sample_rate >= SAMPLE_RATE_MINIMUM) - { - sound_assert(!synchronous() || samples == 1); - - // ensure all input streams are up to date, and create views for them as well - for (unsigned int inputnum = 0; inputnum < m_input.size(); inputnum++) - { - if (m_input[inputnum].valid()) - m_input_view[inputnum] = m_input[inputnum].update(update_start, end); - else - m_input_view[inputnum] = empty_view(update_start, end); - sound_assert(m_input_view[inputnum].samples() > 0); - sound_assert(m_resampling_disabled || m_input_view[inputnum].sample_rate() == m_sample_rate); - } + if(VERBOSE & LOG_ORDER) { + LOG_OUTPUT_FUNC("Order:\n"); + for(sound_stream *s : m_ordered_streams) + LOG_OUTPUT_FUNC("- %s (%d)\n", s->name().c_str(), s->sample_rate()); + } + + // Registrations for state saving + for(auto &stream : m_stream_list) + stream->register_state(); + + // Compute all the per-stream orders for update() + for(auto &stream : m_stream_list) + stream->compute_dependants(); + + // Create the default effect chain + for(u32 effect = 0; effect != audio_effect::COUNT; effect++) + m_default_effects.emplace_back(audio_effect::create(effect, machine().sample_rate(), nullptr)); + + // Inventory speakers and microphones + m_outputs_count = 0; + for(speaker_device &dev : speaker_device_enumerator(machine().root_device())) { + dev.set_id(m_speakers.size()); + m_speakers.emplace_back(speaker_info(dev, machine().sample_rate(), m_outputs_count)); + for(u32 effect = 0; effect != audio_effect::COUNT; effect++) + m_speakers.back().m_effects[effect].m_effect.reset(audio_effect::create(effect, machine().sample_rate(), m_default_effects[effect].get())); + m_outputs_count += dev.inputs(); + } + + for(microphone_device &dev : microphone_device_enumerator(machine().root_device())) { + dev.set_id(m_microphones.size()); + m_microphones.emplace_back(microphone_info(dev)); + } + + // Allocate the buffer to pass for recording + m_record_buffer.resize(m_outputs_count * machine().sample_rate(), 0); + m_record_samples = 0; -#if (SOUND_DEBUG) - // clear each output view to NANs before we call the callback - for (unsigned int outindex = 0; outindex < m_output.size(); outindex++) - m_output_view[outindex].fill(NAN); -#endif + // Have all streams create their initial resamplers + for(auto &stream : m_stream_list) + stream->create_resamplers(); - // if we have an extended callback, that's all we need - m_callback_ex(*this, m_input_view, m_output_view); + // Then get the initial history sizes + for(auto &stream : m_stream_list) + stream->lookup_history_sizes(); -#if (SOUND_DEBUG) - // make sure everything was overwritten - for (unsigned int outindex = 0; outindex < m_output.size(); outindex++) - for (int sampindex = 0; sampindex < m_output_view[outindex].samples(); sampindex++) - m_output_view[outindex].get(sampindex); + m_effects_done = false; - for (unsigned int outindex = 0; outindex < m_output.size(); outindex++) - m_output[outindex].m_buffer.flush_wav(); -#endif + m_effects_thread = std::make_unique<std::thread>( + [this]{ run_effects(); }); +} + + +//**// Effects, input and output management + +void sound_manager::input_get(int id, sound_stream &stream) +{ + u32 samples = stream.samples(); + u64 end_pos = stream.sample_index(); + u32 skip = stream.output_count(); + + for(const auto &step : m_microphones[id].m_input_mixing_steps) { + auto get_source = [&istream = m_osd_input_streams[step.m_osd_index], this](u32 samples, u64 end_pos, u32 channel) -> const s16 * { + if(istream.m_buffer.write_sample() < end_pos) { + u32 needed = end_pos - istream.m_buffer.write_sample(); + istream.m_buffer.prepare_space(needed); + machine().osd().sound_stream_source_update(istream.m_id, istream.m_buffer.ptrw(0, 0), needed); + istream.m_buffer.commit(needed); + } + return istream.m_buffer.ptrs(channel, end_pos - samples - istream.m_buffer.sync_sample()); + }; + + switch(step.m_mode) { + case mixing_step::CLEAR: + case mixing_step::COPY: + fatalerror("Impossible step encountered in input\n"); + + case mixing_step::ADD: { + const s16 *src = get_source(samples, end_pos, step.m_osd_channel); + float gain = step.m_linear_volume / 32768.0; + for(u32 sample = 0; sample != samples; sample++) { + stream.add(step.m_device_channel, sample, *src * gain); + src += skip; + } + break; + } } } +} - // return the requested view - return read_stream_view(m_output_view[outputnum], start); +void sound_manager::output_push(int id, sound_stream &stream) +{ + auto &spk = m_speakers[id]; + auto &out = spk.m_buffer; + auto &inp = stream.m_input_buffer; + int samples = stream.samples(); + int channels = stream.input_count(); + out.prepare_space(samples); + for(int channel = 0; channel != channels; channel ++) + std::copy(inp[channel].begin(), inp[channel].begin() + samples, out.ptrw(channel, 0)); + out.commit(samples); + + m_record_samples = samples; + s16 *outb = m_record_buffer.data() + spk.m_first_output; + for(int channel = 0; channel != channels; channel ++) { + s16 *outb1 = outb; + const float *inb = inp[channel].data(); + for(int sample = 0; sample != samples; sample++) { + *outb1 = std::clamp(int(*inb++ * 32768), -32768, 32767); + outb1 += m_outputs_count; + } + } } +void sound_manager::run_effects() +{ + std::unique_lock<std::mutex> lock(m_effects_mutex); + for(;;) { + m_effects_condition.wait(lock); + if(m_effects_done) + return; + + // Apply the effects + for(auto &si : m_speakers) + for(u32 i=0; i != si.m_effects.size(); i++) { + auto &source = i ? si.m_effects[i-1].m_buffer : si.m_buffer; + si.m_effects[i].m_effect->apply(source, si.m_effects[i].m_buffer); + source.sync(); + } -//------------------------------------------------- -// apply_sample_rate_changes - if there is a -// pending sample rate change, apply it now -//------------------------------------------------- + // Apply the mixing steps + for(const auto &step : m_output_mixing_steps) { + const sample_t *src = step.m_mode == mixing_step::CLEAR ? nullptr : m_speakers[step.m_device_index].m_effects.back().m_buffer.ptrs(step.m_device_channel, 0); -void sound_stream::apply_sample_rate_changes(u32 updatenum, u32 downstream_rate) -{ - // grab the new rate and invalidate - u32 new_rate = (m_pending_sample_rate != SAMPLE_RATE_INVALID) ? m_pending_sample_rate : m_sample_rate; - m_pending_sample_rate = SAMPLE_RATE_INVALID; + auto &ostream = m_osd_output_streams[step.m_osd_index]; + u32 samples = ostream.m_samples; + s16 *dest = ostream.m_buffer.data() + step.m_osd_channel; + u32 skip = ostream.m_channels; - // clamp to the minimum - 1 (anything below minimum means "off" and - // will not call the sound callback at all) - if (new_rate < SAMPLE_RATE_MINIMUM) - new_rate = SAMPLE_RATE_MINIMUM - 1; + switch(step.m_mode) { + case mixing_step::CLEAR: + for(u32 sample = 0; sample != samples; sample++) { + *dest = 0; + dest += skip; + } + break; - // if we're input adaptive, override with the rate of our input - if (input_adaptive() && m_input.size() > 0 && m_input[0].valid()) - new_rate = m_input[0].source().stream().sample_rate(); + case mixing_step::COPY: { + float gain = 32768 * step.m_linear_volume * m_master_gain; + for(u32 sample = 0; sample != samples; sample++) { + *dest = std::clamp(int(*src++ * gain), -32768, 32767); + dest += skip; + } + break; + } - // if we're output adaptive, override with the rate of our output - if (output_adaptive()) - { - if (m_last_sample_rate_update == updatenum) - sound_assert(new_rate == m_sample_rate); - else - m_last_sample_rate_update = updatenum; - new_rate = downstream_rate; - } + case mixing_step::ADD: { + float gain = 32768 * step.m_linear_volume * m_master_gain; + for(u32 sample = 0; sample != samples; sample++) { + *dest = std::clamp(int(*src++ * gain) + *dest, -32768, 32767); + dest += skip; + } + break; + } + } + } - // if something is different, process the change - if (new_rate != SAMPLE_RATE_INVALID && new_rate != m_sample_rate) - { - // update to the new rate and notify everyone -#if (SOUND_DEBUG) - printf("stream %s changing rates %d -> %d\n", name().c_str(), m_sample_rate, new_rate); -#endif - m_sample_rate = new_rate; - sample_rate_changed(); + for(auto &si : m_speakers) + si.m_effects.back().m_buffer.sync(); + + // Send the result to the osd + for(auto &stream : m_osd_output_streams) + if(stream.m_samples) + machine().osd().sound_stream_sink_update(stream.m_id, stream.m_buffer.data(), stream.m_samples); } +} - // now call through our inputs and apply the rate change there - for (auto &input : m_input) - if (input.valid()) - input.apply_sample_rate_changes(updatenum, m_sample_rate); +std::string sound_manager::effect_chain_tag(s32 index) const +{ + return m_speakers[index].m_dev.tag(); } +std::vector<audio_effect *> sound_manager::effect_chain(s32 index) const +{ + std::vector<audio_effect *> res; + for(const auto &e : m_speakers[index].m_effects) + res.push_back(e.m_effect.get()); + return res; +} -//------------------------------------------------- -// print_graph_recursive - helper for debugging; -// prints info on this stream and then recursively -// prints info on all inputs -//------------------------------------------------- +std::vector<audio_effect *> sound_manager::default_effect_chain() const +{ + std::vector<audio_effect *> res; + for(const auto &e : m_default_effects) + res.push_back(e.get()); + return res; +} -#if (SOUND_DEBUG) -void sound_stream::print_graph_recursive(int indent, int index) -{ - osd_printf_info("%*s%s Ch.%d @ %d\n", indent, "", name(), index + m_output_base, sample_rate()); - for (int index = 0; index < m_input.size(); index++) - if (m_input[index].valid()) - { - if (m_input[index].m_resampler_source != nullptr) - m_input[index].m_resampler_source->stream().print_graph_recursive(indent + 2, m_input[index].m_resampler_source->index()); - else - m_input[index].m_native_source->stream().print_graph_recursive(indent + 2, m_input[index].m_native_source->index()); - } +void sound_manager::default_effect_changed(u32 entry) +{ + u32 type = m_default_effects[entry]->type(); + for(const auto &s : m_speakers) + for(const auto &e : s.m_effects) + if(e.m_effect->type() == type) + e.m_effect->default_changed(); } -#endif -//------------------------------------------------- -// sample_rate_changed - recompute sample -// rate data, and all streams that are affected -// by this stream -//------------------------------------------------- -void sound_stream::sample_rate_changed() -{ - // if invalid, just punt - if (m_sample_rate == SAMPLE_RATE_INVALID) - return; - // update all output buffers - for (auto &output : m_output) - output.sample_rate_changed(m_sample_rate); - // if synchronous, prime the timer - if (synchronous()) - reprime_sync_timer(); -} -//------------------------------------------------- -// postload - save/restore callback -//------------------------------------------------- -void sound_stream::postload() -{ - // set the end time of all of our streams to the value saved in m_last_update_end_time - for (auto &output : m_output) - output.set_end_time(m_last_update_end_time); - // recompute the sample rate information - sample_rate_changed(); -} //------------------------------------------------- -// presave - save/restore callback +// start_recording - begin audio recording //------------------------------------------------- -void sound_stream::presave() +bool sound_manager::start_recording(std::string_view filename) { - // save the stream end time - m_last_update_end_time = m_output[0].end_time(); + if(m_wavfile) + return false; + m_wavfile = util::wav_open(filename, machine().sample_rate(), m_outputs_count); + return bool(m_wavfile); +} + +bool sound_manager::start_recording() +{ + // open the output WAV file if specified + char const *const filename = machine().options().wav_write(); + return *filename ? start_recording(filename) : false; } //------------------------------------------------- -// reprime_sync_timer - set up the next sync -// timer to go off just a hair after the end of -// the current sample period +// stop_recording - end audio recording //------------------------------------------------- -void sound_stream::reprime_sync_timer() +void sound_manager::stop_recording() { - attotime curtime = m_device.machine().time(); - attotime target = m_output[0].end_time() + attotime(0, 1); - m_sync_timer->adjust(target - curtime); + // close any open WAV file + m_wavfile.reset(); } //------------------------------------------------- -// sync_update - timer callback to handle a -// synchronous stream +// mute - mute sound output //------------------------------------------------- -void sound_stream::sync_update(s32) +void sound_manager::mute(bool mute, u8 reason) { - update(); - reprime_sync_timer(); + if(mute) + m_muted |= reason; + else + m_muted &= ~reason; } //------------------------------------------------- -// empty_view - return an empty view covering the -// given time period as a substitute for invalid -// inputs +// reset - reset all sound chips //------------------------------------------------- -read_stream_view sound_stream::empty_view(attotime start, attotime end) +sound_manager::speaker_info::speaker_info(speaker_device &dev, u32 rate, u32 first_output) : m_dev(dev), m_first_output(first_output), m_buffer(rate, dev.inputs()) { - // if our dummy buffer doesn't match our sample rate, update and clear it - if (m_empty_buffer.sample_rate() != m_sample_rate) - m_empty_buffer.set_sample_rate(m_sample_rate, false); - - // allocate a write view so that it can expand, and convert back to a read view - // on the return - return write_stream_view(m_empty_buffer, start, end); + m_channels = dev.inputs(); + m_stream = dev.stream(); + for(u32 i=0; i != audio_effect::COUNT; i++) + m_effects.emplace_back(effect_step(rate, dev.inputs())); } +sound_manager::microphone_info::microphone_info(microphone_device &dev) : m_dev(dev) +{ + m_channels = dev.outputs(); +} +void sound_manager::reset() +{ + LOG_OUTPUT_FUNC("Sound reset\n"); +} -//************************************************************************** -// RESAMPLER STREAM -//************************************************************************** //------------------------------------------------- -// default_resampler_stream - derived sound_stream -// class that handles resampling +// pause - pause sound output //------------------------------------------------- -default_resampler_stream::default_resampler_stream(device_t &device) : - sound_stream(device, 1, 1, 0, SAMPLE_RATE_OUTPUT_ADAPTIVE, stream_update_delegate(&default_resampler_stream::resampler_sound_update, this), STREAM_DISABLE_INPUT_RESAMPLING), - m_max_latency(0) +void sound_manager::pause() { - // create a name - m_name = "Default Resampler '"; - m_name += device.tag(); - m_name += "'"; + mute(true, MUTE_REASON_PAUSE); } //------------------------------------------------- -// resampler_sound_update - stream callback -// handler for resampling an input stream to the -// target sample rate of the output +// resume - resume sound output //------------------------------------------------- -void default_resampler_stream::resampler_sound_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sound_manager::resume() { - sound_assert(inputs.size() == 1); - sound_assert(outputs.size() == 1); + mute(false, MUTE_REASON_PAUSE); +} - auto &input = inputs[0]; - auto &output = outputs[0]; - // if the input has an invalid rate, just fill with zeros - if (input.sample_rate() <= 1) - { - output.fill(0); +//**// Configuration management + +void sound_manager::config_load(config_type cfg_type, config_level cfg_level, util::xml::data_node const *parentnode) +{ + // If no config file, ignore + if(!parentnode) return; - } - // optimize_resampler ensures we should not have equal sample rates - sound_assert(input.sample_rate() != output.sample_rate()); + switch(cfg_type) { + case config_type::INIT: + break; - // compute the stepping value and the inverse - stream_buffer::sample_t step = stream_buffer::sample_t(input.sample_rate()) / stream_buffer::sample_t(output.sample_rate()); - stream_buffer::sample_t stepinv = 1.0 / step; + case config_type::CONTROLLER: + break; - // determine the latency we need to introduce, in input samples: - // 1 input sample for undersampled inputs - // 1 + step input samples for oversampled inputs - s64 latency_samples = 1 + ((step < 1.0) ? 0 : s32(step)); - if (latency_samples <= m_max_latency) - latency_samples = m_max_latency; - else - m_max_latency = latency_samples; - attotime latency = latency_samples * input.sample_period(); - - // clamp the latency to the start (only relevant at the beginning) - s32 dstindex = 0; - attotime output_start = output.start_time(); - auto numsamples = output.samples(); - while (latency > output_start && dstindex < numsamples) - { - output.put(dstindex++, 0); - output_start += output.sample_period(); + case config_type::DEFAULT: { + // In the global config, get the default effect chain configuration + + util::xml::data_node const *efl_node = parentnode->get_child("default_audio_effects"); + for(util::xml::data_node const *ef_node = efl_node->get_child("effect"); ef_node != nullptr; ef_node = ef_node->get_next_sibling("effect")) { + unsigned int id = ef_node->get_attribute_int("step", 0); + std::string type = ef_node->get_attribute_string("type", ""); + if(id >= 1 && id <= m_default_effects.size() && audio_effect::effect_names[m_default_effects[id-1]->type()] == type) + m_default_effects[id-1]->config_load(ef_node); + } + break; } - if (dstindex >= numsamples) - return; - // create a rebased input buffer around the adjusted start time - read_stream_view rebased(input, output_start - latency); - sound_assert(rebased.start_time() + latency <= output_start); + case config_type::SYSTEM: { + // In the per-driver file, get the specific configuration for everything + + // Effects configuration + for(util::xml::data_node const *efl_node = parentnode->get_child("audio_effects"); efl_node != nullptr; efl_node = efl_node->get_next_sibling("audio_effects")) { + std::string speaker_tag = efl_node->get_attribute_string("tag", ""); + for(auto &speaker : m_speakers) + if(speaker.m_dev.tag() == speaker_tag) { + auto &eff = speaker.m_effects; + for(util::xml::data_node const *ef_node = efl_node->get_child("effect"); ef_node != nullptr; ef_node = ef_node->get_next_sibling("effect")) { + unsigned int id = ef_node->get_attribute_int("step", 0); + std::string type = ef_node->get_attribute_string("type", ""); + if(id >= 1 && id <= m_default_effects.size() && audio_effect::effect_names[eff[id-1].m_effect->type()] == type) + eff[id-1].m_effect->config_load(ef_node); + } + break; + } + } - // compute the fractional input start position - attotime delta = output_start - (rebased.start_time() + latency); - sound_assert(delta.seconds() == 0); - stream_buffer::sample_t srcpos = stream_buffer::sample_t(double(delta.attoseconds()) / double(rebased.sample_period_attoseconds())); - sound_assert(srcpos <= 1.0f); + // All levels + const util::xml::data_node *lv_node = parentnode->get_child("master_volume"); + if(lv_node) + m_master_gain = lv_node->get_attribute_float("gain", 1.0); - // input is undersampled: point sample except where our sample period covers a boundary - s32 srcindex = 0; - if (step < 1.0) - { - stream_buffer::sample_t cursample = rebased.get(srcindex++); - for ( ; dstindex < numsamples; dstindex++) - { - // if still within the current sample, just replicate - srcpos += step; - if (srcpos <= 1.0) - output.put(dstindex, cursample); - - // if crossing a sample boundary, blend with the neighbor - else - { - srcpos -= 1.0; - sound_assert(srcpos <= step + 1e-5); - stream_buffer::sample_t prevsample = cursample; - cursample = rebased.get(srcindex++); - output.put(dstindex, stepinv * (prevsample * (step - srcpos) + srcpos * cursample)); - } + for(lv_node = parentnode->get_child("device_volume"); lv_node != nullptr; lv_node = lv_node->get_next_sibling("device_volume")) { + std::string device_tag = lv_node->get_attribute_string("device", ""); + device_sound_interface *intf = dynamic_cast<device_sound_interface *>(m_machine.root_device().subdevice(device_tag)); + if(intf) + intf->set_user_output_gain(lv_node->get_attribute_float("gain", 1.0)); } - sound_assert(srcindex <= rebased.samples()); - } - // input is oversampled: sum the energy - else - { - float cursample = rebased.get(srcindex++); - for ( ; dstindex < numsamples; dstindex++) - { - // compute the partial first sample and advance - stream_buffer::sample_t scale = 1.0 - srcpos; - stream_buffer::sample_t sample = cursample * scale; - - // add in complete samples until we only have a fraction left - stream_buffer::sample_t remaining = step - scale; - while (remaining >= 1.0) - { - sample += rebased.get(srcindex++); - remaining -= 1.0; - } + for(lv_node = parentnode->get_child("device_channel_volume"); lv_node != nullptr; lv_node = lv_node->get_next_sibling("device_channel_volume")) { + std::string device_tag = lv_node->get_attribute_string("device", ""); + int channel = lv_node->get_attribute_int("channel", -1); + device_sound_interface *intf = dynamic_cast<device_sound_interface *>(m_machine.root_device().subdevice(device_tag)); + if(intf && channel >= 0 && channel < intf->outputs()) + intf->set_user_output_gain(channel, lv_node->get_attribute_float("gain", 1.0)); + } - // add in the final partial sample - cursample = rebased.get(srcindex++); - sample += cursample * remaining; - output.put(dstindex, sample * stepinv); - // our position is now the remainder - srcpos = remaining; - sound_assert(srcindex <= rebased.samples()); + // Mapping configuration + m_configs.clear(); + for(util::xml::data_node const *node = parentnode->get_child("sound_map"); node != nullptr; node = node->get_next_sibling("sound_map")) { + m_configs.emplace_back(config_mapping { node->get_attribute_string("tag", "") }); + auto &config = m_configs.back(); + for(util::xml::data_node const *nmap = node->get_child("node_mapping"); nmap != nullptr; nmap = nmap->get_next_sibling("node_mapping")) + config.m_node_mappings.emplace_back(std::pair<std::string, float>(nmap->get_attribute_string("node", ""), nmap->get_attribute_float("db", 0))); + for(util::xml::data_node const *cmap = node->get_child("channel_mapping"); cmap != nullptr; cmap = cmap->get_next_sibling("channel_mapping")) + config.m_channel_mappings.emplace_back(std::tuple<u32, std::string, u32, float>(cmap->get_attribute_int("guest_channel", 0), + cmap->get_attribute_string("node", ""), + cmap->get_attribute_int("node_channel", 0), + cmap->get_attribute_float("db", 0))); } + break; } -} - + case config_type::FINAL: + break; + } +} -//************************************************************************** -// SOUND MANAGER -//************************************************************************** //------------------------------------------------- -// sound_manager - constructor +// config_save - save data to the configuration +// file //------------------------------------------------- -sound_manager::sound_manager(running_machine &machine) : - m_machine(machine), - m_update_timer(nullptr), - m_update_number(0), - m_last_update(attotime::zero), - m_finalmix_leftover(0), - m_samples_this_update(0), - m_finalmix(machine.sample_rate()), - m_leftmix(machine.sample_rate()), - m_rightmix(machine.sample_rate()), - m_compressor_scale(1.0), - m_compressor_counter(0), - m_compressor_enabled(machine.options().compressor()), - m_muted(0), - m_nosound_mode(machine.osd().no_sound()), - m_attenuation(0), - m_unique_id(0), - m_wavfile(), - m_first_reset(true) +void sound_manager::config_save(config_type cfg_type, util::xml::data_node *parentnode) { - // count the mixers -#if VERBOSE - mixer_interface_enumerator iter(machine.root_device()); - LOG("total mixers = %d\n", iter.count()); -#endif + switch(cfg_type) { + case config_type::INIT: + break; + + case config_type::CONTROLLER: + break; + + case config_type::DEFAULT: { + // In the global config, save the default effect chain configuration + util::xml::data_node *const efl_node = parentnode->add_child("default_audio_effects", nullptr); + for(u32 ei = 0; ei != m_default_effects.size(); ei++) { + const audio_effect *e = m_default_effects[ei].get(); + util::xml::data_node *const ef_node = efl_node->add_child("effect", nullptr); + ef_node->set_attribute_int("step", ei+1); + ef_node->set_attribute("type", audio_effect::effect_names[e->type()]); + e->config_save(ef_node); + } + break; + } - // register callbacks - machine.configuration().config_register( - "mixer", - configuration_manager::load_delegate(&sound_manager::config_load, this), - configuration_manager::save_delegate(&sound_manager::config_save, this)); - machine.add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(&sound_manager::pause, this)); - machine.add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(&sound_manager::resume, this)); - machine.add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(&sound_manager::reset, this)); - machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&sound_manager::stop_recording, this)); + case config_type::SYSTEM: { + // In the per-driver file, save the specific configuration for everything + + // Effects configuration + for(const auto &speaker : m_speakers) { + util::xml::data_node *const efl_node = parentnode->add_child("audio_effects", nullptr); + efl_node->set_attribute("tag", speaker.m_dev.tag()); + for(u32 ei = 0; ei != speaker.m_effects.size(); ei++) { + const audio_effect *e = speaker.m_effects[ei].m_effect.get(); + util::xml::data_node *const ef_node = efl_node->add_child("effect", nullptr); + ef_node->set_attribute_int("step", ei+1); + ef_node->set_attribute("type", audio_effect::effect_names[e->type()]); + e->config_save(ef_node); + } + } - // register global states - machine.save().save_item(NAME(m_last_update)); + // All levels + if(m_master_gain != 1.0) { + util::xml::data_node *const lv_node = parentnode->add_child("master_volume", nullptr); + lv_node->set_attribute_float("gain", m_master_gain); + } + for(device_sound_interface &snd : sound_interface_enumerator(m_machine.root_device())) { + // Don't add microphones, speakers or devices without outputs + if(dynamic_cast<sound_io_device *>(&snd) || !snd.outputs()) + continue; + if(snd.user_output_gain() != 1.0) { + util::xml::data_node *const lv_node = parentnode->add_child("device_volume", nullptr); + lv_node->set_attribute("device", snd.device().tag()); + lv_node->set_attribute_float("gain", snd.user_output_gain()); + } + for(int channel = 0; channel != snd.outputs(); channel ++) + if(snd.user_output_gain(channel) != 1.0) { + util::xml::data_node *const lv_node = parentnode->add_child("device_channel_volume", nullptr); + lv_node->set_attribute("device", snd.device().tag()); + lv_node->set_attribute_int("channel", channel); + lv_node->set_attribute_float("gain", snd.user_output_gain(channel)); + } + } - // set the starting attenuation - set_attenuation(machine.options().volume()); + // Mapping configuration + auto output_one = [this, parentnode](sound_io_device &dev) { + for(const auto &config : m_configs) + if(config.m_name == dev.tag()) { + util::xml::data_node *const sp_node = parentnode->add_child("sound_map", nullptr); + sp_node->set_attribute("tag", dev.tag()); + for(const auto &nmap : config.m_node_mappings) { + util::xml::data_node *const node = sp_node->add_child("node_mapping", nullptr); + node->set_attribute("node", nmap.first.c_str()); + node->set_attribute_float("db", nmap.second); + } + for(const auto &cmap : config.m_channel_mappings) { + util::xml::data_node *const node = sp_node->add_child("channel_mapping", nullptr); + node->set_attribute_int("guest_channel", std::get<0>(cmap)); + node->set_attribute("node", std::get<1>(cmap).c_str()); + node->set_attribute_int("node_channel", std::get<2>(cmap)); + node->set_attribute_float("db", std::get<3>(cmap)); + } + return; + } + }; + + for(auto &spk : m_speakers) + output_one(spk.m_dev); + for(auto &mic : m_microphones) + output_one(mic.m_dev); + break; + } - // start the periodic update flushing timer - m_update_timer = machine.scheduler().timer_alloc(timer_expired_delegate(FUNC(sound_manager::update), this)); - m_update_timer->adjust(STREAMS_UPDATE_ATTOTIME, 0, STREAMS_UPDATE_ATTOTIME); + case config_type::FINAL: + break; + } } -//------------------------------------------------- -// sound_manager - destructor -//------------------------------------------------- -sound_manager::~sound_manager() +//**// Mapping between speakers/microphones and OSD endpoints + +sound_manager::config_mapping &sound_manager::config_get_sound_io(sound_io_device *dev) { + for(auto &config : m_configs) + if(config.m_name == dev->tag()) + return config; + m_configs.emplace_back(config_mapping { dev->tag() }); + return m_configs.back(); } +void sound_manager::config_add_sound_io_connection_node(sound_io_device *dev, std::string name, float db) +{ + internal_config_add_sound_io_connection_node(dev, name, db); + m_osd_info.m_generation --; +} -//------------------------------------------------- -// stream_alloc - allocate a new stream with the -// new-style callback and flags -//------------------------------------------------- +void sound_manager::internal_config_add_sound_io_connection_node(sound_io_device *dev, std::string name, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &nmap : config.m_node_mappings) + if(nmap.first == name) + return; + config.m_node_mappings.emplace_back(std::pair<std::string, float>(name, db)); +} -sound_stream *sound_manager::stream_alloc(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags) +void sound_manager::config_add_sound_io_connection_default(sound_io_device *dev, float db) { - // determine output base - u32 output_base = 0; - for (auto &stream : m_stream_list) - if (&stream->device() == &device) - output_base += stream->output_count(); + internal_config_add_sound_io_connection_default(dev, db); + m_osd_info.m_generation --; +} - m_stream_list.push_back(std::make_unique<sound_stream>(device, inputs, outputs, output_base, sample_rate, callback, flags)); - return m_stream_list.back().get(); +void sound_manager::internal_config_add_sound_io_connection_default(sound_io_device *dev, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &nmap : config.m_node_mappings) + if(nmap.first == "") + return; + config.m_node_mappings.emplace_back(std::pair<std::string, float>("", db)); } +void sound_manager::config_remove_sound_io_connection_node(sound_io_device *dev, std::string name) +{ + internal_config_remove_sound_io_connection_node(dev, name); + m_osd_info.m_generation --; +} -//------------------------------------------------- -// start_recording - begin audio recording -//------------------------------------------------- +void sound_manager::internal_config_remove_sound_io_connection_node(sound_io_device *dev, std::string name) +{ + auto &config = config_get_sound_io(dev); + for(auto i = config.m_node_mappings.begin(); i != config.m_node_mappings.end(); i++) + if(i->first == name) { + config.m_node_mappings.erase(i); + return; + } +} -bool sound_manager::start_recording(std::string_view filename) +void sound_manager::config_remove_sound_io_connection_default(sound_io_device *dev) { - if (m_wavfile) - return false; - m_wavfile = util::wav_open(filename, machine().sample_rate(), 2); - return bool(m_wavfile); + internal_config_remove_sound_io_connection_default(dev); + m_osd_info.m_generation --; } -bool sound_manager::start_recording() +void sound_manager::internal_config_remove_sound_io_connection_default(sound_io_device *dev) { - // open the output WAV file if specified - char const *const filename = machine().options().wav_write(); - return *filename ? start_recording(filename) : false; + auto &config = config_get_sound_io(dev); + for(auto i = config.m_node_mappings.begin(); i != config.m_node_mappings.end(); i++) + if(i->first == "") { + config.m_node_mappings.erase(i); + return; + } } +void sound_manager::config_set_volume_sound_io_connection_node(sound_io_device *dev, std::string name, float db) +{ + internal_config_set_volume_sound_io_connection_node(dev, name, db); + m_osd_info.m_generation --; +} -//------------------------------------------------- -// stop_recording - end audio recording -//------------------------------------------------- +void sound_manager::internal_config_set_volume_sound_io_connection_node(sound_io_device *dev, std::string name, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &nmap : config.m_node_mappings) + if(nmap.first == name) { + nmap.second = db; + return; + } +} -void sound_manager::stop_recording() +void sound_manager::config_set_volume_sound_io_connection_default(sound_io_device *dev, float db) { - // close any open WAV file - m_wavfile.reset(); + internal_config_set_volume_sound_io_connection_default(dev, db); + m_osd_info.m_generation --; } +void sound_manager::internal_config_set_volume_sound_io_connection_default(sound_io_device *dev, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &nmap : config.m_node_mappings) + if(nmap.first == "") { + nmap.second = db; + return; + } +} -//------------------------------------------------- -// set_attenuation - set the global volume -//------------------------------------------------- -void sound_manager::set_attenuation(float attenuation) +void sound_manager::config_add_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db) { - // currently OSD only supports integral attenuation - m_attenuation = int(attenuation); - machine().osd().set_mastervolume(m_muted ? -32 : m_attenuation); + internal_config_add_sound_io_channel_connection_node(dev, guest_channel, name, node_channel, db); + m_osd_info.m_generation --; } +void sound_manager::internal_config_add_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &cmap : config.m_channel_mappings) + if(std::get<0>(cmap) == guest_channel && std::get<1>(cmap) == name && std::get<2>(cmap) == node_channel) + return; + config.m_channel_mappings.emplace_back(std::tuple<u32, std::string, u32, float>(guest_channel, name, node_channel, db)); +} -//------------------------------------------------- -// indexed_mixer_input - return the mixer -// device and input index of the global mixer -// input -//------------------------------------------------- +void sound_manager::config_add_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db) +{ + internal_config_add_sound_io_channel_connection_default(dev, guest_channel, node_channel, db); + m_osd_info.m_generation --; +} -bool sound_manager::indexed_mixer_input(int index, mixer_input &info) const +void sound_manager::internal_config_add_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db) { - // scan through the mixers until we find the indexed input - for (device_mixer_interface &mixer : mixer_interface_enumerator(machine().root_device())) - { - if (index < mixer.inputs()) - { - info.mixer = &mixer; - info.stream = mixer.input_to_stream_input(index, info.inputnum); - sound_assert(info.stream != nullptr); - return true; - } - index -= mixer.inputs(); - } + auto &config = config_get_sound_io(dev); + for(auto &cmap : config.m_channel_mappings) + if(std::get<0>(cmap) == guest_channel && std::get<1>(cmap) == "" && std::get<2>(cmap) == node_channel) + return; + config.m_channel_mappings.emplace_back(std::tuple<u32, std::string, u32, float>(guest_channel, "", node_channel, db)); +} - // didn't locate - info.mixer = nullptr; - return false; +void sound_manager::config_remove_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel) +{ + internal_config_remove_sound_io_channel_connection_node(dev, guest_channel, name, node_channel); + m_osd_info.m_generation --; } +void sound_manager::internal_config_remove_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel) +{ + auto &config = config_get_sound_io(dev); + for(auto i = config.m_channel_mappings.begin(); i != config.m_channel_mappings.end(); i++) + if(std::get<0>(*i) == guest_channel && std::get<1>(*i) == name && std::get<2>(*i) == node_channel) { + config.m_channel_mappings.erase(i); + return; + } +} -//------------------------------------------------- -// samples - fills the specified buffer with -// 16-bit stereo audio samples generated during -// the current frame -//------------------------------------------------- +void sound_manager::config_remove_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel) +{ + internal_config_remove_sound_io_channel_connection_default(dev, guest_channel, node_channel); + m_osd_info.m_generation --; +} -void sound_manager::samples(s16 *buffer) +void sound_manager::internal_config_remove_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel) { - for (int sample = 0; sample < m_samples_this_update * 2; sample++) - *buffer++ = m_finalmix[sample]; + auto &config = config_get_sound_io(dev); + for(auto i = config.m_channel_mappings.begin(); i != config.m_channel_mappings.end(); i++) + if(std::get<0>(*i) == guest_channel && std::get<1>(*i) == "" && std::get<2>(*i) == node_channel) { + config.m_channel_mappings.erase(i); + return; + } } +void sound_manager::config_set_volume_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db) +{ + internal_config_set_volume_sound_io_channel_connection_node(dev, guest_channel, name, node_channel, db); + m_osd_info.m_generation --; +} -//------------------------------------------------- -// mute - mute sound output -//------------------------------------------------- +void sound_manager::internal_config_set_volume_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &cmap : config.m_channel_mappings) + if(std::get<0>(cmap) == guest_channel && std::get<1>(cmap) == name && std::get<2>(cmap) == node_channel) { + std::get<3>(cmap) = db; + return; + } +} -void sound_manager::mute(bool mute, u8 reason) +void sound_manager::config_set_volume_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db) { - bool old_muted = m_muted; - if (mute) - m_muted |= reason; - else - m_muted &= ~reason; + internal_config_set_volume_sound_io_channel_connection_default(dev, guest_channel, node_channel, db); + m_osd_info.m_generation --; +} - if(old_muted != (m_muted != 0)) - set_attenuation(m_attenuation); +void sound_manager::internal_config_set_volume_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db) +{ + auto &config = config_get_sound_io(dev); + for(auto &cmap : config.m_channel_mappings) + if(std::get<0>(cmap) == guest_channel && std::get<1>(cmap) == "" && std::get<2>(cmap) == node_channel) { + std::get<3>(cmap) = db; + return; + } } +void sound_manager::startup_cleanups() +{ + auto osd_info = machine().osd().sound_get_information(); + + // for every sound_io device that does not have a configuration entry, add a + // mapping to default + auto default_one = [this](sound_io_device &dev) { + for(const auto &config : m_configs) + if(config.m_name == dev.tag()) + return; + m_configs.emplace_back(config_mapping { dev.tag() }); + m_configs.back().m_node_mappings.emplace_back(std::pair<std::string, float>("", 0.0)); + }; + + for(sound_io_device &dev : speaker_device_enumerator(machine().root_device())) + default_one(dev); + for(sound_io_device &dev : microphone_device_enumerator(machine().root_device())) + default_one(dev); + + // If there's no default sink replace all the default sink config + // entries into the first sink available + if(!osd_info.m_default_sink) { + std::string first_sink_name; + for(const auto &node : osd_info.m_nodes) + if(node.m_sinks) { + first_sink_name = node.name(); + break; + } -//------------------------------------------------- -// recursive_remove_stream_from_orphan_list - -// remove the given stream from the orphan list -// and recursively remove all our inputs -//------------------------------------------------- + if(first_sink_name != "") + for(auto &config : m_configs) { + for(auto &nmap : config.m_node_mappings) + if(nmap.first == "") + nmap.first = first_sink_name; + for(auto &cmap : config.m_channel_mappings) + if(std::get<1>(cmap) == "") + std::get<1>(cmap) = first_sink_name; + } + } -void sound_manager::recursive_remove_stream_from_orphan_list(sound_stream *which) -{ - m_orphan_stream_list.erase(which); - for (int inputnum = 0; inputnum < which->input_count(); inputnum++) - { - auto &input = which->input(inputnum); - if (input.valid()) - recursive_remove_stream_from_orphan_list(&input.source().stream()); - } -} + // If there's no default source replace all the default source config + // entries into the first source available + if(!osd_info.m_default_source) { + std::string first_source_name; + for(const auto &node : osd_info.m_nodes) + if(node.m_sources) { + first_source_name = node.name(); + break; + } -//------------------------------------------------- -// apply_sample_rate_changes - recursively -// update sample rates throughout the system -//------------------------------------------------- + if(first_source_name != "") + for(auto &config : m_configs) { + for(auto &nmap : config.m_node_mappings) + if(nmap.first == "") + nmap.first = first_source_name; + for(auto &cmap : config.m_channel_mappings) + if(std::get<1>(cmap) == "") + std::get<1>(cmap) = first_source_name; + } + } +} -void sound_manager::apply_sample_rate_changes() +template<bool is_output, typename S> void sound_manager::apply_osd_changes(std::vector<S> &streams) { - // update sample rates if they have changed - for (speaker_device &speaker : speaker_device_enumerator(machine().root_device())) - { - int stream_out; - sound_stream *stream = speaker.output_to_stream_output(0, stream_out); - - // due to device removal, some speakers may end up with no outputs; just skip those - if (stream != nullptr) - { - sound_assert(speaker.outputs() == 1); - stream->apply_sample_rate_changes(m_update_number, machine().sample_rate()); + // Apply host system volume and routing changes to the internal structures + for(S &stream : streams) { + u32 sidx; + for(sidx = 0; sidx != m_osd_info.m_streams.size() && m_osd_info.m_streams[sidx].m_id != stream.m_id; sidx++); + // If the stream has been lost, continue. It will be cleared in update_osd_streams. + if(sidx == m_osd_info.m_streams.size()) + continue; + + // Check if the target and/or the volumes changed + bool node_changed = stream.m_node != m_osd_info.m_streams[sidx].m_node; + bool volume_changed = !std::equal(stream.m_volumes.begin(), stream.m_volumes.end(), m_osd_info.m_streams[sidx].m_volumes.begin(), m_osd_info.m_streams[sidx].m_volumes.end()); + + if(node_changed || volume_changed) { + // Check if a node change is just tracking the system default + bool system_default_tracking = node_changed && stream.m_is_system_default && m_osd_info.m_streams[sidx].m_node == (is_output ? m_osd_info.m_default_sink : m_osd_info.m_default_source); + + // Find the config entry for the sound_io + config_mapping *config = nullptr; + for(auto &conf : m_configs) + if(conf.m_name == stream.m_dev->tag()) { + config = &conf; + break; + } + if(!config) + continue; + + // Retrieve the old node name, and, if it's different, the new node name + std::string old_node_name = stream.m_node_name; + std::string new_node_name; + if(node_changed) { + for(const auto &node : m_osd_info.m_nodes) + if(node.m_id == m_osd_info.m_streams[sidx].m_node) { + new_node_name = node.name(); + break; + } + // That's really, really not supposed to happen + if(new_node_name.empty()) + continue; + } else + new_node_name = old_node_name; + + // Separate the cases on full mapping vs. channel mapping + if(!stream.m_is_channel_mapping) { + // Full mapping + // Find the index of the config mapping entry that generated the stream, if there's still one. + // Note that a default system stream has the empty string as a name + u32 index; + for(index = 0; index != config->m_node_mappings.size(); index++) + if(config->m_node_mappings[index].first == old_node_name) + break; + if(index == config->m_node_mappings.size()) + continue; + + // If the target node changed, write it down + if(node_changed) { + if(!system_default_tracking) { + config->m_node_mappings[index].first = new_node_name; + stream.m_node_name = new_node_name; + stream.m_is_system_default = false; + } + stream.m_node = m_osd_info.m_streams[sidx].m_node; + } + + // If the volume changed, there are two + // possibilities: either the channels split, or + // they didn't. + if(volume_changed) { + // Check is all the channel volumes are the same + float new_volume = m_osd_info.m_streams[sidx].m_volumes[0]; + bool same = true; + for(u32 i = 1; i != m_osd_info.m_streams[sidx].m_volumes.size(); i++) + if(m_osd_info.m_streams[sidx].m_volumes[i] != new_volume) { + same = false; + break; + } + if(same) { + // All the same volume, just note down the new volume + stream.m_volumes = m_osd_info.m_streams[sidx].m_volumes; + config->m_node_mappings[index].second = new_volume; + + } else { + const osd::audio_info::node_info *node = nullptr; + for(const auto &n : m_osd_info.m_nodes) + if(n.m_id == stream.m_node) { + node = &n; + break; + } + for(u32 channel = 0; channel != stream.m_channels; channel++) { + std::vector<u32> targets = find_channel_mapping(stream.m_dev->get_position(channel), node); + for(u32 tchannel : targets) + if(stream.m_node_name == "") + internal_config_add_sound_io_channel_connection_default(stream.m_dev, channel, tchannel, m_osd_info.m_streams[sidx].m_volumes[tchannel]); + else + internal_config_add_sound_io_channel_connection_node(stream.m_dev, channel, stream.m_node_name, tchannel, m_osd_info.m_streams[sidx].m_volumes[tchannel]); + } + config->m_node_mappings.erase(config->m_node_mappings.begin() + index); + } + } + } else { + // Channel mapping + for(u32 channel = 0; channel != stream.m_channels; channel++) { + if(stream.m_unused_channels_mask & (1 << channel)) + continue; + + // Find the index of the config mapping entry that generated the stream channel, if there's still one. + // Note that a default system stream has the empty string as a name + u32 index; + for(index = 0; index != config->m_channel_mappings.size(); index++) + if(std::get<1>(config->m_channel_mappings[index]) == old_node_name && + std::get<2>(config->m_channel_mappings[index]) == channel) + break; + if(index == config->m_channel_mappings.size()) + continue; + + // If the target node changed, write it down + if(node_changed) { + if(!system_default_tracking) { + std::get<1>(config->m_channel_mappings[index]) = new_node_name; + stream.m_node_name = new_node_name; + stream.m_is_system_default = false; + } + stream.m_node = m_osd_info.m_streams[sidx].m_node; + } + + // If the volume changed, write in down too + if(volume_changed) { + std::get<3>(config->m_channel_mappings[index]) = m_osd_info.m_streams[sidx].m_volumes[channel]; + stream.m_volumes[channel] = m_osd_info.m_streams[sidx].m_volumes[channel]; + } + } + } } } } - -//------------------------------------------------- -// reset - reset all sound chips -//------------------------------------------------- - -void sound_manager::reset() +void sound_manager::osd_information_update() { - // reset all the sound chips - for (device_sound_interface &sound : sound_interface_enumerator(machine().root_device())) - sound.device().reset(); + // Get a snapshot of the current information + m_osd_info = machine().osd().sound_get_information(); + + // Analyze the streams to see if anything changed, but only in the + // split stream case. + if(machine().osd().sound_split_streams_per_source()) { + apply_osd_changes<false, osd_input_stream >(m_osd_input_streams ); + apply_osd_changes<false, osd_output_stream>(m_osd_output_streams); + } - // apply any sample rate changes now - apply_sample_rate_changes(); +} - // on first reset, identify any orphaned streams - if (m_first_reset) - { - m_first_reset = false; +void sound_manager::generate_mapping() +{ + auto find_node = [this](std::string name) -> u32 { + for(const auto &node : m_osd_info.m_nodes) + if(node.name() == name) + return node.m_id; + return 0; + }; + + m_mappings.clear(); + for(speaker_info &speaker : m_speakers) { + auto &config = config_get_sound_io(&speaker.m_dev); + m_mappings.emplace_back(mapping { &speaker.m_dev }); + auto &omap = m_mappings.back(); + + std::vector<std::string> node_to_remove; + for(auto &nmap : config.m_node_mappings) { + if(nmap.first == "") { + if(m_osd_info.m_default_sink) + omap.m_node_mappings.emplace_back(mapping::node_mapping { m_osd_info.m_default_sink, nmap.second, true }); + } else { + u32 node_id = find_node(nmap.first); + if(node_id != 0) + omap.m_node_mappings.emplace_back(mapping::node_mapping { node_id, nmap.second, false }); + else + node_to_remove.push_back(nmap.first); + } + } - // put all the streams on the orphan list to start - for (auto &stream : m_stream_list) - m_orphan_stream_list[stream.get()] = 0; + for(auto &nmap: node_to_remove) + internal_config_remove_sound_io_connection_node(&speaker.m_dev, nmap); + + std::vector<std::tuple<u32, std::string, u32>> channel_map_to_remove; + for(auto &cmap : config.m_channel_mappings) { + if(std::get<1>(cmap) == "") { + if(m_osd_info.m_default_sink) + omap.m_channel_mappings.emplace_back(mapping::channel_mapping { std::get<0>(cmap), m_osd_info.m_default_sink, std::get<2>(cmap), std::get<3>(cmap), true }); + } else { + u32 node_id = find_node(std::get<1>(cmap)); + if(node_id != 0) + omap.m_channel_mappings.emplace_back(mapping::channel_mapping { std::get<0>(cmap), node_id, std::get<2>(cmap), std::get<3>(cmap), false }); + else + channel_map_to_remove.push_back(std::tuple<u32, std::string, u32>(std::get<0>(cmap), std::get<1>(cmap), std::get<2>(cmap))); + } + } - // then walk the graph like we do on update and remove any we touch - for (speaker_device &speaker : speaker_device_enumerator(machine().root_device())) - { - int dummy; - sound_stream *const output = speaker.output_to_stream_output(0, dummy); - if (output) - recursive_remove_stream_from_orphan_list(output); + for(auto &cmap : channel_map_to_remove) + internal_config_remove_sound_io_channel_connection_node(&speaker.m_dev, std::get<0>(cmap), std::get<1>(cmap), std::get<2>(cmap)); + } - m_speakers.emplace_back(speaker); + for(microphone_info &mic : m_microphones) { + auto &config = config_get_sound_io(&mic.m_dev); + m_mappings.emplace_back(mapping { &mic.m_dev }); + auto &omap = m_mappings.back(); + + std::vector<std::string> node_to_remove; + for(auto &nmap : config.m_node_mappings) { + if(nmap.first == "") { + if(m_osd_info.m_default_source) + omap.m_node_mappings.emplace_back(mapping::node_mapping { m_osd_info.m_default_source, nmap.second, true }); + } else { + u32 node_id = find_node(nmap.first); + if(node_id != 0) + omap.m_node_mappings.emplace_back(mapping::node_mapping { node_id, nmap.second, false }); + else + node_to_remove.push_back(nmap.first); + } } -#if (SOUND_DEBUG) - // dump the sound graph when we start up - for (speaker_device &speaker : speaker_device_enumerator(machine().root_device())) - { - int index; - sound_stream *output = speaker.output_to_stream_output(0, index); - if (output != nullptr) - output->print_graph_recursive(0, index); + for(auto &nmap: node_to_remove) + internal_config_remove_sound_io_connection_node(&mic.m_dev, nmap); + + std::vector<std::tuple<u32, std::string, u32>> channel_map_to_remove; + for(auto &cmap : config.m_channel_mappings) { + if(std::get<1>(cmap) == "") { + if(m_osd_info.m_default_source) + omap.m_channel_mappings.emplace_back(mapping::channel_mapping { std::get<0>(cmap), m_osd_info.m_default_source, std::get<2>(cmap), std::get<3>(cmap), true }); + } else { + u32 node_id = find_node(std::get<1>(cmap)); + if(node_id != 0) + omap.m_channel_mappings.emplace_back(mapping::channel_mapping { std::get<0>(cmap), node_id, std::get<2>(cmap), std::get<3>(cmap), false }); + else + channel_map_to_remove.push_back(std::tuple<u32, std::string, u32>(std::get<0>(cmap), std::get<1>(cmap), std::get<2>(cmap))); + } } - // dump the orphan list as well - if (m_orphan_stream_list.size() != 0) - { - osd_printf_info("\nOrphaned streams:\n"); - for (auto &stream : m_orphan_stream_list) - osd_printf_info(" %s\n", stream.first->name()); - } -#endif + for(auto &cmap : channel_map_to_remove) + internal_config_remove_sound_io_channel_connection_node(&mic.m_dev, std::get<0>(cmap), std::get<1>(cmap), std::get<2>(cmap)); } } +// Find where to map a sound_io channel into a node's channels depending on their positions -//------------------------------------------------- -// pause - pause sound output -//------------------------------------------------- - -void sound_manager::pause() +std::vector<u32> sound_manager::find_channel_mapping(const std::array<double, 3> &position, const osd::audio_info::node_info *node) { - mute(true, MUTE_REASON_PAUSE); + std::vector<u32> result; + if(position[0] == 0 && position[1] == 0 && position[2] == 0) + return result; + double best_dist = -1; + for(u32 port = 0; port != node->m_port_positions.size(); port++) + if(node->m_port_positions[port][0] || node->m_port_positions[port][1] || node->m_port_positions[port][2]) { + double dx = position[0] - node->m_port_positions[port][0]; + double dy = position[1] - node->m_port_positions[port][1]; + double dz = position[2] - node->m_port_positions[port][2]; + double dist = dx*dx + dy*dy + dz*dz; + if(best_dist == -1 || dist < best_dist) { + best_dist = dist; + result.clear(); + result.push_back(port); + } else if(best_dist == dist) + result.push_back(port); + } + return result; } -//------------------------------------------------- -// resume - resume sound output -//------------------------------------------------- - -void sound_manager::resume() +void sound_manager::update_osd_streams() { - mute(false, MUTE_REASON_PAUSE); -} + std::unique_lock<std::mutex> lock(m_effects_mutex); + auto current_input_streams = std::move(m_osd_input_streams); + auto current_output_streams = std::move(m_osd_output_streams); + m_osd_input_streams.clear(); + m_osd_output_streams.clear(); + + // Find the index of a sound_io_device in the speaker_info vector or the microphone_info vector + + auto find_sound_io_index = [this](sound_io_device *dev) -> u32 { + for(u32 si = 0; si != m_speakers.size(); si++) + if(&m_speakers[si].m_dev == dev) + return si; + for(u32 si = 0; si != m_microphones.size(); si++) + if(&m_microphones[si].m_dev == dev) + return si; + return 0; // Can't happen + }; + + + // Find a pointer to a node_info from the node id + auto find_node_info = [this](u32 node) -> const osd::audio_info::node_info * { + for(const auto &ni : m_osd_info.m_nodes) { + if(ni.m_id == node) + return ∋ + } + // Can't happen + return nullptr; + }; + + // Two possible mapping methods depending on the osd capabilities + + for(auto &m : m_microphones) + m.m_input_mixing_steps.clear(); + m_output_mixing_steps.clear(); + + auto &osd = machine().osd(); + if(osd.sound_split_streams_per_source()) { + auto get_input_stream_for_node_and_device = [this, ¤t_input_streams] (const osd::audio_info::node_info *node, sound_io_device *dev, bool is_system_default, bool is_channel_mapping = false) -> u32 { + // Check if the osd stream already exists to pick it up in case. + // Clear the id in the current_streams structure to show it has been picked up, reset the unused mask. + // Clear the volumes + // m_dev will already be correct + + for(auto &os : current_input_streams) + if(os.m_id && os.m_node == node->m_id && os.m_dev == dev) { + u32 sid = m_osd_input_streams.size(); + m_osd_input_streams.emplace_back(std::move(os)); + os.m_id = 0; + auto &nos = m_osd_input_streams[sid]; + nos.m_is_channel_mapping = is_channel_mapping; + nos.m_unused_channels_mask = util::make_bitmask<u32>(node->m_sources); + nos.m_volumes.clear(); + nos.m_is_system_default = is_system_default; + return sid; + } + // If none exists, create one + u32 sid = m_osd_input_streams.size(); + u32 rate = machine().sample_rate(); + m_osd_input_streams.emplace_back(osd_input_stream(node->m_id, is_system_default ? "" : node->m_name, node->m_sources, rate, is_system_default, dev)); + osd_input_stream &nos = m_osd_input_streams.back(); + nos.m_id = machine().osd().sound_stream_source_open(node->m_id, dev->tag(), rate); + nos.m_is_channel_mapping = is_channel_mapping; + nos.m_buffer.set_sync_sample(rate_and_last_sync_to_index(rate)); + return sid; + }; + + auto get_output_stream_for_node_and_device = [this, ¤t_output_streams] (const osd::audio_info::node_info *node, sound_io_device *dev, bool is_system_default, bool is_channel_mapping = false) -> u32 { + // Check if the osd stream already exists to pick it up in case. + // Clear the id in the current_streams structure to show it has been picked up, reset the unused mask. + // Clear the volumes + // m_dev will already be correct + + for(auto &os : current_output_streams) + if(os.m_id && os.m_node == node->m_id && os.m_dev == dev) { + u32 sid = m_osd_output_streams.size(); + m_osd_output_streams.emplace_back(std::move(os)); + os.m_id = 0; + auto &nos = m_osd_output_streams[sid]; + nos.m_is_channel_mapping = is_channel_mapping; + nos.m_volumes.clear(); + nos.m_unused_channels_mask = util::make_bitmask<u32>(node->m_sinks); + nos.m_is_system_default = is_system_default; + return sid; + } -//------------------------------------------------- -// config_load - read and apply data from the -// configuration file -//------------------------------------------------- + // If none exists, create one + u32 sid = m_osd_output_streams.size(); + u32 rate = machine().sample_rate(); + m_osd_output_streams.emplace_back(osd_output_stream(node->m_id, is_system_default ? "" : node->m_name, node->m_sinks, rate, is_system_default, dev)); + osd_output_stream &nos = m_osd_output_streams.back(); + nos.m_id = machine().osd().sound_stream_sink_open(node->m_id, dev->tag(), rate); + nos.m_is_channel_mapping = is_channel_mapping; + nos.m_last_sync = rate_and_last_sync_to_index(rate); + return sid; + }; + + auto get_input_stream_for_node_and_channel = [this, &get_input_stream_for_node_and_device] (const osd::audio_info::node_info *node, u32 node_channel, sound_io_device *dev, bool is_system_default) -> u32 { + // First check if there's an active stream + for(u32 sid = 0; sid != m_osd_input_streams.size(); sid++) { + auto &os = m_osd_input_streams[sid]; + if(os.m_node == node->m_id && os.m_dev == dev && os.m_unused_channels_mask & (1 << node_channel) && os.m_is_channel_mapping) + return sid; + } -void sound_manager::config_load(config_type cfg_type, config_level cfg_level, util::xml::data_node const *parentnode) -{ - // we only care system-specific configuration - if ((cfg_type != config_type::SYSTEM) || !parentnode) - return; + // Otherwise use the default method + return get_input_stream_for_node_and_device(node, dev, is_system_default, true); + }; - // master volume attenuation - if (util::xml::data_node const *node = parentnode->get_child("attenuation")) - { - // treat source INI files or more specific as higher priority than CFG - // FIXME: leaky abstraction - this depends on a front-end implementation detail - if ((OPTION_PRIORITY_NORMAL + 5) > machine().options().get_entry(OPTION_VOLUME)->priority()) - set_attenuation(std::clamp(int(node->get_attribute_int("value", 0)), -32, 0)); - } - // iterate over channel nodes - for (util::xml::data_node const *node = parentnode->get_child("channel"); node != nullptr; node = node->get_next_sibling("channel")) - { - mixer_input info; - if (indexed_mixer_input(node->get_attribute_int("index", -1), info)) - { - // note that this doesn't disallow out-of-range values - float value = node->get_attribute_float("value", std::nanf("")); - - if (!std::isnan(value)) - info.stream->input(info.inputnum).set_user_gain(value); - } - } + auto get_output_stream_for_node_and_channel = [this, &get_output_stream_for_node_and_device] (const osd::audio_info::node_info *node, u32 node_channel, sound_io_device *dev, bool is_system_default) -> u32 { + // First check if there's an active stream with the correct channel not used yet + for(u32 sid = 0; sid != m_osd_output_streams.size(); sid++) { + auto &os = m_osd_output_streams[sid]; + if(os.m_node == node->m_id && os.m_dev == dev && os.m_unused_channels_mask & (1 << node_channel) && os.m_is_channel_mapping) + return sid; + } - // iterate over speaker panning nodes - for (util::xml::data_node const *node = parentnode->get_child("panning"); node != nullptr; node = node->get_next_sibling("panning")) - { - char const *const tag = node->get_attribute_string("tag", nullptr); - if (tag != nullptr) - { - for (speaker_device &speaker : speaker_device_enumerator(machine().root_device())) - { - if (!strcmp(tag, speaker.tag())) - { - float value = node->get_attribute_float("value", speaker.defpan()); - speaker.set_pan(value); - break; + // Otherwise use the default method + return get_output_stream_for_node_and_device(node, dev, is_system_default, true); + }; + + // Create/retrieve streams to apply the decided mapping + for(const auto &omap : m_mappings) { + u32 dev_index = find_sound_io_index(omap.m_dev); + bool is_output = omap.m_dev->is_output(); + if(is_output) { + std::vector<mixing_step> &mixing_steps = m_output_mixing_steps; + u32 dchannels = omap.m_dev->inputs(); + for(const auto &nm : omap.m_node_mappings) { + const auto *node = find_node_info(nm.m_node); + u32 osd_index = get_output_stream_for_node_and_device(node, omap.m_dev, nm.m_is_system_default); + auto &stream = m_osd_output_streams[osd_index]; + u32 umask = stream.m_unused_channels_mask; + float linear_volume = 1.0; + + if(osd.sound_external_per_channel_volume()) { + stream.m_volumes.clear(); + stream.m_volumes.resize(stream.m_channels, nm.m_db); + + } else + linear_volume = osd::db_to_linear(nm.m_db); + + for(u32 channel = 0; channel != dchannels; channel++) { + std::vector<u32> targets = find_channel_mapping(omap.m_dev->get_position(channel), node); + for(u32 tchannel : targets) { + // If the channel is output and in the to + // clear mask, use load, otherwise use add. + // Apply the volume too if needed + mixing_steps.emplace_back(mixing_step { + (umask & (1 << tchannel)) ? mixing_step::COPY : mixing_step::ADD, + osd_index, + tchannel, + dev_index, + channel, + linear_volume + }); + umask &= ~(1 << tchannel); + } + } + stream.m_unused_channels_mask = umask; + } + + for(const auto &cm : omap.m_channel_mappings) { + const auto *node = find_node_info(cm.m_node); + u32 osd_index = get_output_stream_for_node_and_channel(node, cm.m_node_channel, omap.m_dev, cm.m_is_system_default); + auto &stream = m_osd_output_streams[osd_index]; + float linear_volume = 1.0; + + if(osd.sound_external_per_channel_volume()) { + if(stream.m_volumes.empty()) + stream.m_volumes.resize(stream.m_channels, -96); + stream.m_volumes[cm.m_node_channel] = cm.m_db; + + } else + linear_volume = osd::db_to_linear(cm.m_db); + + mixing_steps.emplace_back(mixing_step { + (stream.m_unused_channels_mask & (1 << cm.m_node_channel)) ? + mixing_step::COPY : mixing_step::ADD, + osd_index, + cm.m_node_channel, + dev_index, + cm.m_guest_channel, + linear_volume + }); + stream.m_unused_channels_mask &= ~(1 << cm.m_node_channel); + } + + + } else { + std::vector<mixing_step> &mixing_steps = m_microphones[dev_index].m_input_mixing_steps; + u32 dchannels = omap.m_dev->outputs(); + for(const auto &nm : omap.m_node_mappings) { + const auto *node = find_node_info(nm.m_node); + u32 osd_index = get_input_stream_for_node_and_device(node, omap.m_dev, nm.m_is_system_default); + auto &stream = m_osd_input_streams[osd_index]; + u32 umask = stream.m_unused_channels_mask; + float linear_volume = 1.0; + + if(osd.sound_external_per_channel_volume()) { + stream.m_volumes.clear(); + stream.m_volumes.resize(stream.m_channels, nm.m_db); + + } else + linear_volume = osd::db_to_linear(nm.m_db); + + for(u32 channel = 0; channel != dchannels; channel++) { + std::vector<u32> targets = find_channel_mapping(omap.m_dev->get_position(channel), node); + for(u32 tchannel : targets) { + // If the channel is output and in the to + // clear mask, use load, otherwise use add. + // Apply the volume too if needed + mixing_steps.emplace_back(mixing_step { + mixing_step::ADD, + osd_index, + tchannel, + dev_index, + channel, + linear_volume + }); + umask &= ~(1 << tchannel); + } + } + stream.m_unused_channels_mask = umask; + } + + for(const auto &cm : omap.m_channel_mappings) { + const auto *node = find_node_info(cm.m_node); + u32 osd_index = get_input_stream_for_node_and_channel(node, cm.m_node_channel, omap.m_dev, cm.m_is_system_default); + auto &stream = m_osd_input_streams[osd_index]; + float linear_volume = 1.0; + + if(osd.sound_external_per_channel_volume()) { + if(stream.m_volumes.empty()) + stream.m_volumes.resize(stream.m_channels, -96); + stream.m_volumes[cm.m_node_channel] = cm.m_db; + + } else + linear_volume = osd::db_to_linear(cm.m_db); + + mixing_steps.emplace_back(mixing_step { + mixing_step::ADD, + osd_index, + cm.m_node_channel, + dev_index, + cm.m_guest_channel, + linear_volume + }); + stream.m_unused_channels_mask &= ~(1 << cm.m_node_channel); } } } - } -} + } else { + // All sources need to be merged per-destination, max one stream per destination + + std::map<u32, u32> stream_per_node; + + // Retrieve or create the one osd stream for a given + // destination. First check if we already have it, then + // whether it was previously created, then otherwise create + // it. + + auto get_input_stream_for_node = [this, ¤t_input_streams, &stream_per_node] (const osd::audio_info::node_info *node, bool is_system_default) -> u32 { + // Pick up the existing stream if there's one + auto si = stream_per_node.find(node->m_id); + if(si != stream_per_node.end()) + return si->second; + + // Create the default unused mask + u32 channels = node->m_sources; + u32 umask = util::make_bitmask<u32>(channels); + + // Check if the osd stream already exists to pick it up in case. + // Clear the id in the current_streams structure to show it has been picked up, reset the unused mask. + // m_speaker will already be nullptr, m_source_channels and m_volumes empty. + + for(auto &os : current_input_streams) + if(os.m_id && os.m_node == node->m_id) { + u32 sid = m_osd_input_streams.size(); + m_osd_input_streams.emplace_back(std::move(os)); + os.m_id = 0; + m_osd_input_streams.back().m_unused_channels_mask = umask; + m_osd_input_streams.back().m_is_system_default = is_system_default; + stream_per_node[node->m_id] = sid; + return sid; + } -//------------------------------------------------- -// config_save - save data to the configuration -// file -//------------------------------------------------- + // If none exists, create one + u32 sid = m_osd_input_streams.size(); + u32 rate = machine().sample_rate(); + m_osd_input_streams.emplace_back(osd_input_stream(node->m_id, is_system_default ? "" : node->m_name, channels, rate, is_system_default, nullptr)); + osd_input_stream &stream = m_osd_input_streams.back(); + stream.m_id = machine().osd().sound_stream_source_open(node->m_id, machine().system().name, rate); + stream.m_buffer.set_sync_sample(rate_and_last_sync_to_index(rate)); + stream_per_node[node->m_id] = sid; + return sid; + }; + + auto get_output_stream_for_node = [this, ¤t_output_streams, &stream_per_node] (const osd::audio_info::node_info *node, bool is_system_default) -> u32 { + // Pick up the existing stream if there's one + auto si = stream_per_node.find(node->m_id); + if(si != stream_per_node.end()) + return si->second; + + // Create the default unused mask + u32 channels = node->m_sinks; + u32 umask = util::make_bitmask<u32>(channels); + + // Check if the osd stream already exists to pick it up in case. + // Clear the id in the current_streams structure to show it has been picked up, reset the unused mask. + // m_speaker will already be nullptr, m_source_channels and m_volumes empty. + + for(auto &os : current_output_streams) + if(os.m_id && os.m_node == node->m_id) { + u32 sid = m_osd_output_streams.size(); + m_osd_output_streams.emplace_back(std::move(os)); + os.m_id = 0; + m_osd_output_streams.back().m_unused_channels_mask = umask; + m_osd_output_streams.back().m_is_system_default = is_system_default; + stream_per_node[node->m_id] = sid; + return sid; + } -void sound_manager::config_save(config_type cfg_type, util::xml::data_node *parentnode) -{ - // we only save system-specific configuration - if (cfg_type != config_type::SYSTEM) - return; + // If none exists, create one + u32 sid = m_osd_output_streams.size(); + u32 rate = machine().sample_rate(); + m_osd_output_streams.emplace_back(osd_output_stream(node->m_id, is_system_default ? "" : node->m_name, channels, rate, is_system_default, nullptr)); + osd_output_stream &stream = m_osd_output_streams.back(); + stream.m_id = machine().osd().sound_stream_sink_open(node->m_id, machine().system().name, rate); + stream.m_last_sync = rate_and_last_sync_to_index(rate); + stream_per_node[node->m_id] = sid; + return sid; + }; + + + // Create/retrieve streams to apply the decided mapping + + for(const auto &omap : m_mappings) { + u32 dev_index = find_sound_io_index(omap.m_dev); + bool is_output = omap.m_dev->is_output(); + if(is_output) { + u32 channels = m_speakers[dev_index].m_channels; + std::vector<mixing_step> &mixing_steps = m_output_mixing_steps; + for(const auto &nm : omap.m_node_mappings) { + const auto *node = find_node_info(nm.m_node); + u32 stream_index = get_output_stream_for_node(node, nm.m_is_system_default); + u32 umask = m_osd_output_streams[stream_index].m_unused_channels_mask; + float linear_volume = osd::db_to_linear(nm.m_db); + + for(u32 channel = 0; channel != channels; channel++) { + std::vector<u32> targets = find_channel_mapping(omap.m_dev->get_position(channel), node); + for(u32 tchannel : targets) { + // If the channel is in the to clear mask, use load, otherwise use add + // Apply the volume too + mixing_steps.emplace_back(mixing_step { + (umask & (1 << tchannel)) ? mixing_step::COPY : mixing_step::ADD, + dev_index, + channel, + stream_index, + tchannel, + linear_volume + }); + umask &= ~(1 << tchannel); + } + } + m_osd_output_streams[stream_index].m_unused_channels_mask = umask; + } - // master volume attenuation - if (m_attenuation != machine().options().volume()) - { - if (util::xml::data_node *const node = parentnode->add_child("attenuation", nullptr)) - node->set_attribute_int("value", m_attenuation); - } + for(const auto &cm : omap.m_channel_mappings) { + const auto *node = find_node_info(cm.m_node); + u32 stream_index = get_output_stream_for_node(node, false); + u32 umask = m_osd_output_streams[stream_index].m_unused_channels_mask; + + // If the channel is in the to clear mask, use load, otherwise use add + // Apply the volume too + mixing_steps.emplace_back(mixing_step { + (umask & (1 << cm.m_node_channel)) ? mixing_step::COPY : mixing_step::ADD, + dev_index, + cm.m_guest_channel, + stream_index, + cm.m_node_channel, + osd::db_to_linear(cm.m_db) + }); + m_osd_output_streams[stream_index].m_unused_channels_mask = umask & ~(1 << cm.m_node_channel); + } - // iterate over mixer channels for per-channel volume - for (int mixernum = 0; ; mixernum++) - { - mixer_input info; - if (!indexed_mixer_input(mixernum, info)) - break; + } else { + u32 channels = m_microphones[dev_index].m_channels; + std::vector<mixing_step> &mixing_steps = m_microphones[dev_index].m_input_mixing_steps; + for(const auto &nm : omap.m_node_mappings) { + const auto *node = find_node_info(nm.m_node); + u32 stream_index = get_input_stream_for_node(node, nm.m_is_system_default); + float linear_volume = osd::db_to_linear(nm.m_db); + + for(u32 channel = 0; channel != channels; channel++) { + std::vector<u32> targets = find_channel_mapping(omap.m_dev->get_position(channel), node); + for(u32 tchannel : targets) { + // If the channel is in the to clear mask, use load, otherwise use add + // Apply the volume too + mixing_steps.emplace_back(mixing_step { + mixing_step::ADD, + dev_index, + channel, + stream_index, + tchannel, + linear_volume + }); + m_osd_input_streams[stream_index].m_unused_channels_mask &= ~(1 << tchannel); + } + } + } - float const value = info.stream->input(info.inputnum).user_gain(); - if (value != 1.0f) - { - util::xml::data_node *const node = parentnode->add_child("channel", nullptr); - if (node) - { - node->set_attribute_int("index", mixernum); - node->set_attribute_float("value", value); + for(const auto &cm : omap.m_channel_mappings) { + const auto *node = find_node_info(cm.m_node); + u32 stream_index = get_input_stream_for_node(node, false); + + // If the channel is in the to clear mask, use load, otherwise use add + // Apply the volume too + mixing_steps.emplace_back(mixing_step { + mixing_step::ADD, + dev_index, + cm.m_guest_channel, + stream_index, + cm.m_node_channel, + osd::db_to_linear(cm.m_db) + }); + m_osd_input_streams[stream_index].m_unused_channels_mask &= ~(1 << cm.m_node_channel); + } } } } - // iterate over speakers for panning - for (speaker_device &speaker : speaker_device_enumerator(machine().root_device())) - { - float const value = speaker.pan(); - if (value != speaker.defpan()) - { - util::xml::data_node *const node = parentnode->add_child("panning", nullptr); - if (node) - { - node->set_attribute("tag", speaker.tag()); - node->set_attribute_float("value", value); - } + // Add a clear step for all output streams that need it + // Also set the volumes if supported + for(u32 stream_index = 0; stream_index != m_osd_output_streams.size(); stream_index++) { + auto &stream = m_osd_output_streams[stream_index]; + if(stream.m_unused_channels_mask) { + for(u32 channel = 0; channel != stream.m_channels; channel ++) + if(stream.m_unused_channels_mask & (1 << channel)) + m_output_mixing_steps.emplace_back(mixing_step { mixing_step::CLEAR, 0, 0, stream_index, channel, 0.0 }); } + if(!stream.m_volumes.empty()) + osd.sound_stream_set_volumes(stream.m_id, stream.m_volumes); } -} + // If supported, set the volumes for the input streams + for(u32 stream_index = 0; stream_index != m_osd_input_streams.size(); stream_index++) { + auto &stream = m_osd_input_streams[stream_index]; + if(!stream.m_volumes.empty()) + osd.sound_stream_set_volumes(stream.m_id, stream.m_volumes); + } -//------------------------------------------------- -// adjust_toward_compressor_scale - adjust the -// current scale factor toward the current goal, -// in small increments -//------------------------------------------------- + // Close all previous streams that haven't been picked up + for(const auto &stream : current_input_streams) + if(stream.m_id) + machine().osd().sound_stream_close(stream.m_id); + for(const auto &stream : current_output_streams) + if(stream.m_id) + machine().osd().sound_stream_close(stream.m_id); +} -stream_buffer::sample_t sound_manager::adjust_toward_compressor_scale(stream_buffer::sample_t curscale, stream_buffer::sample_t prevsample, stream_buffer::sample_t rawsample) +void sound_manager::mapping_update() { - stream_buffer::sample_t proposed_scale = curscale; + auto &osd = machine().osd(); + while(m_osd_info.m_generation != osd.sound_get_generation()) { + osd_information_update(); + + if(VERBOSE & LOG_OSD_INFO) { + LOG_OUTPUT_FUNC("OSD information:\n"); + LOG_OUTPUT_FUNC("- generation %u\n", m_osd_info.m_generation); + LOG_OUTPUT_FUNC("- default sink %u\n", m_osd_info.m_default_sink); + LOG_OUTPUT_FUNC("- default source %u\n", m_osd_info.m_default_source); + LOG_OUTPUT_FUNC("- nodes:\n"); + for(const auto &node : m_osd_info.m_nodes) { + LOG_OUTPUT_FUNC(" * %3u %s [%d %d-%d]\n", node.m_id, node.name().c_str(), node.m_rate.m_default_rate, node.m_rate.m_min_rate, node.m_rate.m_max_rate); + uint32_t port_count = node.m_sinks; + if(port_count < node.m_sources) + port_count = node.m_sources; + for(uint32_t port = 0; port != port_count; port++) + LOG_OUTPUT_FUNC(" %s %s [%g %g %g]\n", + port < node.m_sinks ? port < node.m_sources ? "<>" : ">" : "<", + node.m_port_names[port].c_str(), + node.m_port_positions[port][0], + node.m_port_positions[port][1], + node.m_port_positions[port][2]); + } + LOG_OUTPUT_FUNC("- streams:\n"); + for(const auto &stream : m_osd_info.m_streams) { + LOG_OUTPUT_FUNC(" * %3u node %u", stream.m_id, stream.m_node); + if(!stream.m_volumes.empty()) { + LOG_OUTPUT_FUNC(" volumes"); + for(float v : stream.m_volumes) + LOG_OUTPUT_FUNC(" %g", v); + } + LOG_OUTPUT_FUNC("\n"); + } + } - // if we want to get larger, increment by 0.01 - if (curscale < m_compressor_scale) - { - proposed_scale += 0.01f; - if (proposed_scale > m_compressor_scale) - proposed_scale = m_compressor_scale; - } + generate_mapping(); - // otherwise, decrement by 0.01 - else - { - proposed_scale -= 0.01f; - if (proposed_scale < m_compressor_scale) - proposed_scale = m_compressor_scale; + if(VERBOSE & LOG_MAPPING) { + LOG_OUTPUT_FUNC("MAPPING:\n"); + for(const auto &omap : m_mappings) { + LOG_OUTPUT_FUNC("- sound_io %s\n", omap.m_dev->tag()); + for(const auto &nm : omap.m_node_mappings) + LOG_OUTPUT_FUNC(" * node %u volume %g%s\n", nm.m_node, nm.m_db, nm.m_is_system_default ? " (default)" : ""); + for(const auto &cm : omap.m_channel_mappings) + LOG_OUTPUT_FUNC(" * channel %u <-> node %u:%i volume %g\n", cm.m_guest_channel, cm.m_node, cm.m_node_channel, cm.m_db); + } + } + + update_osd_streams(); + + if(VERBOSE & LOG_OSD_STREAMS) { + LOG_OUTPUT_FUNC("OSD input streams:\n"); + for(const auto &os : m_osd_input_streams) { + if(machine().osd().sound_split_streams_per_source()) { + LOG_OUTPUT_FUNC("- %3u %s node %u", os.m_id, os.m_dev ? os.m_dev->tag() : "-", os.m_node); + if(!os.m_is_channel_mapping) + LOG_OUTPUT_FUNC(" channels"); + if(machine().osd().sound_external_per_channel_volume()) { + LOG_OUTPUT_FUNC(" dB"); + for(u32 i = 0; i != os.m_channels; i++) + LOG_OUTPUT_FUNC(" %g", os.m_volumes[i]); + } + LOG_OUTPUT_FUNC("\n"); + } else + LOG_OUTPUT_FUNC("- %3u node %u\n", os.m_id, os.m_node); + } + LOG_OUTPUT_FUNC("Input mixing steps:\n"); + for(const auto &m : m_microphones) { + LOG_OUTPUT_FUNC(" %s:\n", m.m_dev.tag()); + for(const auto &ms : m.m_input_mixing_steps) { + static const char *const modes[5] = { "clear", "copy", "copy+vol", "add", "add+vol" }; + LOG_OUTPUT_FUNC(" - %s osd %u:%u -> device %u:%u level %g\n", modes[ms.m_mode], ms.m_osd_index, ms.m_osd_channel, ms.m_device_index, ms.m_device_channel, ms.m_linear_volume); + } + } + LOG_OUTPUT_FUNC("OSD output streams:\n"); + for(const auto &os : m_osd_output_streams) { + if(machine().osd().sound_split_streams_per_source()) { + LOG_OUTPUT_FUNC("- %3u %s node %u", os.m_id, os.m_dev ? os.m_dev->tag() : "-", os.m_node); + if(!os.m_is_channel_mapping) + LOG_OUTPUT_FUNC(" channels"); + if(machine().osd().sound_external_per_channel_volume()) { + LOG_OUTPUT_FUNC(" dB"); + for(u32 i = 0; i != os.m_channels; i++) + LOG_OUTPUT_FUNC(" %g", os.m_volumes[i]); + } + LOG_OUTPUT_FUNC("\n"); + } else + LOG_OUTPUT_FUNC("- %3u node %u\n", os.m_id, os.m_node); + } + LOG_OUTPUT_FUNC("Output mixing steps:\n"); + for(const auto &ms : m_output_mixing_steps) { + static const char *const modes[5] = { "clear", "copy", "copy+vol", "add", "add+vol" }; + LOG_OUTPUT_FUNC("- %s device %u:%u -> osd %u:%u level %g\n", modes[ms.m_mode], ms.m_device_index, ms.m_device_channel, ms.m_osd_index, ms.m_osd_channel, ms.m_linear_volume); + } + } } +} - // compute the sample at the current scale and at the proposed scale - stream_buffer::sample_t cursample = rawsample * curscale; - stream_buffer::sample_t proposed_sample = rawsample * proposed_scale; - // if they trend in the same direction, it's ok to take the step - if ((cursample < prevsample && proposed_sample < prevsample) || (cursample > prevsample && proposed_sample > prevsample)) - curscale = proposed_scale; - // return the current scale - return curscale; -} +//**// Global sound system update -//------------------------------------------------- -// update - mix everything down to its final form -// and send it to the OSD layer -//------------------------------------------------- - -void sound_manager::update(s32 param) +u64 sound_manager::rate_and_time_to_index(attotime time, u32 sample_rate) const { - LOG("sound_update\n"); + return time.m_seconds * sample_rate + ((time.m_attoseconds / 100000000) * sample_rate) / 10000000000; +} +void sound_manager::update(s32) +{ auto profile = g_profiler.start(PROFILER_SOUND); - // determine the duration of this update - attotime update_period = machine().time() - m_last_update; - sound_assert(update_period.seconds() == 0); + if(m_osd_info.m_generation == 0xffffffff) + startup_cleanups(); - // use that to compute the number of samples we need from the speakers - attoseconds_t sample_rate_attos = HZ_TO_ATTOSECONDS(machine().sample_rate()); - m_samples_this_update = update_period.attoseconds() / sample_rate_attos; + mapping_update(); + streams_update(); - // recompute the end time to an even sample boundary - attotime endtime = m_last_update + attotime(0, m_samples_this_update * sample_rate_attos); - - // clear out the mix bufers - std::fill_n(&m_leftmix[0], m_samples_this_update, 0); - std::fill_n(&m_rightmix[0], m_samples_this_update, 0); - - // force all the speaker streams to generate the proper number of samples - for (speaker_device &speaker : m_speakers) - speaker.mix(&m_leftmix[0], &m_rightmix[0], m_last_update, endtime, m_samples_this_update, (m_muted & MUTE_REASON_SYSTEM)); - - // determine the maximum in this section - stream_buffer::sample_t curmax = 0; - for (int sampindex = 0; sampindex < m_samples_this_update; sampindex++) - { - auto sample = m_leftmix[sampindex]; - if (sample < 0) - sample = -sample; - if (sample > curmax) - curmax = sample; - - sample = m_rightmix[sampindex]; - if (sample < 0) - sample = -sample; - if (sample > curmax) - curmax = sample; - } - - // pull in current compressor scale factor before modifying - stream_buffer::sample_t lscale = m_compressor_scale; - stream_buffer::sample_t rscale = m_compressor_scale; + // notify that new samples have been generated + m_last_sync_time = machine().time(); + emulator_info::sound_hook(); +} - // if we're above what the compressor will handle, adjust the compression - if (curmax * m_compressor_scale > 1.0) +void sound_manager::streams_update() +{ + attotime now = machine().time(); { - m_compressor_scale = 1.0 / curmax; - m_compressor_counter = STREAMS_UPDATE_FREQUENCY / 5; - } - - // if we're currently scaled, wait a bit to see if we can trend back toward 1.0 - else if (m_compressor_counter != 0) - m_compressor_counter--; + std::unique_lock<std::mutex> lock(m_effects_mutex); + for(osd_output_stream &stream : m_osd_output_streams) { + u64 next_sync = rate_and_time_to_index(now, stream.m_rate); + stream.m_samples = next_sync - stream.m_last_sync; + stream.m_last_sync = next_sync; + } - // try to migrate toward 0 unless we're going to introduce clipping - else if (m_compressor_scale < 1.0 && curmax * 1.01 * m_compressor_scale < 1.0) - { - m_compressor_scale *= 1.01f; - if (m_compressor_scale > 1.0) - m_compressor_scale = 1.0; + for(sound_stream *stream : m_ordered_streams) + stream->update_nodeps(); } -#if (SOUND_DEBUG) - if (lscale != m_compressor_scale) - printf("scale=%.5f\n", m_compressor_scale); -#endif - - // track whether there are pending scale changes in left/right - stream_buffer::sample_t lprev = 0, rprev = 0; + for(sound_stream *stream : m_ordered_streams) + if(stream->device().type() != SPEAKER) + stream->sync(now); - // now downmix the final result - u32 finalmix_step = machine().video().speed_factor(); - u32 finalmix_offset = 0; - s16 *finalmix = &m_finalmix[0]; - int sample; - for (sample = m_finalmix_leftover; sample < m_samples_this_update * 1000; sample += finalmix_step) - { - int sampindex = sample / 1000; - - // ensure that changing the compression won't reverse direction to reduce "pops" - stream_buffer::sample_t lsamp = m_leftmix[sampindex]; - if (lscale != m_compressor_scale && sample != m_finalmix_leftover) - lscale = adjust_toward_compressor_scale(lscale, lprev, lsamp); - - lprev = lsamp * lscale; - if (m_compressor_enabled) - lsamp = lprev; - - // clamp the left side - if (lsamp > 1.0) - lsamp = 1.0; - else if (lsamp < -1.0) - lsamp = -1.0; - finalmix[finalmix_offset++] = s16(lsamp * 32767.0); - - // ensure that changing the compression won't reverse direction to reduce "pops" - stream_buffer::sample_t rsamp = m_rightmix[sampindex]; - if (rscale != m_compressor_scale && sample != m_finalmix_leftover) - rscale = adjust_toward_compressor_scale(rscale, rprev, rsamp); - - rprev = rsamp * rscale; - if (m_compressor_enabled) - rsamp = rprev; - - // clamp the right side - if (rsamp > 1.0) - rsamp = 1.0; - else if (rsamp < -1.0) - rsamp = -1.0; - finalmix[finalmix_offset++] = s16(rsamp * 32767.0); - } - m_finalmix_leftover = sample - m_samples_this_update * 1000; - - // play the result - if (finalmix_offset > 0) - { - if (!m_nosound_mode) - machine().osd().update_audio_stream(finalmix, finalmix_offset / 2); - machine().osd().add_audio_to_recording(finalmix, finalmix_offset / 2); - machine().video().add_sound_to_recording(finalmix, finalmix_offset / 2); - if (m_wavfile) - util::wav_add_data_16(*m_wavfile, finalmix, finalmix_offset); - } + for(osd_input_stream &stream : m_osd_input_streams) + stream.m_buffer.sync(); - // update any orphaned streams so they don't get too far behind - for (auto &stream : m_orphan_stream_list) - stream.first->update(); + machine().osd().add_audio_to_recording(m_record_buffer.data(), m_record_samples); + machine().video().add_sound_to_recording(m_record_buffer.data(), m_record_samples); + if(m_wavfile) + util::wav_add_data_16(*m_wavfile, m_record_buffer.data(), m_record_samples); - // remember the update time - m_last_update = endtime; - m_update_number++; + m_effects_condition.notify_all(); + +} - // apply sample rate changes - apply_sample_rate_changes(); +//**// Resampler management - // notify that new samples have been generated - emulator_info::sound_hook(); +const audio_resampler *sound_manager::get_resampler(u32 fs, u32 ft) +{ + auto key = std::make_pair(fs, ft); + auto i = m_resamplers.find(key); + if(i != m_resamplers.end()) + return i->second.get(); + auto *res = new audio_resampler(fs, ft); + m_resamplers[key].reset(res); + return res; } + diff --git a/src/emu/sound.h b/src/emu/sound.h index 15f6a5743a2..bca66c88a7c 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -62,21 +62,19 @@ #define MAME_EMU_SOUND_H #include "wavwrite.h" - +#include "interface/audio.h" +#include <mutex> +#include <thread> +#include <condition_variable> //************************************************************************** // CONSTANTS //************************************************************************** // special sample-rate values -constexpr u32 SAMPLE_RATE_INVALID = 0xffffffff; -constexpr u32 SAMPLE_RATE_INPUT_ADAPTIVE = 0xfffffffe; -constexpr u32 SAMPLE_RATE_OUTPUT_ADAPTIVE = 0xfffffffd; - -// anything below this sample rate is effectively treated as "off" -constexpr u32 SAMPLE_RATE_MINIMUM = 50; - - +constexpr u32 SAMPLE_RATE_INPUT_ADAPTIVE = 0xffffffff; +constexpr u32 SAMPLE_RATE_OUTPUT_ADAPTIVE = 0xfffffffe; +constexpr u32 SAMPLE_RATE_ADAPTIVE = 0xfffffffd; //************************************************************************** // DEBUGGING @@ -86,7 +84,7 @@ constexpr u32 SAMPLE_RATE_MINIMUM = 50; #ifdef MAME_DEBUG #define SOUND_DEBUG (1) #else -#define SOUND_DEBUG (0) +#define SOUND_DEBUG (1) #endif // if SOUND_DEBUG is on, make assertions fire regardless of MAME_DEBUG @@ -96,491 +94,9 @@ constexpr u32 SAMPLE_RATE_MINIMUM = 50; #define sound_assert assert #endif - - -//************************************************************************** -// TYPE DEFINITIONS -//************************************************************************** - -// ======================> stream_buffer - -class stream_buffer -{ - // stream_buffer is an internal class, not directly accessed - // outside of the classes below - friend class read_stream_view; - friend class write_stream_view; - friend class sound_stream; - friend class sound_stream_output; - -public: - // the one public bit is the sample type - using sample_t = float; - -private: - // constructor/destructor - stream_buffer(u32 sample_rate = 48000); - ~stream_buffer(); - - // disable copying of stream_buffers directly - stream_buffer(stream_buffer const &src) = delete; - stream_buffer &operator=(stream_buffer const &rhs) = delete; - - // return the current sample rate - u32 sample_rate() const { return m_sample_rate; } - - // set a new sample rate - void set_sample_rate(u32 rate, bool resample); - - // return the current sample period in attoseconds - attoseconds_t sample_period_attoseconds() const { return m_sample_attos; } - attotime sample_period() const { return attotime(0, m_sample_attos); } - - // return the attotime of the current end of buffer - attotime end_time() const { return index_time(m_end_sample); } - - // set the ending time (for forced resyncs; generally not used) - void set_end_time(attotime time) - { - m_end_second = time.seconds(); - m_end_sample = u32(time.attoseconds() / m_sample_attos); - } - - // return the effective buffer size; currently it is a full second of audio - // at the current sample rate, but this maybe change in the future - u32 size() const { return m_sample_rate; } - - // read the sample at the given index (clamped); should be valid in all cases - sample_t get(s32 index) const - { - sound_assert(u32(index) < size()); - sample_t value = m_buffer[index]; -#if (SOUND_DEBUG) - sound_assert(!std::isnan(value)); -#endif - return value; - } - - // write the sample at the given index (clamped) - void put(s32 index, sample_t data) - { - sound_assert(u32(index) < size()); - m_buffer[index] = data; - } - - // simple helpers to step indexes - u32 next_index(u32 index) { index++; return (index == size()) ? 0 : index; } - u32 prev_index(u32 index) { return (index == 0) ? (size() - 1) : (index - 1); } - - // clamp an index to the size of the buffer; allows for indexing +/- one - // buffers' worth of range - u32 clamp_index(s32 index) const - { - if (index < 0) - index += size(); - else if (index >= size()) - index -= size(); - sound_assert(index >= 0 && index < size()); - return index; - } - - // fill the buffer with the given value - void fill(sample_t value) { std::fill_n(&m_buffer[0], m_buffer.size(), value); } - - // return the attotime of a given index within the buffer - attotime index_time(s32 index) const; - - // given an attotime, return the buffer index corresponding to it - u32 time_to_buffer_index(attotime time, bool round_up, bool allow_expansion = false); - - // downsample from our buffer into a temporary buffer - void backfill_downsample(sample_t *dest, int samples, attotime newend, attotime newperiod); - - // upsample from a temporary buffer into our buffer - void backfill_upsample(sample_t const *src, int samples, attotime prevend, attotime prevperiod); - - // internal state - u32 m_end_second; // current full second of the buffer end - u32 m_end_sample; // current sample number within the final second - u32 m_sample_rate; // sample rate of the data in the buffer - attoseconds_t m_sample_attos; // pre-computed attoseconds per sample - std::vector<sample_t> m_buffer; // vector of actual buffer data - -#if (SOUND_DEBUG) -public: - // for debugging, provide an interface to write a WAV stream - void open_wav(char const *filename); - void flush_wav(); - -private: - // internal debugging state - util::wav_file_ptr m_wav_file; // pointer to the current WAV file - u32 m_last_written = 0; // last written sample index -#endif -}; - - -// ======================> read_stream_view - -class read_stream_view -{ -public: - using sample_t = stream_buffer::sample_t; - -protected: - // private constructor used by write_stream_view that allows for expansion - read_stream_view(stream_buffer &buffer, attotime start, attotime end) : - read_stream_view(&buffer, 0, buffer.time_to_buffer_index(end, true, true), 1.0) - { - // start has to be set after end, since end can expand the buffer and - // potentially invalidate start - m_start = buffer.time_to_buffer_index(start, false); - normalize_start_end(); - } - -public: - // base constructor to simplify some of the code - read_stream_view(stream_buffer *buffer, s32 start, s32 end, sample_t gain) : - m_buffer(buffer), - m_end(end), - m_start(start), - m_gain(gain) - { - normalize_start_end(); - } - - // empty constructor so we can live in an array or vector - read_stream_view() : - read_stream_view(nullptr, 0, 0, 1.0) - { - } - - // constructor that covers the given time period - read_stream_view(stream_buffer &buffer, attotime start, attotime end, sample_t gain) : - read_stream_view(&buffer, buffer.time_to_buffer_index(start, false), buffer.time_to_buffer_index(end, true), gain) - { - } - - // copy constructor - read_stream_view(read_stream_view const &src) : - read_stream_view(src.m_buffer, src.m_start, src.m_end, src.m_gain) - { - } - - // copy constructor that sets a different start time - read_stream_view(read_stream_view const &src, attotime start) : - read_stream_view(src.m_buffer, src.m_buffer->time_to_buffer_index(start, false), src.m_end, src.m_gain) - { - } - - // copy assignment - read_stream_view &operator=(read_stream_view const &rhs) - { - m_buffer = rhs.m_buffer; - m_start = rhs.m_start; - m_end = rhs.m_end; - m_gain = rhs.m_gain; - normalize_start_end(); - return *this; - } - - // return the local gain - sample_t gain() const { return m_gain; } - - // return the sample rate of the data - u32 sample_rate() const { return m_buffer->sample_rate(); } - - // return the sample period (in attoseconds) of the data - attoseconds_t sample_period_attoseconds() const { return m_buffer->sample_period_attoseconds(); } - attotime sample_period() const { return m_buffer->sample_period(); } - - // return the number of samples represented by the buffer - u32 samples() const { return m_end - m_start; } - - // return the starting or ending time of the buffer - attotime start_time() const { return m_buffer->index_time(m_start); } - attotime end_time() const { return m_buffer->index_time(m_end); } - - // set the gain - read_stream_view &set_gain(float gain) { m_gain = gain; return *this; } - - // apply an additional gain factor - read_stream_view &apply_gain(float gain) { m_gain *= gain; return *this; } - - // safely fetch a gain-scaled sample from the buffer - sample_t get(s32 index) const - { - sound_assert(u32(index) < samples()); - index += m_start; - if (index >= m_buffer->size()) - index -= m_buffer->size(); - return m_buffer->get(index) * m_gain; - } - - // safely fetch a raw sample from the buffer; if you use this, you need to - // apply the gain yourself for correctness - sample_t getraw(s32 index) const - { - sound_assert(u32(index) < samples()); - index += m_start; - if (index >= m_buffer->size()) - index -= m_buffer->size(); - return m_buffer->get(index); - } - -protected: - // normalize start/end - void normalize_start_end() - { - // ensure that end is always greater than start; we'll - // wrap to the buffer length as needed - if (m_end < m_start && m_buffer != nullptr) - m_end += m_buffer->size(); - sound_assert(m_end >= m_start); - } - - // internal state - stream_buffer *m_buffer; // pointer to the stream buffer we're viewing - s32 m_end; // ending sample index (always >= start) - s32 m_start; // starting sample index - sample_t m_gain; // overall gain factor -}; - - -// ======================> write_stream_view - -class write_stream_view : public read_stream_view -{ - -public: - // empty constructor so we can live in an array or vector - write_stream_view() - { - } - - // constructor that covers the given time period - write_stream_view(stream_buffer &buffer, attotime start, attotime end) : - read_stream_view(buffer, start, end) - { - } - - // constructor that converts from a read_stream_view - write_stream_view(read_stream_view const &src) : - read_stream_view(src) - { - } - - // safely write a sample to the buffer - void put(s32 start, sample_t sample) - { - sound_assert(u32(start) < samples()); - m_buffer->put(index_to_buffer_index(start), sample); - } - - // write a sample to the buffer, clamping to +/- the clamp value - void put_clamp(s32 index, sample_t sample, sample_t clamp = 1.0) - { - assert(clamp >= sample_t(0)); - put(index, std::clamp(sample, -clamp, clamp)); - } - - // write a sample to the buffer, converting from an integer with the given maximum - void put_int(s32 index, s32 sample, s32 max) - { - put(index, sample_t(sample) * (1.0f / sample_t(max))); - } - - // write a sample to the buffer, converting from an integer with the given maximum - void put_int_clamp(s32 index, s32 sample, s32 maxclamp) - { - assert(maxclamp >= 0); - put_int(index, std::clamp(sample, -maxclamp, maxclamp), maxclamp); - } - - // safely add a sample to the buffer - void add(s32 start, sample_t sample) - { - sound_assert(u32(start) < samples()); - u32 index = index_to_buffer_index(start); - m_buffer->put(index, m_buffer->get(index) + sample); - } - - // add a sample to the buffer, converting from an integer with the given maximum - void add_int(s32 index, s32 sample, s32 max) - { - add(index, sample_t(sample) * (1.0f / sample_t(max))); - } - - // fill part of the view with the given value - void fill(sample_t value, s32 start, s32 count) - { - if (start + count > samples()) - count = samples() - start; - u32 index = index_to_buffer_index(start); - for (s32 sampindex = 0; sampindex < count; sampindex++) - { - m_buffer->put(index, value); - index = m_buffer->next_index(index); - } - } - void fill(sample_t value, s32 start) { fill(value, start, samples() - start); } - void fill(sample_t value) { fill(value, 0, samples()); } - - // copy data from another view - void copy(read_stream_view const &src, s32 start, s32 count) - { - if (start + count > samples()) - count = samples() - start; - u32 index = index_to_buffer_index(start); - for (s32 sampindex = 0; sampindex < count; sampindex++) - { - m_buffer->put(index, src.get(start + sampindex)); - index = m_buffer->next_index(index); - } - } - void copy(read_stream_view const &src, s32 start) { copy(src, start, samples() - start); } - void copy(read_stream_view const &src) { copy(src, 0, samples()); } - - // add data from another view to our current values - void add(read_stream_view const &src, s32 start, s32 count) - { - if (start + count > samples()) - count = samples() - start; - u32 index = index_to_buffer_index(start); - for (s32 sampindex = 0; sampindex < count; sampindex++) - { - m_buffer->put(index, m_buffer->get(index) + src.get(start + sampindex)); - index = m_buffer->next_index(index); - } - } - void add(read_stream_view const &src, s32 start) { add(src, start, samples() - start); } - void add(read_stream_view const &src) { add(src, 0, samples()); } - -private: - // given a stream starting offset, return the buffer index - u32 index_to_buffer_index(s32 start) const - { - u32 index = start + m_start; - if (index >= m_buffer->size()) - index -= m_buffer->size(); - return index; - } -}; - - -// ======================> sound_stream_output - -class sound_stream_output -{ -#if (SOUND_DEBUG) - friend class sound_stream; -#endif - -public: - // construction/destruction - sound_stream_output(); - - // initialization - void init(sound_stream &stream, u32 index, char const *tag_base); - - // no copying allowed - sound_stream_output(sound_stream_output const &src) = delete; - sound_stream_output &operator=(sound_stream_output const &rhs) = delete; - - // simple getters - sound_stream &stream() const { sound_assert(m_stream != nullptr); return *m_stream; } - attotime end_time() const { return m_buffer.end_time(); } - u32 index() const { return m_index; } - stream_buffer::sample_t gain() const { return m_gain; } - u32 buffer_sample_rate() const { return m_buffer.sample_rate(); } - - // simple setters - void set_gain(float gain) { m_gain = gain; } - - // return a friendly name - std::string name() const; - - // handle a changing sample rate - void sample_rate_changed(u32 rate) { m_buffer.set_sample_rate(rate, true); } - - // return an output view covering a time period - write_stream_view view(attotime start, attotime end) { return write_stream_view(m_buffer, start, end); } - - // resync the buffer to the given end time - void set_end_time(attotime end) { m_buffer.set_end_time(end); } - - // attempt to optimize resamplers by reusing them where possible - sound_stream_output &optimize_resampler(sound_stream_output *input_resampler); - -private: - // internal state - sound_stream *m_stream; // owning stream - stream_buffer m_buffer; // output buffer - u32 m_index; // output index within the stream - stream_buffer::sample_t m_gain; // gain to apply to the output - std::vector<sound_stream_output *> m_resampler_list; // list of resamplers we're connected to -}; - - -// ======================> sound_stream_input - -class sound_stream_input -{ -#if (SOUND_DEBUG) - friend class sound_stream; -#endif - -public: - // construction/destruction - sound_stream_input(); - - // initialization - void init(sound_stream &stream, u32 index, char const *tag_base, sound_stream_output *resampler); - - // no copying allowed - sound_stream_input(sound_stream_input const &src) = delete; - sound_stream_input &operator=(sound_stream_input const &rhs) = delete; - - // simple getters - bool valid() const { return (m_native_source != nullptr); } - sound_stream &owner() const { sound_assert(valid()); return *m_owner; } - sound_stream_output &source() const { sound_assert(valid()); return *m_native_source; } - u32 index() const { return m_index; } - stream_buffer::sample_t gain() const { return m_gain; } - stream_buffer::sample_t user_gain() const { return m_user_gain; } - - // simple setters - void set_gain(float gain) { m_gain = gain; } - void set_user_gain(float gain) { m_user_gain = gain; } - - // return a friendly name - std::string name() const; - - // connect the source - void set_source(sound_stream_output *source); - - // update and return an reading view - read_stream_view update(attotime start, attotime end); - - // tell inputs to apply sample rate changes - void apply_sample_rate_changes(u32 updatenum, u32 downstream_rate); - -private: - // internal state - sound_stream *m_owner; // pointer to the owning stream - sound_stream_output *m_native_source; // pointer to the native sound_stream_output - sound_stream_output *m_resampler_source; // pointer to the resampler output - u32 m_index; // input index within the stream - stream_buffer::sample_t m_gain; // gain to apply to this input - stream_buffer::sample_t m_user_gain; // user-controlled gain to apply to this input -}; - - -// ======================> stream_update_delegate - -// new-style callback -using stream_update_delegate = delegate<void (sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs)>; - +using stream_update_delegate = delegate<void (sound_stream &stream)>; +class audio_effect; +class audio_resampler; // ======================> sound_stream_flags @@ -592,86 +108,203 @@ enum sound_stream_flags : u32 // specify that updates should be forced to one sample at a time, in real time // this implicitly creates a timer that runs at the stream's output frequency // so only use when strictly necessary - STREAM_SYNCHRONOUS = 0x01, - - // specify that input streams should not be resampled; stream update handler - // must be able to accommodate multiple strams of differing input rates - STREAM_DISABLE_INPUT_RESAMPLING = 0x02 + STREAM_SYNCHRONOUS = 0x01 }; +namespace emu::detail { + template<typename S> class output_buffer_interleaved { + public: + output_buffer_interleaved(u32 buffer_size, u32 channels); + + void set_buffer_size(u32 buffer_size); + + u32 channels() const { return m_channels; } + u64 sync_sample() const { return m_sync_sample; } + void set_sync_sample(u64 sample) { m_sync_sample = sample; } + u64 write_sample() const { return m_sync_sample + m_write_position - m_sync_position; } + void prepare_space(u32 samples); + void commit(u32 samples); + void sync(); + + void ensure_size(u32 buffer_size); + void set_history(u32 history); + + u32 available_samples() const { return m_write_position - m_sync_position; } + S *ptrw(u32 channel, s32 index) { return &m_buffer[(m_write_position + index) * m_channels + channel]; } + const S *ptrw(u32 channel, s32 index) const { return &m_buffer[(m_write_position + index) * m_channels + channel]; } + const S *ptrs(u32 channel, s32 index) const { return &m_buffer[(m_sync_position + index) * m_channels + channel]; } + + private: + std::vector<S> m_buffer; + u64 m_sync_sample; + u32 m_write_position; + u32 m_sync_position; + u32 m_history; + u32 m_channels; + }; + + template<typename S> class output_buffer_flat { + friend class sound_stream; // To make state saving easier + public: + output_buffer_flat(u32 buffer_size, u32 channels); + + void set_buffer_size(u32 buffer_size); + + u32 channels() const { return m_channels; } + u64 sync_sample() const { return m_sync_sample; } + void set_sync_sample(u64 sample) { m_sync_sample = sample; } + u64 write_sample() const { return m_sync_sample + m_write_position - m_sync_position; } + + void prepare_space(u32 samples); + void commit(u32 samples); + void sync(); + + void ensure_size(u32 buffer_size); + void set_history(u32 history); + + void resample(u32 previous_rate, u32 next_rate, attotime sync_time, attotime now); + + void register_save_state(device_t &device, const char *id1, const char *id2); + + u32 available_samples() const { return m_write_position - m_sync_position; } + S *ptrw(u32 channel, s32 index) { return &m_buffer[channel][m_write_position + index]; } + const S *ptrw(u32 channel, s32 index) const { return &m_buffer[channel][m_write_position + index]; } + const S *ptrs(u32 channel, s32 index) const { return &m_buffer[channel][m_sync_position + index]; } + + private: + std::vector<std::vector<S>> m_buffer; + u64 m_sync_sample; + u32 m_write_position; + u32 m_sync_position; + u32 m_history; + u32 m_channels; + }; +} // ======================> sound_stream class sound_stream { +public: friend class sound_manager; + using sample_t = float; - // private common constructopr - sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, sound_stream_flags flags); - -public: // construction/destruction - sound_stream(device_t &device, u32 inputs, u32 outputs, u32 output_base, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags = STREAM_DEFAULT_FLAGS); + sound_stream(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags = sound_stream_flags::STREAM_DEFAULT_FLAGS); virtual ~sound_stream(); // simple getters - sound_stream *next() const { return m_next; } device_t &device() const { return m_device; } std::string name() const { return m_name; } - bool input_adaptive() const { return m_input_adaptive || m_synchronous; } + bool input_adaptive() const { return m_input_adaptive; } bool output_adaptive() const { return m_output_adaptive; } bool synchronous() const { return m_synchronous; } - bool resampling_disabled() const { return m_resampling_disabled; } + bool is_active() const { return m_sample_rate != 0; } // input and output getters - u32 input_count() const { return m_input.size(); } - u32 output_count() const { return m_output.size(); } - u32 output_base() const { return m_output_base; } - sound_stream_input &input(int index) { sound_assert(index >= 0 && index < m_input.size()); return m_input[index]; } - sound_stream_output &output(int index) { sound_assert(index >= 0 && index < m_output.size()); return m_output[index]; } + u32 input_count() const { return m_input_count; } + u32 output_count() const { return m_output_count; } // sample rate and timing getters - u32 sample_rate() const { return (m_pending_sample_rate != SAMPLE_RATE_INVALID) ? m_pending_sample_rate : m_sample_rate; } - attotime sample_time() const { return m_output[0].end_time(); } - attotime sample_period() const { return attotime(0, sample_period_attoseconds()); } - attoseconds_t sample_period_attoseconds() const { return (m_sample_rate != SAMPLE_RATE_INVALID) ? HZ_TO_ATTOSECONDS(m_sample_rate) : ATTOSECONDS_PER_SECOND; } - - // set the sample rate of the stream; will kick in at the next global update + u32 sample_rate() const { return m_sample_rate; } + attotime sample_period() const { return attotime::from_hz(m_sample_rate); } + + // sample id and timing of the first and last sample of the current update block, and first of the next sample block + u64 start_index() const { return m_output_buffer.write_sample(); } + u64 end_index() const { return m_output_buffer.write_sample() + samples() - 1; } + u64 sample_index() const { return m_output_buffer.write_sample() + samples(); } + attotime start_time() const { return sample_to_time(start_index()); } + attotime end_time() const { return sample_to_time(end_index()); } + attotime sample_time() const { return sample_to_time(sample_index()); } + + // convert from absolute sample index to time + attotime sample_to_time(u64 index) const; + + // gain management + float user_output_gain() const { return m_user_output_gain; } + void set_user_output_gain(float gain) { update(); m_user_output_gain = gain; } + float user_output_gain(s32 output) const { return m_user_output_channel_gain[output]; } + void set_user_output_gain(s32 output, float gain) { update(); m_user_output_channel_gain[output] = gain; } + + float input_gain(s32 input) const { return m_input_channel_gain[input]; } + void set_input_gain(s32 input, float gain) { update(); m_input_channel_gain[input] = gain; } + void apply_input_gain(s32 input, float gain) { update(); m_input_channel_gain[input] *= gain; } + float output_gain(s32 output) const { return m_output_channel_gain[output]; } + void set_output_gain(s32 output, float gain) { update(); m_output_channel_gain[output] = gain; } + void apply_output_gain(s32 output, float gain) { update(); m_output_channel_gain[output] *= gain; } + + // set the sample rate of the stream void set_sample_rate(u32 sample_rate); - // connect the output 'outputnum' of given input_stream to this stream's input 'inputnum' - void set_input(int inputnum, sound_stream *input_stream, int outputnum = 0, float gain = 1.0f); - // force an update to the current time void update(); - // force an update to the current time, returning a view covering the given time period - read_stream_view update_view(attotime start, attotime end, u32 outputnum = 0); + // number of samples to handle + s32 samples() const { return m_samples_to_update; } - // apply any pending sample rate changes; should only be called by the sound manager - void apply_sample_rate_changes(u32 updatenum, u32 downstream_rate); + // write a sample to the buffer + void put(s32 output, s32 index, sample_t sample) { *m_output_buffer.ptrw(output, index) = sample; } -#if (SOUND_DEBUG) - // print one level of the sound graph and recursively tell our inputs to do the same - void print_graph_recursive(int indent, int index); -#endif + // write a sample to the buffer, clamping to +/- the clamp value + void put_clamp(s32 output, s32 index, sample_t sample, sample_t clamp = 1.0) { put(output, index, std::clamp(sample, -clamp, clamp)); } -protected: - // protected state - std::string m_name; // name of this stream + // write a sample to the buffer, converting from an integer with the given maximum + void put_int(s32 output, s32 index, s32 sample, s32 max) { put(output, index, double(sample)/max); } + + // write a sample to the buffer, converting from an integer with the given maximum + void put_int_clamp(s32 output, s32 index, s32 sample, s32 maxclamp) { put_int(output, index, std::clamp(sample, -maxclamp, maxclamp-1), maxclamp); } + + // safely add a sample to the buffer + void add(s32 output, s32 index, sample_t sample) { *m_output_buffer.ptrw(output, index) += sample; } + + // add a sample to the buffer, converting from an integer with the given maximum + void add_int(s32 output, s32 index, s32 sample, s32 max) { add(output, index, double(sample)/max); } + + // fill part of the view with the given value + void fill(s32 output, sample_t value, s32 start, s32 count) { std::fill(m_output_buffer.ptrw(output, start), m_output_buffer.ptrw(output, start+count), value); } + void fill(s32 output, sample_t value, s32 start) { std::fill(m_output_buffer.ptrw(output, start), m_output_buffer.ptrw(output, samples()), value); } + void fill(s32 output, sample_t value) { std::fill(m_output_buffer.ptrw(output, 0), m_output_buffer.ptrw(output, samples()), value); } + + // copy data from the input + void copy(s32 output, s32 input, s32 start, s32 count) { std::copy(m_input_buffer[input].begin() + start, m_input_buffer[input].begin() + start + count, m_output_buffer.ptrw(output, start)); } + void copy(s32 output, s32 input, s32 start) { std::copy(m_input_buffer[input].begin() + start, m_input_buffer[input].begin() + samples(), m_output_buffer.ptrw(output, start)); } + void copy(s32 output, s32 input) { std::copy(m_input_buffer[input].begin(), m_input_buffer[input].begin() + samples(), m_output_buffer.ptrw(output, 0)); } + + // fetch a sample from the input buffer + sample_t get(s32 input, s32 index) const { return m_input_buffer[input][index]; } + + // fetch a sample from the output buffer + sample_t get_output(s32 output, s32 index) const { return *m_output_buffer.ptrw(output, index); } + + void add_bw_route(sound_stream *source, int output, int input, float gain); + void add_fw_route(sound_stream *target, int input, int output); + std::vector<sound_stream *> sources() const; + std::vector<sound_stream *> targets() const; + + bool set_route_gain(sound_stream *source, int source_channel, int target_channel, float gain); private: - // perform most of the initialization here - void init_common(u32 inputs, u32 outputs, u32 sample_rate, sound_stream_flags flags); + struct route_bw { + sound_stream *m_source; + int m_output; + int m_input; + float m_gain; + const audio_resampler *m_resampler; - // if the sample rate has changed, this gets called to update internals - void sample_rate_changed(); + route_bw(sound_stream *source, int output, int input, float gain) : m_source(source), m_output(output), m_input(input), m_gain(gain), m_resampler(nullptr) {} + }; - // handle updates after a save state load - void postload(); + struct route_fw { + sound_stream *m_target; + int m_input; + int m_output; + + route_fw(sound_stream *target, int input, int output) : m_target(target), m_input(input), m_output(output) {} + }; - // handle updates before a save state load - void presave(); + + // perform most of the initialization here + void init(); // re-print the synchronization timer void reprime_sync_timer(); @@ -679,68 +312,57 @@ private: // timer callback for synchronous streams void sync_update(s32); - // return a view of 0 data covering the given time period - read_stream_view empty_view(attotime start, attotime end); + void update_nodeps(); + void sync(attotime now); + u64 get_current_sample_index() const; + void do_update(); + + bool frequency_is_solved() const { return (!(m_input_adaptive || m_output_adaptive)) || m_sample_rate != 0; } + bool try_solving_frequency(); + void register_state(); + void add_dependants(std::vector<sound_stream *> &deps); + void compute_dependants(); + void create_resamplers(); + void lookup_history_sizes(); + u32 get_history_for_bw_route(const sound_stream *source, u32 channel) const; + void internal_set_sample_rate(u32 sample_rate); + + std::string m_name; // name of this stream + std::string m_state_tag; // linking information device_t &m_device; // owning device - sound_stream *m_next; // next stream in the chain + std::vector<route_bw> m_bw_routes; + std::vector<route_fw> m_fw_routes; + std::vector<sound_stream *> m_dependant_streams; + + // buffers + std::vector<std::vector<sample_t>> m_input_buffer; + emu::detail::output_buffer_flat<sample_t> m_output_buffer; + attotime m_sync_time; + s32 m_samples_to_update; + + // gains + std::vector<float> m_input_channel_gain; + std::vector<float> m_output_channel_gain; + std::vector<float> m_user_output_channel_gain; + float m_user_output_gain; // general information - u32 m_sample_rate; // current live sample rate - u32 m_pending_sample_rate; // pending sample rate for dynamic changes - u32 m_last_sample_rate_update; // update number of last sample rate change + u32 m_sample_rate; // current sample rate + u32 m_input_count; + u32 m_output_count; bool m_input_adaptive; // adaptive stream that runs at the sample rate of its input bool m_output_adaptive; // adaptive stream that runs at the sample rate of its output bool m_synchronous; // synchronous stream that runs at the rate of its input - bool m_resampling_disabled; // is resampling of input streams disabled? + bool m_started; emu_timer *m_sync_timer; // update timer for synchronous streams - attotime m_last_update_end_time; // last end_time() in update - - // input information - std::vector<sound_stream_input> m_input; // list of streams we directly depend upon - std::vector<read_stream_view> m_input_view; // array of output views for passing to the callback - std::vector<std::unique_ptr<sound_stream>> m_resampler_list; // internal list of resamplers - stream_buffer m_empty_buffer; // empty buffer for invalid inputs - - // output information - u32 m_output_base; // base index of our outputs, relative to our device - std::vector<sound_stream_output> m_output; // list of streams which directly depend upon us - std::vector<write_stream_view> m_output_view; // array of output views for passing to the callback - // callback information - stream_update_delegate m_callback_ex; // extended callback function + stream_update_delegate m_callback; // update callback function }; -// ======================> default_resampler_stream - -class default_resampler_stream : public sound_stream -{ -public: - // construction/destruction - default_resampler_stream(device_t &device); - - // update handler - void resampler_sound_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs); - -private: - // internal state - u32 m_max_latency; -}; - - -// ======================> sound_manager - -// structure describing an indexed mixer -struct mixer_input -{ - device_mixer_interface *mixer; // owning device interface - sound_stream * stream; // stream within the device - int inputnum; // input on the stream -}; - class sound_manager { friend class sound_stream; @@ -755,6 +377,27 @@ class sound_manager static const attotime STREAMS_UPDATE_ATTOTIME; public: + using sample_t = sound_stream::sample_t; + + struct mapping { + struct node_mapping { + u32 m_node; + float m_db; + bool m_is_system_default; + }; + + struct channel_mapping { + u32 m_guest_channel; + u32 m_node; + u32 m_node_channel; + float m_db; + bool m_is_system_default; + }; + sound_io_device *m_dev; + std::vector<node_mapping> m_node_mappings; + std::vector<channel_mapping> m_channel_mappings; + }; + static constexpr int STREAMS_UPDATE_FREQUENCY = 50; // construction/destruction @@ -763,14 +406,13 @@ public: // getters running_machine &machine() const { return m_machine; } - int attenuation() const { return m_attenuation; } const std::vector<std::unique_ptr<sound_stream>> &streams() const { return m_stream_list; } - attotime last_update() const { return m_last_update; } - int sample_count() const { return m_samples_this_update; } int unique_id() { return m_unique_id++; } - stream_buffer::sample_t compressor_scale() const { return m_compressor_scale; } - // allocate a new stream with a new-style callback + const typename osd::audio_info &get_osd_info() const { return m_osd_info; } + const std::vector<mapping> &get_mappings() const { return m_mappings; } + + // allocate a new stream sound_stream *stream_alloc(device_t &device, u32 inputs, u32 outputs, u32 sample_rate, stream_update_delegate callback, sound_stream_flags flags); // WAV recording @@ -778,9 +420,21 @@ public: bool start_recording(); bool start_recording(std::string_view filename); void stop_recording(); - - // set the global OSD attenuation level - void set_attenuation(float attenuation); + u32 outputs_count() const { return m_outputs_count; } + + // manage the sound_io mapping and volume configuration + void config_add_sound_io_connection_node(sound_io_device *dev, std::string name, float db); + void config_add_sound_io_connection_default(sound_io_device *dev, float db); + void config_remove_sound_io_connection_node(sound_io_device *dev, std::string name); + void config_remove_sound_io_connection_default(sound_io_device *dev); + void config_set_volume_sound_io_connection_node(sound_io_device *dev, std::string name, float db); + void config_set_volume_sound_io_connection_default(sound_io_device *dev, float db); + void config_add_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db); + void config_add_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db); + void config_remove_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel); + void config_remove_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel); + void config_set_volume_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db); + void config_set_volume_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db); // mute sound for one of various independent reasons bool muted() const { return bool(m_muted); } @@ -791,22 +445,118 @@ public: void debugger_mute(bool turn_off) { mute(turn_off, MUTE_REASON_DEBUGGER); } void system_mute(bool turn_off) { mute(turn_off, MUTE_REASON_SYSTEM); } - // return information about the given mixer input, by index - bool indexed_mixer_input(int index, mixer_input &info) const; + // master gain + float master_gain() const { return m_master_gain; } + void set_master_gain(float gain) { m_master_gain = gain; } + + void before_devices_init(); + void after_devices_init(); + void postload(); + + void input_get(int m_id, sound_stream &stream); + void output_push(int m_id, sound_stream &stream); + const audio_resampler *get_resampler(u32 fs, u32 ft); - // fill the given buffer with 16-bit stereo audio samples - void samples(s16 *buffer); + u32 effect_chains() const { return m_speakers.size(); } + std::string effect_chain_tag(s32 index) const; + std::vector<audio_effect *> effect_chain(s32 index) const; + std::vector<audio_effect *> default_effect_chain() const; + void default_effect_changed(u32 entry); private: + struct effect_step { + std::unique_ptr<audio_effect> m_effect; + emu::detail::output_buffer_flat<sample_t> m_buffer; + effect_step(u32 buffer_size, u32 channels); + }; + + struct mixing_step { + enum { CLEAR, COPY, ADD }; + u32 m_mode; + u32 m_osd_index; + u32 m_osd_channel; + u32 m_device_index; + u32 m_device_channel; + float m_linear_volume; + }; + + struct speaker_info { + speaker_device &m_dev; + sound_stream *m_stream; + u32 m_channels; + u32 m_first_output; + + emu::detail::output_buffer_flat<sample_t> m_buffer; + + std::vector<effect_step> m_effects; + + speaker_info(speaker_device &dev, u32 rate, u32 first_output); + }; + + struct microphone_info { + microphone_device &m_dev; + u32 m_channels; + + std::vector<mixing_step> m_input_mixing_steps; // actions to take to fill the buffer + std::vector<sample_t> m_buffer; + microphone_info(microphone_device &dev); + }; + + struct osd_stream { + u32 m_id; + u32 m_node; + std::string m_node_name; + u32 m_channels; + u32 m_rate; + u32 m_unused_channels_mask; + bool m_is_system_default; + bool m_is_channel_mapping; + sound_io_device *m_dev; + std::vector<float> m_volumes; + + osd_stream(u32 node, std::string node_name, u32 channels, u32 rate, bool is_system_default, sound_io_device *dev) : + m_id(0), + m_node(node), + m_node_name(node_name), + m_channels(channels), + m_rate(rate), + m_unused_channels_mask(util::make_bitmask<u32>(channels)), + m_is_system_default(is_system_default), + m_is_channel_mapping(false), + m_dev(dev) + { } + }; + + struct osd_input_stream : public osd_stream { + emu::detail::output_buffer_interleaved<s16> m_buffer; + osd_input_stream(u32 node, std::string node_name, u32 channels, u32 rate, bool is_system_default, sound_io_device *dev) : + osd_stream(node, node_name, channels, rate, is_system_default, dev), + m_buffer(rate, channels) + { } + }; + + struct osd_output_stream : public osd_stream { + u64 m_last_sync; + u32 m_samples; + std::vector<s16> m_buffer; + osd_output_stream(u32 node, std::string node_name, u32 channels, u32 rate, bool is_system_default, sound_io_device *dev) : + osd_stream(node, node_name, channels, rate, is_system_default, dev), + m_last_sync(0), + m_samples(0), + m_buffer(channels*rate, 0) + { } + }; + + struct config_mapping { + std::string m_name; + // "" to indicates default node + std::vector<std::pair<std::string, float>> m_node_mappings; + std::vector<std::tuple<u32, std::string, u32, float>> m_channel_mappings; + }; + // set/reset the mute state for the given reason void mute(bool mute, u8 reason); - // helper to remove items from the orphan list - void recursive_remove_stream_from_orphan_list(sound_stream *stream); - - // apply pending sample rate changes - void apply_sample_rate_changes(); - // reset all sound chips void reset(); @@ -818,39 +568,79 @@ private: void config_load(config_type cfg_type, config_level cfg_lvl, util::xml::data_node const *parentnode); void config_save(config_type cfg_type, util::xml::data_node *parentnode); - // helper to adjust scale factor toward a goal - stream_buffer::sample_t adjust_toward_compressor_scale(stream_buffer::sample_t curscale, stream_buffer::sample_t prevsample, stream_buffer::sample_t rawsample); - // periodic sound update, called STREAMS_UPDATE_FREQUENCY per second - void update(s32 param = 0); + void update(s32); + + // handle mixing mapping update if needed + static std::vector<u32> find_channel_mapping(const std::array<double, 3> &position, const osd::audio_info::node_info *node); + void startup_cleanups(); + void mapping_update(); + void streams_update(); + template<bool is_output, typename S> void apply_osd_changes(std::vector<S> &streams); + void osd_information_update(); + void generate_mapping(); + void update_osd_streams(); + void update_osd_input(); + void speakers_update(attotime endtime); + + void run_effects(); + + u64 rate_and_time_to_index(attotime time, u32 sample_rate) const; + u64 rate_and_last_sync_to_index(u32 sample_rate) const { return rate_and_time_to_index(m_last_sync_time, sample_rate); } + + // manage the sound_io mapping and volume configuration, + // but don't change generation because we're in the update process + + config_mapping &config_get_sound_io(sound_io_device *dev); + void internal_config_add_sound_io_connection_node(sound_io_device *dev, std::string name, float db); + void internal_config_add_sound_io_connection_default(sound_io_device *dev, float db); + void internal_config_remove_sound_io_connection_node(sound_io_device *dev, std::string name); + void internal_config_remove_sound_io_connection_default(sound_io_device *dev); + void internal_config_set_volume_sound_io_connection_node(sound_io_device *dev, std::string name, float db); + void internal_config_set_volume_sound_io_connection_default(sound_io_device *dev, float db); + void internal_config_add_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db); + void internal_config_add_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db); + void internal_config_remove_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel); + void internal_config_remove_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel); + void internal_config_set_volume_sound_io_channel_connection_node(sound_io_device *dev, u32 guest_channel, std::string name, u32 node_channel, float db); + void internal_config_set_volume_sound_io_channel_connection_default(sound_io_device *dev, u32 guest_channel, u32 node_channel, float db); + // internal state - running_machine &m_machine; // reference to the running machine - emu_timer *m_update_timer; // timer that runs the update function - std::vector<std::reference_wrapper<speaker_device> > m_speakers; - - u32 m_update_number; // current update index; used for sample rate updates - attotime m_last_update; // time of the last update - u32 m_finalmix_leftover; // leftover samples in the final mix - u32 m_samples_this_update; // number of samples this update - std::vector<s16> m_finalmix; // final mix, in 16-bit signed format - std::vector<stream_buffer::sample_t> m_leftmix; // left speaker mix, in native format - std::vector<stream_buffer::sample_t> m_rightmix; // right speaker mix, in native format - - stream_buffer::sample_t m_compressor_scale; // current compressor scale factor - int m_compressor_counter; // compressor update counter for backoff - bool m_compressor_enabled; // enable compressor (it will still be calculated for detecting overdrive) - - u8 m_muted; // bitmask of muting reasons - bool m_nosound_mode; // true if we're in "nosound" mode - int m_attenuation; // current attentuation level (at the OSD) - int m_unique_id; // unique ID used for stream identification - util::wav_file_ptr m_wavfile; // WAV file for streaming + running_machine &m_machine; // reference to the running machine + emu_timer *m_update_timer; // timer that runs the update function + attotime m_last_sync_time; + std::vector<speaker_info> m_speakers; + std::vector<microphone_info> m_microphones; + + std::vector<s16> m_record_buffer; // pre-effects speaker samples for recording + u32 m_record_samples; // how many samples for the next update + osd::audio_info m_osd_info; // current state of the osd information + std::vector<mapping> m_mappings; // current state of the mappings + std::vector<osd_input_stream> m_osd_input_streams; // currently active osd streams + std::vector<osd_output_stream> m_osd_output_streams; // currently active osd streams + std::vector<mixing_step> m_output_mixing_steps; // actions to take to fill the osd streams buffers + std::vector<config_mapping> m_configs; // mapping user configuration + + std::mutex m_effects_mutex; + std::condition_variable m_effects_condition; + std::unique_ptr<std::thread> m_effects_thread; + std::vector<std::unique_ptr<audio_effect>> m_default_effects; + bool m_effects_done; + + float m_master_gain; + + std::map<std::pair<u32, u32>, std::unique_ptr<audio_resampler>> m_resamplers; + + u8 m_muted; // bitmask of muting reasons + bool m_nosound_mode; // true if we're in "nosound" mode + int m_unique_id; // unique ID used for stream identification + util::wav_file_ptr m_wavfile; // WAV file for streaming // streams data std::vector<std::unique_ptr<sound_stream>> m_stream_list; // list of streams - std::map<sound_stream *, u8> m_orphan_stream_list; // list of orphaned streams - bool m_first_reset; // is this our first reset? + std::vector<sound_stream *> m_ordered_streams; // Streams in update order + u32 m_outputs_count; }; diff --git a/src/emu/speaker.cpp b/src/emu/speaker.cpp index 33b1e8d329a..bcfd5609d5e 100644 --- a/src/emu/speaker.cpp +++ b/src/emu/speaker.cpp @@ -5,6 +5,7 @@ speaker.cpp Speaker output sound device. + Microphone input sound device. ***************************************************************************/ @@ -14,210 +15,78 @@ -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - -// device type definition DEFINE_DEVICE_TYPE(SPEAKER, speaker_device, "speaker", "Speaker") - - - -//************************************************************************** -// LIVE SPEAKER DEVICE -//************************************************************************** - -//------------------------------------------------- -// speaker_device - constructor -//------------------------------------------------- - -speaker_device::speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : device_t(mconfig, SPEAKER, tag, owner, clock) - , device_mixer_interface(mconfig, *this) - , m_x(0.0) - , m_y(0.0) - , m_z(0.0) - , m_pan(0.0) - , m_defpan(0.0) - , m_current_max(0) - , m_samples_this_bucket(0) +DEFINE_DEVICE_TYPE(MICROPHONE, microphone_device, "microphone", "Microphone") + +const sound_io_device::position_name_mapping sound_io_device::position_name_mappings[] = { + { 0.0, 0.0, 1.0, "Front center" }, + { -0.2, 0.0, 1.0, "Front left" }, + { 0.0, -0.5, 1.0, "Front floor" }, + { 0.2, 0.0, 1.0, "Front right" }, + { 0.0, 0.0, -0.5, "Rear center" }, + { -0.2, 0.0, -0.5, "Rear left" }, + { 0.2, 0.0, -0.5, "Read right" }, + { 0.0, 0.0, -0.1, "Headrest center" }, + { -0.1, 0.0, -0.1, "Headrest left" }, + { 0.1, 0.0, -0.1, "Headrest right" }, + { 0.0, -0.5, 0.0, "Seat" }, + { 0.0, -0.2, 0.1, "Backrest" }, + { } +}; + +std::string sound_io_device::get_position_name(u32 channel) const { + for(unsigned int i = 0; position_name_mappings[i].m_name; i++) + if(m_positions[channel][0] == position_name_mappings[i].m_x && m_positions[channel][1] == position_name_mappings[i].m_y && m_positions[channel][2] == position_name_mappings[i].m_z) + return position_name_mappings[i].m_name; + return util::string_format("#%d", channel); } - -//------------------------------------------------- -// ~speaker_device - destructor -//------------------------------------------------- - -speaker_device::~speaker_device() +sound_io_device &sound_io_device::set_position(u32 channel, double x, double y, double z) { + m_positions[channel][0] = x; + m_positions[channel][1] = y; + m_positions[channel][2] = z; + return *this; } - -//------------------------------------------------- -// set_position - set speaker position -//------------------------------------------------- - -speaker_device &speaker_device::set_position(double x, double y, double z) +sound_io_device::sound_io_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 channels) : + device_t(mconfig, type, tag, owner, 0), + device_sound_interface(mconfig, *this), + m_positions(channels ? channels : 1) { - // as mentioned in the header file, y and z params currently have no effect - m_x = x; - m_y = y; - m_z = z; - - // hard pan to left - if (m_x < 0.0) - set_pan(-1.0f); - - // hard pan to right - else if (m_x > 0.0) - set_pan(1.0f); - - // center (mono) - else - set_pan(0.0f); - - m_defpan = m_pan; - return *this; } -//------------------------------------------------- -// mix - mix in samples from the speaker's stream -//------------------------------------------------- +sound_io_device::~sound_io_device() +{ +} -void speaker_device::mix(stream_buffer::sample_t *leftmix, stream_buffer::sample_t *rightmix, attotime start, attotime end, int expected_samples, bool suppress) +speaker_device::~speaker_device() { - // skip if no stream - if (m_mixer_stream == nullptr) - return; - - // skip if invalid range - if (start > end) - return; - - // get a view on the desired range - read_stream_view view = m_mixer_stream->update_view(start, end); - sound_assert(view.samples() >= expected_samples); - - // track maximum sample value for each 0.1s bucket - if (machine().options().speaker_report() != 0) - { - u32 samples_per_bucket = m_mixer_stream->sample_rate() / BUCKETS_PER_SECOND; - for (int sample = 0; sample < expected_samples; sample++) - { - m_current_max = std::max(m_current_max, fabsf(view.get(sample))); - if (++m_samples_this_bucket >= samples_per_bucket) - { - m_max_sample.push_back(m_current_max); - m_current_max = 0.0f; - m_samples_this_bucket = 0; - } - } - } - - // mix if sound is enabled - if (!suppress) - { - // if the speaker is hard panned to the left, send only to the left - if (m_pan == -1.0f) - for (int sample = 0; sample < expected_samples; sample++) - leftmix[sample] += view.get(sample); - - // if the speaker is hard panned to the right, send only to the right - else if (m_pan == 1.0f) - for (int sample = 0; sample < expected_samples; sample++) - rightmix[sample] += view.get(sample); - - // otherwise, send to both - else - { - const float leftpan = (m_pan <= 0.0f) ? 1.0f : 1.0f - m_pan; - const float rightpan = (m_pan >= 0.0f) ? 1.0f : 1.0f + m_pan; - - for (int sample = 0; sample < expected_samples; sample++) - { - stream_buffer::sample_t cursample = view.get(sample); - leftmix[sample] += cursample * leftpan; - rightmix[sample] += cursample * rightpan; - } - } - } } +microphone_device::~microphone_device() +{ +} -//------------------------------------------------- -// device_start - handle device startup -//------------------------------------------------- void speaker_device::device_start() { + m_stream = stream_alloc(m_positions.size(), 0, machine().sample_rate()); } +void microphone_device::device_start() +{ + m_stream = stream_alloc(0, m_positions.size(), machine().sample_rate()); +} -//------------------------------------------------- -// device_stop - cleanup and report -//------------------------------------------------- +void speaker_device::sound_stream_update(sound_stream &stream) +{ + machine().sound().output_push(m_id, stream); +} -void speaker_device::device_stop() +void microphone_device::sound_stream_update(sound_stream &stream) { - // level 1: just report if there was any clipping - // level 2: report the overall maximum, even if no clipping - // level 3: print a detailed list of all the times there was clipping - // level 4: print a detailed list of every bucket - int report = machine().options().speaker_report(); - if (report != 0) - { - m_max_sample.push_back(m_current_max); - - // determine overall maximum and number of clipped buckets - stream_buffer::sample_t overallmax = 0; - u32 clipped = 0; - for (auto &curmax : m_max_sample) - { - overallmax = std::max(overallmax, curmax); - if (curmax > stream_buffer::sample_t(1.0)) - clipped++; - } - - // levels 1 and 2 just get a summary - if (clipped != 0 || report == 2 || report == 4) - osd_printf_info("Speaker \"%s\" - max = %.5f (gain *= %.3f) - clipped in %d/%d (%d%%) buckets\n", tag(), overallmax, 1 / (overallmax ? overallmax : 1), clipped, m_max_sample.size(), clipped * 100 / m_max_sample.size()); - - // levels 3 and 4 get a full dump - if (report >= 3) - { - static char const * const s_stars = "************************************************************"; - static char const * const s_spaces = " "; - int totalstars = strlen(s_stars); - double t = 0; - if (overallmax < 1.0) - overallmax = 1.0; - int leftstars = totalstars / overallmax; - for (auto &curmax : m_max_sample) - { - if (curmax > stream_buffer::sample_t(1.0) || report == 4) - { - osd_printf_info("%6.1f: %9.5f |", t, curmax); - if (curmax == 0) - osd_printf_info("%.*s|\n", leftstars, s_spaces); - else if (curmax <= 1.0) - { - int stars = std::max(1, std::min(leftstars, int(curmax * totalstars / overallmax))); - osd_printf_info("%.*s", stars, s_stars); - int spaces = leftstars - stars; - if (spaces != 0) - osd_printf_info("%.*s", spaces, s_spaces); - osd_printf_info("|\n"); - } - else - { - int rightstars = std::max(1, std::min(totalstars, int(curmax * totalstars / overallmax)) - leftstars); - osd_printf_info("%.*s|%.*s\n", leftstars, s_stars, rightstars, s_stars); - } - } - t += 1.0 / double(BUCKETS_PER_SECOND); - } - } - } + machine().sound().input_get(m_id, stream); } diff --git a/src/emu/speaker.h b/src/emu/speaker.h index 3cb0794d998..c4fd19edca1 100644 --- a/src/emu/speaker.h +++ b/src/emu/speaker.h @@ -5,8 +5,9 @@ speaker.h Speaker output sound device. + Microphone input sound device. - Speakers have (x, y, z) coordinates in 3D space: + They have (x, y, z) coordinates in 3D space: * Observer is at position (0, 0, 0) * Positive x is to the right of the observer * Negative x is to the left of the observer @@ -15,9 +16,6 @@ * Positive z is in front of the observer * Negative z is behind the observer - Currently, MAME only considers the sign of the x coordinate (not its - magnitude), and completely ignores the y and z coordinates. - ***************************************************************************/ #ifndef MAME_EMU_SPEAKER_H @@ -32,6 +30,7 @@ // device type definition DECLARE_DEVICE_TYPE(SPEAKER, speaker_device) +DECLARE_DEVICE_TYPE(MICROPHONE, microphone_device) @@ -39,65 +38,101 @@ DECLARE_DEVICE_TYPE(SPEAKER, speaker_device) // TYPE DEFINITIONS //************************************************************************** -// ======================> speaker_device +class sound_io_device : public device_t, public device_sound_interface +{ +public: + virtual ~sound_io_device(); + + // configuration helpers + sound_io_device &set_position(u32 channel, double x, double y, double z); + sound_io_device &front_center(u32 channel = 0) { return set_position(channel, 0.0, 0.0, 1.0); } + sound_io_device &front_left(u32 channel = 0) { return set_position(channel, -0.2, 0.0, 1.0); } + sound_io_device &front_floor(u32 channel = 0) { return set_position(channel, 0.0, -0.5, 1.0); } + sound_io_device &front_right(u32 channel = 0) { return set_position(channel, 0.2, 0.0, 1.0); } + sound_io_device &rear_center(u32 channel = 0) { return set_position(channel, 0.0, 0.0, -0.5); } + sound_io_device &rear_left(u32 channel = 0) { return set_position(channel, -0.2, 0.0, -0.5); } + sound_io_device &rear_right(u32 channel = 0) { return set_position(channel, 0.2, 0.0, -0.5); } + sound_io_device &headrest_center(u32 channel = 0) { return set_position(channel, 0.0, 0.0, -0.1); } + sound_io_device &headrest_left(u32 channel = 0) { return set_position(channel, -0.1, 0.0, -0.1); } + sound_io_device &headrest_right(u32 channel = 0) { return set_position(channel, 0.1, 0.0, -0.1); } + sound_io_device &seat(u32 channel = 0) { return set_position(channel, 0.0, -0.5, 0.0); } + sound_io_device &backrest(u32 channel = 0) { return set_position(channel, 0.0, -0.2, 0.1); } + sound_io_device &front() { return front_left(0).front_right(1); } + sound_io_device &rear() { return rear_left(0).rear_right(1); } + sound_io_device &corners() { return front_left(0).front_right(1).rear_left(2).rear_right(3); } + std::array<double, 3> get_position(u32 channel) const { return m_positions[channel]; } + std::string get_position_name(u32 channel) const; + + virtual bool is_output() const = 0; + void set_id(int id) { m_id = id; } + + sound_stream *stream() const { return m_stream; } + +protected: + struct position_name_mapping { + double m_x, m_y, m_z; + const char *m_name; + }; + + static const position_name_mapping position_name_mappings[]; -class speaker_device : public device_t, public device_mixer_interface + // configuration state + std::vector<std::array<double, 3>> m_positions; + sound_stream *m_stream; + int m_id; + + sound_io_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, double x, double y, double z) + : sound_io_device(mconfig, type, tag, owner, 1) + { + set_position(0, x, y, z); + } + sound_io_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, u32 channels); // Collides with clock, but not important +}; + +class speaker_device : public sound_io_device { public: // construction/destruction speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, double x, double y, double z) - : speaker_device(mconfig, tag, owner, 0) - { - set_position(x, y, z); - } - speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0); + : sound_io_device(mconfig, SPEAKER, tag, owner, x, y, z) {} + speaker_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 channels = 1) + : sound_io_device(mconfig, SPEAKER, tag, owner, channels) {} + virtual ~speaker_device(); - // configuration helpers - speaker_device &set_position(double x, double y, double z); - speaker_device &front_center() { set_position( 0.0, 0.0, 1.0); return *this; } - speaker_device &front_left() { set_position(-0.2, 0.0, 1.0); return *this; } - speaker_device &front_floor() { set_position( 0.0, -0.5, 1.0); return *this; } - speaker_device &front_right() { set_position( 0.2, 0.0, 1.0); return *this; } - speaker_device &rear_center() { set_position( 0.0, 0.0, -0.5); return *this; } - speaker_device &rear_left() { set_position(-0.2, 0.0, -0.5); return *this; } - speaker_device &rear_right() { set_position( 0.2, 0.0, -0.5); return *this; } - speaker_device &headrest_center() { set_position( 0.0, 0.0, -0.1); return *this; } - speaker_device &headrest_left() { set_position(-0.1, 0.0, -0.1); return *this; } - speaker_device &headrest_right() { set_position( 0.1, 0.0, -0.1); return *this; } - speaker_device &seat() { set_position( 0.0, -0.5, 0.0); return *this; } - speaker_device &backrest() { set_position( 0.0, -0.2, 0.1); return *this; } - - // internally for use by the sound system - void mix(stream_buffer::sample_t *leftmix, stream_buffer::sample_t *rightmix, attotime start, attotime end, int expected_samples, bool suppress); - - // user panning configuration - void set_pan(float pan) { m_pan = std::clamp(pan, -1.0f, 1.0f); } - float pan() { return m_pan; } - float defpan() { return m_defpan; } + virtual bool is_output() const override { return true; } protected: + // device-level overrides virtual void device_start() override ATTR_COLD; - virtual void device_stop() override ATTR_COLD; - // configuration state - double m_x; - double m_y; - double m_z; - float m_pan; - float m_defpan; - - // internal state - static constexpr int BUCKETS_PER_SECOND = 10; - std::vector<stream_buffer::sample_t> m_max_sample; - stream_buffer::sample_t m_current_max; - u32 m_samples_this_bucket; + virtual void sound_stream_update(sound_stream &stream) override; }; +class microphone_device : public sound_io_device +{ +public: + // construction/destruction + microphone_device(const machine_config &mconfig, const char *tag, device_t *owner, double x, double y, double z) + : sound_io_device(mconfig, MICROPHONE, tag, owner, x, y, z) {} + microphone_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 channels = 1) + : sound_io_device(mconfig, MICROPHONE, tag, owner, channels) {} + + virtual ~microphone_device(); + + virtual bool is_output() const override { return false; } + +protected: + + // device-level overrides + virtual void device_start() override ATTR_COLD; + + virtual void sound_stream_update(sound_stream &stream) override; +}; -// speaker device iterator using speaker_device_enumerator = device_type_enumerator<speaker_device>; +using microphone_device_enumerator = device_type_enumerator<microphone_device>; #endif // MAME_EMU_SPEAKER_H diff --git a/src/frontend/mame/infoxml.cpp b/src/frontend/mame/infoxml.cpp index ee5c51d3a21..1318fa12fda 100644 --- a/src/frontend/mame/infoxml.cpp +++ b/src/frontend/mame/infoxml.cpp @@ -1257,7 +1257,7 @@ void output_chips(std::ostream &out, device_t &device, const char *root_tag) // iterate over sound devices for (device_sound_interface &sound : sound_interface_enumerator(device)) { - if (strcmp(sound.device().tag(), device.tag()) != 0 && sound.issound()) + if (strcmp(sound.device().tag(), device.tag()) != 0) { std::string newtag(sound.device().tag()), oldtag(":"); newtag = newtag.substr(newtag.find(oldtag.append(root_tag)) + oldtag.length()); diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index 93616f825f6..331f7ce8603 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -2068,16 +2068,13 @@ void lua_engine::initialize() return filename ? sm.start_recording(filename) : sm.start_recording(); }; sound_type["stop_recording"] = &sound_manager::stop_recording; - sound_type["get_samples"] = - [] (sound_manager &sm, sol::this_state s) - { - luaL_Buffer buff; - s32 const count = sm.sample_count() * 2 * 2; // 2 channels, 2 bytes per sample - s16 *const ptr = (s16 *)luaL_buffinitsize(s, &buff, count); - sm.samples(ptr); - luaL_pushresultsize(&buff, count); - return sol::make_reference(s, sol::stack_reference(s, -1)); - }; + // sound_type["get_samples"] = + // [] (sound_manager &sm, sol::this_state s) + // { + // std::vector<s16> samples = sm.samples(); + // lua_pushlstring(s, (const char *)samples.data(), samples.size()*2); + // return sol::make_reference(s, sol::stack_reference(s, -1)); + // }; sound_type["muted"] = sol::property(&sound_manager::muted); sound_type["ui_mute"] = sol::property( static_cast<bool (sound_manager::*)() const>(&sound_manager::ui_mute), @@ -2088,9 +2085,6 @@ void lua_engine::initialize() sound_type["system_mute"] = sol::property( static_cast<bool (sound_manager::*)() const>(&sound_manager::system_mute), static_cast<void (sound_manager::*)(bool)>(&sound_manager::system_mute)); - sound_type["attenuation"] = sol::property( - &sound_manager::attenuation, - &sound_manager::set_attenuation); sound_type["recording"] = sol::property(&sound_manager::is_recording); diff --git a/src/frontend/mame/ui/audio_effect_eq.cpp b/src/frontend/mame/ui/audio_effect_eq.cpp new file mode 100644 index 00000000000..d758480ad00 --- /dev/null +++ b/src/frontend/mame/ui/audio_effect_eq.cpp @@ -0,0 +1,365 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/********************************************************************* + + ui/audio_effect_eq.cpp + + Equalizer configuration + +*********************************************************************/ + +#include "emu.h" +#include "ui/audio_effect_eq.h" +#include "audio_effects/aeffect.h" +#include "audio_effects/eq.h" + +#include "ui/ui.h" + +namespace ui { + +const u32 menu_audio_effect_eq::freqs[3][43] = { + { 0, 32, 36, 40, 45, 50, 56, 63, 70, 80, 90, 100, 110, 125, 140, 160, 180, 200, 225, 250, 280, 315, 355, 400, 450, 500, 560, 630, 700, 800, 900, 1000, 1100, 1200, 1400, 1600, 1800, 2000 }, + { 0, 100, 110, 125, 140, 160, 180, 200, 225, 250, 280, 315, 355, 400, 450, 500, 560, 630, 700, 800, 900, 1000, 1100, 1200, 1400, 1600, 1800, 2000, 2200, 2500, 2800, 3200, 3600, 4000, 4500, 5000, 5600, 6300, 7000, 8000, 9000, 10000 }, + { 0, 500, 560, 630, 700, 800, 900, 1000, 1100, 1200, 1400, 1600, 1800, 2000, 2200, 2500, 2800, 3200, 3600, 4000, 4500, 5000, 5600, 6300, 7000, 8000, 9000, 10000, 11000, 12000, 14000, 16000 }, +}; + +menu_audio_effect_eq::menu_audio_effect_eq(mame_ui_manager &mui, render_container &container, u16 chain, u16 entry, audio_effect *effect) + : menu(mui, container) +{ + m_chain = chain; + m_entry = entry; + m_effect = static_cast<audio_effect_eq *>(effect); + set_heading(util::string_format("%s #%u", chain == 0xffff ? _("Default") : machine().sound().effect_chain_tag(chain), entry+1)); + set_process_flags(PROCESS_LR_REPEAT | PROCESS_LR_ALWAYS); +} + +menu_audio_effect_eq::~menu_audio_effect_eq() +{ +} + +std::pair<u32, u32> menu_audio_effect_eq::find_f(u32 band) const +{ + u32 variant = band == 0 ? 0 : band < 4 ? 1 : 2; + u32 bi = 0; + s32 dt = 40000; + s32 f = s32(m_effect->f(band) + 0.5); + for(u32 index = 1; freqs[variant][index]; index++) { + s32 d1 = f - freqs[variant][index]; + if(d1 < 0) + d1 = -d1; + if(d1 < dt) { + dt = d1; + bi = index; + } + } + return std::make_pair(variant, bi); +} + +void menu_audio_effect_eq::change_f(u32 band, s32 direction) +{ + auto [variant, bi] = find_f(band); + bi += direction; + if(!freqs[variant][bi]) + bi -= direction; + m_effect->set_f(band, freqs[variant][bi]); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); +} + +bool menu_audio_effect_eq::handle(event const *ev) +{ + if(!ev) + return false; + + u32 band = (uintptr_t(ev->itemref)) >> 16; + u32 entry = (uintptr_t(ev->itemref)) & 0xffff; + + switch(ev->iptkey) { + case IPT_UI_LEFT: { + switch(entry) { + case MODE: + m_effect->set_mode(0); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case SHELF: + if(band == 0) + m_effect->set_low_shelf(true); + else + m_effect->set_high_shelf(true); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F: + change_f(band, -1); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q: { + float q = m_effect->q(band); + q = (int(q*10 + 0.5) - 1) / 10.0; + if(q < 0.1) + q = 0.1; + m_effect->set_q(band, q); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + + case DB: { + float db = m_effect->db(band); + db -= 1; + if(db < -12) + db = -12; + m_effect->set_db(band, db); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + } + break; + } + + case IPT_UI_RIGHT: { + switch(entry) { + case MODE: + m_effect->set_mode(1); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case SHELF: + if(band == 0) + m_effect->set_low_shelf(false); + else + m_effect->set_high_shelf(false); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F: + change_f(band, +1); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q: { + float q = m_effect->q(band); + q = (int(q*10 + 0.5) + 1) / 10.0; + if(q > 12) + q = 12; + m_effect->set_q(band, q); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + + case DB: { + float db = m_effect->db(band); + db += 1; + if(db > 12) + db = 12; + m_effect->set_db(band, db); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + } + break; + } + case IPT_UI_CLEAR: { + switch(entry) { + case MODE: + m_effect->reset_mode(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case SHELF: + if(band == 0) + m_effect->reset_low_shelf(); + else + m_effect->reset_high_shelf(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F: + m_effect->reset_f(band); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q: { + m_effect->reset_q(band); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + + case DB: { + m_effect->reset_db(band); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + } + break; + } + } + return false; +} + +std::string menu_audio_effect_eq::format_f(float f) +{ + return f >= 1000 ? util::string_format("%.1fkHz", f/1000) : util::string_format("%.0fHz", f); +} + +std::string menu_audio_effect_eq::format_q(float q) +{ + return util::string_format("%.1f", q); +} + +std::string menu_audio_effect_eq::format_db(float db) +{ + return util::string_format("%+.0fdB", db); +} + +u32 menu_audio_effect_eq::flag_mode() const +{ + u32 flag = 0; + if(!m_effect->isset_mode()) + flag |= FLAG_INVERT; + if(m_effect->mode() == 1) + flag |= FLAG_LEFT_ARROW; + if(m_effect->mode() == 0) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_eq::flag_low_shelf() const +{ + u32 flag = 0; + if(!m_effect->isset_low_shelf()) + flag |= FLAG_INVERT; + if(m_effect->low_shelf()) + flag |= FLAG_RIGHT_ARROW; + else + flag |= FLAG_LEFT_ARROW; + return flag; +} + +u32 menu_audio_effect_eq::flag_high_shelf() const +{ + u32 flag = 0; + if(!m_effect->isset_high_shelf()) + flag |= FLAG_INVERT; + if(m_effect->high_shelf()) + flag |= FLAG_RIGHT_ARROW; + else + flag |= FLAG_LEFT_ARROW; + return flag; +} + +u32 menu_audio_effect_eq::flag_f(u32 band) const +{ + u32 flag = 0; + if(!m_effect->isset_f(band)) + flag |= FLAG_INVERT; + auto [variant, bi] = find_f(band); + if(freqs[variant][bi-1]) + flag |= FLAG_LEFT_ARROW; + if(freqs[variant][bi+1]) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_eq::flag_q(u32 band) const +{ + u32 flag = 0; + if(!m_effect->isset_q(band)) + flag |= FLAG_INVERT; + float q = m_effect->q(band); + if(q < 10) + flag |= FLAG_LEFT_ARROW; + if(q > 0.1) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_eq::flag_db(u32 band) const +{ + u32 flag = 0; + if(!m_effect->isset_db(band)) + flag |= FLAG_INVERT; + float db = m_effect->db(band); + if(db < 12) + flag |= FLAG_LEFT_ARROW; + if(db > -12) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +void menu_audio_effect_eq::populate() +{ + item_append(_(audio_effect::effect_names[audio_effect::EQ]), FLAG_UI_HEADING | FLAG_DISABLE, nullptr); + item_append(_("Mode"), m_effect->mode() ? _("5-Band EQ") : _("Bypass"), flag_mode(), (void *)MODE); + item_append(_("Low band mode"), m_effect->low_shelf() ? _("Shelf") : _("Peak"), flag_low_shelf(), (void *)uintptr_t(SHELF | (0 << 16))); + item_append(_("Low band freq."), format_f(m_effect->f(0)), flag_f(0), (void *)uintptr_t(F | (0 << 16))); + if(!m_effect->low_shelf()) + item_append(_("Low band Q"), format_q(m_effect->q(0)), flag_q(0), (void *)uintptr_t(Q | (0 << 16))); + item_append(_("Low band dB"), format_db(m_effect->db(0)), flag_db(0), (void *)uintptr_t(DB | (0 << 16))); + + item_append(_("Lo mid band freq."), format_f(m_effect->f(1)), flag_f(1), (void *)uintptr_t(F | (1 << 16))); + item_append(_("Lo mid band Q"), format_q(m_effect->q(1)), flag_q(1), (void *)uintptr_t(Q | (1 << 16))); + item_append(_("Lo mid band dB"), format_db(m_effect->db(1)), flag_db(1), (void *)uintptr_t(DB | (1 << 16))); + + item_append(_("Mid band freq."), format_f(m_effect->f(2)), flag_f(2), (void *)uintptr_t(F | (2 << 16))); + item_append(_("Mid band Q"), format_q(m_effect->q(2)), flag_q(2), (void *)uintptr_t(Q | (2 << 16))); + item_append(_("Mid band dB"), format_db(m_effect->db(2)), flag_db(2), (void *)uintptr_t(DB | (2 << 16))); + + item_append(_("Hi mid band freq."), format_f(m_effect->f(3)), flag_f(3), (void *)uintptr_t(F | (3 << 16))); + item_append(_("Hi mid band Q"), format_q(m_effect->q(3)), flag_q(3), (void *)uintptr_t(Q | (3 << 16))); + item_append(_("Hi mid band dB"), format_db(m_effect->db(3)), flag_db(3), (void *)uintptr_t(DB | (3 << 16))); + + + item_append(_("High band mode"), m_effect->high_shelf() ? _("Shelf") : _("Peak"), flag_high_shelf(), (void *)uintptr_t(SHELF | (4 << 16))); + item_append(_("High band freq."), format_f(m_effect->f(4)), flag_f(4), (void *)uintptr_t(F | (4 << 16))); + if(!m_effect->high_shelf()) + item_append(_("High band Q"), format_q(m_effect->q(4)), flag_q(4), (void *)uintptr_t(Q | (4 << 16))); + item_append(_("High band dB"), format_db(m_effect->db(4)), flag_db(4), (void *)uintptr_t(DB | (4 << 16))); + item_append(menu_item_type::SEPARATOR); +} + +void menu_audio_effect_eq::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); +} + +void menu_audio_effect_eq::custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +{ +} + +void menu_audio_effect_eq::menu_activated() +{ + // scripts or the other form of the menu could have changed something in the mean time + reset(reset_options::REMEMBER_POSITION); +} + +void menu_audio_effect_eq::menu_deactivated() +{ +} + +} diff --git a/src/frontend/mame/ui/audio_effect_eq.h b/src/frontend/mame/ui/audio_effect_eq.h new file mode 100644 index 00000000000..c11d4f3996c --- /dev/null +++ b/src/frontend/mame/ui/audio_effect_eq.h @@ -0,0 +1,61 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + ui/audio_effect_eq.h + + Equalizer configuration + +***************************************************************************/ + +#ifndef MAME_FRONTEND_UI_AUDIO_EFFECT_EQ_H +#define MAME_FRONTEND_UI_AUDIO_EFFECT_EQ_H + +#pragma once + +#include "ui/menu.h" + +class audio_effect_eq; + +namespace ui { + +class menu_audio_effect_eq : public menu +{ +public: + menu_audio_effect_eq(mame_ui_manager &mui, render_container &container, u16 chain, u16 entry, audio_effect *effect); + virtual ~menu_audio_effect_eq() override; + +protected: + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override; + virtual void custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; + virtual void menu_activated() override; + virtual void menu_deactivated() override; + +private: + enum { MODE = 1, SHELF, F, Q, DB }; + + static const u32 freqs[3][43]; + + u16 m_chain, m_entry; + audio_effect_eq *m_effect; + + virtual void populate() override; + virtual bool handle(event const *ev) override; + + static std::string format_f(float f); + static std::string format_q(float q); + static std::string format_db(float db); + u32 flag_mode() const; + u32 flag_low_shelf() const; + u32 flag_high_shelf() const; + u32 flag_f(u32 band) const; + u32 flag_q(u32 band) const; + u32 flag_db(u32 band) const; + + std::pair<u32, u32> find_f(u32 band) const; + void change_f(u32 band, s32 direction); +}; + +} // namespace ui + +#endif // MAME_FRONTEND_UI_AUDIO_EFFECT_EQ_H diff --git a/src/frontend/mame/ui/audio_effect_filter.cpp b/src/frontend/mame/ui/audio_effect_filter.cpp new file mode 100644 index 00000000000..9b6a90df980 --- /dev/null +++ b/src/frontend/mame/ui/audio_effect_filter.cpp @@ -0,0 +1,351 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/********************************************************************* + + ui/audio_effect_filter.cpp + + Filter configuration + +*********************************************************************/ + +#include "emu.h" +#include "ui/audio_effect_filter.h" +#include "audio_effects/aeffect.h" +#include "audio_effects/filter.h" + +#include "ui/ui.h" + +namespace ui { +const u32 menu_audio_effect_filter::freqs[2][38] = { + { 0, 20, 22, 24, 26, 28, 30, 32, 36, 40, 45, 50, 56, 63, 70, 80, 90, 100, 110, 125, 140, 160, 180, 200, 225, 250, 280, 315, 355, 400, 450, 500, 560, 630, 700, 800, 900, 1000 }, + { 0, 1000, 1100, 1200, 1400, 1600, 1800, 2000, 2200, 2500, 2800, 3200, 3600, 4000, 4500, 5000, 5600, 6300, 7000, 8000, 9000, 10000, 11000, 12000, 14000, 16000, 18000, 20000 }, +}; + +menu_audio_effect_filter::menu_audio_effect_filter(mame_ui_manager &mui, render_container &container, u16 chain, u16 entry, audio_effect *effect) + : menu(mui, container) +{ + m_chain = chain; + m_entry = entry; + m_effect = static_cast<audio_effect_filter *>(effect); + set_heading(util::string_format("%s #%u", chain == 0xffff ? _("Default") : machine().sound().effect_chain_tag(chain), entry+1)); + set_process_flags(PROCESS_LR_REPEAT | PROCESS_LR_ALWAYS); +} + +menu_audio_effect_filter::~menu_audio_effect_filter() +{ +} + +std::pair<u32, u32> menu_audio_effect_filter::find_f(bool lp) const +{ + u32 variant = lp ? 1 : 0; + u32 bi = 0; + s32 dt = 40000; + s32 f = s32((lp ? m_effect->fl() : m_effect->fh()) + 0.5); + for(u32 index = 1; freqs[variant][index]; index++) { + s32 d1 = f - freqs[variant][index]; + if(d1 < 0) + d1 = -d1; + if(d1 < dt) { + dt = d1; + bi = index; + } + } + return std::make_pair(variant, bi); +} + +void menu_audio_effect_filter::change_f(bool lp, s32 direction) +{ + auto [variant, bi] = find_f(lp); + bi += direction; + if(!freqs[variant][bi]) + bi -= direction; + if(lp) + m_effect->set_fl(freqs[variant][bi]); + else + m_effect->set_fh(freqs[variant][bi]); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); +} + +bool menu_audio_effect_filter::handle(event const *ev) +{ + if(!ev) + return false; + + switch(ev->iptkey) { + case IPT_UI_LEFT: { + switch(uintptr_t(ev->itemref)) { + case ACTIVE | HP: + m_effect->set_highpass_active(false); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F | HP: + change_f(false, -1); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q | HP: { + float q = m_effect->qh(); + q = (int(q*10 + 0.5) - 1) / 10.0; + if(q < 0.1) + q = 0.1; + m_effect->set_qh(q); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + + case ACTIVE | LP: + m_effect->set_lowpass_active(false); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F | LP: + change_f(true, -1); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q | LP: { + float q = m_effect->ql(); + q = (int(q*10 + 0.5) - 1) / 10.0; + if(q < 0.1) + q = 0.1; + m_effect->set_ql(q); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + } + break; + } + + case IPT_UI_RIGHT: { + switch(uintptr_t(ev->itemref)) { + case ACTIVE | HP: + m_effect->set_highpass_active(true); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F | HP: + change_f(false, +1); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q | HP: { + float q = m_effect->qh(); + q = (int(q*10 + 0.5) + 1) / 10.0; + if(q > 10) + q = 10; + m_effect->set_qh(q); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + + case ACTIVE | LP: + m_effect->set_lowpass_active(true); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F | LP: + change_f(true, +1); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q | LP: { + float q = m_effect->ql(); + q = (int(q*10 + 0.5) + 1) / 10.0; + if(q > 10) + q = 10; + m_effect->set_ql(q); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + } + break; + } + + case IPT_UI_CLEAR: { + switch(uintptr_t(ev->itemref)) { + case ACTIVE | HP: + m_effect->reset_highpass_active(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F | HP: + m_effect->reset_fh(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q | HP: + m_effect->reset_qh(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case ACTIVE | LP: + m_effect->reset_lowpass_active(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case F | LP: + m_effect->reset_fl(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + + case Q | LP: + m_effect->reset_ql(); + if(m_chain == 0xffff) + machine().sound().default_effect_changed(m_entry); + reset(reset_options::REMEMBER_POSITION); + return true; + } + break; + } + } + return false; +} + +std::string menu_audio_effect_filter::format_f(float f) +{ + return f >= 1000 ? util::string_format("%.1fkHz", f/1000) : util::string_format("%.0fHz", f); +} + +std::string menu_audio_effect_filter::format_q(float q) +{ + return util::string_format("%.1f", q); +} + +u32 menu_audio_effect_filter::flag_highpass_active() const +{ + u32 flag = 0; + if(!m_effect->isset_highpass_active()) + flag |= FLAG_INVERT; + if(m_effect->highpass_active()) + flag |= FLAG_LEFT_ARROW; + else + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_filter::flag_fh() const +{ + u32 flag = 0; + if(!m_effect->isset_fh()) + flag |= FLAG_INVERT; + auto [variant, bi] = find_f(false); + if(freqs[variant][bi-1]) + flag |= FLAG_LEFT_ARROW; + if(freqs[variant][bi+1]) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_filter::flag_qh() const +{ + u32 flag = 0; + if(!m_effect->isset_qh()) + flag |= FLAG_INVERT; + float q = m_effect->qh(); + if(q > 0.1) + flag |= FLAG_LEFT_ARROW; + if(q < 10) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_filter::flag_lowpass_active() const +{ + u32 flag = 0; + if(!m_effect->isset_lowpass_active()) + flag |= FLAG_INVERT; + if(m_effect->lowpass_active()) + flag |= FLAG_LEFT_ARROW; + else + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_filter::flag_fl() const +{ + u32 flag = 0; + if(!m_effect->isset_fl()) + flag |= FLAG_INVERT; + auto [variant, bi] = find_f(true); + if(freqs[variant][bi-1]) + flag |= FLAG_LEFT_ARROW; + if(freqs[variant][bi+1]) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +u32 menu_audio_effect_filter::flag_ql() const +{ + u32 flag = 0; + if(!m_effect->isset_ql()) + flag |= FLAG_INVERT; + float q = m_effect->ql(); + if(q > 0.1) + flag |= FLAG_LEFT_ARROW; + if(q < 10) + flag |= FLAG_RIGHT_ARROW; + return flag; +} + +void menu_audio_effect_filter::populate() +{ + item_append(_(audio_effect::effect_names[audio_effect::FILTER]), FLAG_UI_HEADING | FLAG_DISABLE, nullptr); + item_append(_("Highpass (DC removal)"), m_effect->highpass_active() ? _("Active") : _("Bypass"), flag_highpass_active(), (void *)(ACTIVE | HP)); + item_append(_("Highpass cutoff"), format_f(m_effect->fh()), flag_fh(), (void *)(F | HP)); + item_append(_("Highpass Q"), format_q(m_effect->qh()), flag_qh(), (void *)(Q | HP)); + + item_append(_("Lowpass"), m_effect->lowpass_active() ? _("Active") : _("Bypass"), flag_lowpass_active(), (void *)(ACTIVE | LP)); + item_append(_("Lowpass cutoff"), format_f(m_effect->fl()), flag_fl(), (void *)(F | LP)); + item_append(_("Lowpass Q"), format_q(m_effect->ql()), flag_ql(), (void *)(Q | LP)); + + item_append(menu_item_type::SEPARATOR); +} + +void menu_audio_effect_filter::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); +} + +void menu_audio_effect_filter::custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +{ +} + +void menu_audio_effect_filter::menu_activated() +{ + // scripts or the other form of the menu could have changed something in the mean time + reset(reset_options::REMEMBER_POSITION); +} + +void menu_audio_effect_filter::menu_deactivated() +{ +} + +} diff --git a/src/frontend/mame/ui/audio_effect_filter.h b/src/frontend/mame/ui/audio_effect_filter.h new file mode 100644 index 00000000000..7a4d84e4122 --- /dev/null +++ b/src/frontend/mame/ui/audio_effect_filter.h @@ -0,0 +1,60 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + ui/audio_effect_filter.h + + Filter configuration + +***************************************************************************/ + +#ifndef MAME_FRONTEND_UI_AUDIO_EFFECT_FILTER_H +#define MAME_FRONTEND_UI_AUDIO_EFFECT_FILTER_H + +#pragma once + +#include "ui/menu.h" + +class audio_effect_filter; + +namespace ui { + +class menu_audio_effect_filter : public menu +{ +public: + menu_audio_effect_filter(mame_ui_manager &mui, render_container &container, u16 chain, u16 entry, audio_effect *effect); + virtual ~menu_audio_effect_filter() override; + +protected: + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override; + virtual void custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; + virtual void menu_activated() override; + virtual void menu_deactivated() override; + +private: + enum { ACTIVE = 1, F = 2, Q = 3, HP = 0, LP = 8 }; + + static const u32 freqs[2][38]; + + u16 m_chain, m_entry; + audio_effect_filter *m_effect; + + virtual void populate() override; + virtual bool handle(event const *ev) override; + + static std::string format_f(float f); + static std::string format_q(float q); + u32 flag_highpass_active() const; + u32 flag_fh() const; + u32 flag_qh() const; + u32 flag_lowpass_active() const; + u32 flag_fl() const; + u32 flag_ql() const; + + std::pair<u32, u32> find_f(bool lp) const; + void change_f(bool lp, s32 direction); +}; + +} // namespace ui + +#endif // MAME_FRONTEND_UI_AUDIO_EFFECT_FILTER_H diff --git a/src/frontend/mame/ui/audioeffects.cpp b/src/frontend/mame/ui/audioeffects.cpp new file mode 100644 index 00000000000..6ac84e22954 --- /dev/null +++ b/src/frontend/mame/ui/audioeffects.cpp @@ -0,0 +1,95 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/********************************************************************* + + ui/audioeffects.cpp + + Audio effects control + +*********************************************************************/ + +#include "emu.h" +#include "ui/audioeffects.h" +#include "audio_effects/aeffect.h" + +#include "audio_effect_eq.h" +#include "audio_effect_filter.h" + +#include "ui/ui.h" + +#include "osdepend.h" +#include "speaker.h" + +namespace ui { + +menu_audio_effects::menu_audio_effects(mame_ui_manager &mui, render_container &container) + : menu(mui, container) +{ + set_heading(_("Audio Effects")); +} + +menu_audio_effects::~menu_audio_effects() +{ +} + +bool menu_audio_effects::handle(event const *ev) +{ + if(ev && (ev->iptkey == IPT_UI_SELECT)) { + u16 chain = (uintptr_t(ev->itemref)) >> 16; + u16 entry = (uintptr_t(ev->itemref)) & 0xffff; + audio_effect *eff = chain == 0xffff ? machine().sound().default_effect_chain()[entry] : machine().sound().effect_chain(chain)[entry]; + switch(eff->type()) { + case audio_effect::FILTER: + menu::stack_push<menu_audio_effect_filter>(ui(), container(), chain, entry, eff); + break; + + case audio_effect::EQ: + menu::stack_push<menu_audio_effect_eq>(ui(), container(), chain, entry, eff); + break; + } + return true; + } + + return false; +} + + +void menu_audio_effects::populate() +{ + auto &sound = machine().sound(); + for(s32 chain = 0; chain != sound.effect_chains(); chain++) { + std::string tag = sound.effect_chain_tag(chain); + item_append(tag, FLAG_UI_HEADING | FLAG_DISABLE, nullptr); + auto eff = sound.effect_chain(chain); + for(u32 e = 0; e != eff.size(); e++) + item_append(_(audio_effect::effect_names[eff[e]->type()]), 0, (void *)intptr_t((chain << 16) | e)); + } + item_append(_("Default"), FLAG_UI_HEADING | FLAG_DISABLE, nullptr); + auto eff = sound.default_effect_chain(); + for(u32 e = 0; e != eff.size(); e++) + item_append(_(audio_effect::effect_names[eff[e]->type()]), 0, (void *)intptr_t((0xffff << 16) | e)); + item_append(menu_item_type::SEPARATOR); +} + +void menu_audio_effects::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); +} + +void menu_audio_effects::custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +{ +} + +void menu_audio_effects::menu_activated() +{ + // scripts or the other form of the menu could have changed something in the mean time + reset(reset_options::REMEMBER_POSITION); +} + +void menu_audio_effects::menu_deactivated() +{ +} + + +} // namespace ui + diff --git a/src/frontend/mame/ui/audioeffects.h b/src/frontend/mame/ui/audioeffects.h new file mode 100644 index 00000000000..1ee15da82f9 --- /dev/null +++ b/src/frontend/mame/ui/audioeffects.h @@ -0,0 +1,40 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + ui/audioeffects.h + + Audio effects control + +***************************************************************************/ + +#ifndef MAME_FRONTEND_UI_AUDIOEFFECTS_H +#define MAME_FRONTEND_UI_AUDIOEFFECTS_H + +#pragma once + +#include "ui/menu.h" + + +namespace ui { + +class menu_audio_effects : public menu +{ +public: + menu_audio_effects(mame_ui_manager &mui, render_container &container); + virtual ~menu_audio_effects() override; + +protected: + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override; + virtual void custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; + virtual void menu_activated() override; + virtual void menu_deactivated() override; + +private: + virtual void populate() override; + virtual bool handle(event const *ev) override; +}; + +} // namespace ui + +#endif // MAME_FRONTEND_UI_AUDIOEFFECTS_H diff --git a/src/frontend/mame/ui/audiomix.cpp b/src/frontend/mame/ui/audiomix.cpp new file mode 100644 index 00000000000..361cbe114e5 --- /dev/null +++ b/src/frontend/mame/ui/audiomix.cpp @@ -0,0 +1,1069 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/********************************************************************* + + ui/audiomix.cpp + + Audio mixing/mapping control + +*********************************************************************/ + +#include "emu.h" +#include "ui/audiomix.h" + +#include "ui/ui.h" + +#include "osdepend.h" +#include "speaker.h" + +namespace ui { + +menu_audio_mixer::menu_audio_mixer(mame_ui_manager &mui, render_container &container) + : menu(mui, container) +{ + set_heading(_("Audio Mixer")); + m_generation = 0; + m_current_selection.m_maptype = MT_UNDEFINED; + m_current_selection.m_dev = nullptr; + m_current_selection.m_guest_channel = 0; + m_current_selection.m_node = 0; + m_current_selection.m_node_channel = 0; + m_current_group = GRP_NODE; + + set_process_flags(PROCESS_LR_ALWAYS); +} + +menu_audio_mixer::~menu_audio_mixer() +{ +} + +bool menu_audio_mixer::handle(event const *ev) +{ + if(!ev) { + if(m_generation != machine().sound().get_osd_info().m_generation) { + reset(reset_options::REMEMBER_POSITION); + return true; + } + return false; + } + + switch(ev->iptkey) { + case IPT_UI_MIXER_ADD_FULL: + if(m_current_selection.m_maptype == MT_INTERNAL) + return false; + + if(full_mapping_available(m_current_selection.m_dev, 0)) { + m_current_selection.m_node = 0; + machine().sound().config_add_sound_io_connection_default(m_current_selection.m_dev, 0.0); + + } else { + uint32_t node = find_next_available_node(m_current_selection.m_dev, 0); + if(node == 0xffffffff) + return false; + m_current_selection.m_node = node; + machine().sound().config_add_sound_io_connection_node(m_current_selection.m_dev, find_node_name(node), 0.0); + } + + m_current_selection.m_maptype = MT_FULL; + m_current_selection.m_guest_channel = 0; + m_current_selection.m_node_channel = 0; + m_current_selection.m_db = 0.0; + m_generation --; + return true; + + case IPT_UI_MIXER_ADD_CHANNEL: { + if(m_current_selection.m_maptype == MT_INTERNAL) + return false; + + // Find a possible triplet, any triplet + const auto &info = machine().sound().get_osd_info(); + u32 guest_channel; + u32 node_index, node_id; + u32 node_channel; + u32 default_osd_id = m_current_selection.m_dev->is_output() ? info.m_default_sink : info.m_default_source; + for(node_index = default_osd_id == 0 ? 0 : 0xffffffff; node_index != info.m_nodes.size(); node_index++) { + node_id = node_index == 0xffffffff ? 0 : info.m_nodes[node_index].m_id; + u32 guest_channel_count = m_current_selection.m_dev->outputs(); + u32 node_channel_count = 0; + if(node_index == 0xffffffff) { + for(u32 i = 0; i != info.m_nodes.size(); i++) + if(info.m_nodes[i].m_id == default_osd_id) { + node_channel_count = m_current_selection.m_dev->is_output() ? info.m_nodes[i].m_sinks : info.m_nodes[i].m_sources; + break; + } + } else + node_channel_count = m_current_selection.m_dev->is_output() ? info.m_nodes[node_index].m_sinks : info.m_nodes[node_index].m_sources; + + for(guest_channel = 0; guest_channel != guest_channel_count; guest_channel ++) + for(node_channel = 0; node_channel != node_channel_count; node_channel ++) + if(channel_mapping_available(m_current_selection.m_dev, guest_channel, node_id, node_channel)) + goto found; + } + return false; + + found: + if(node_id) + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, guest_channel, info.m_nodes[node_index].name(), node_channel, 0.0); + else + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, guest_channel, node_channel, 0.0); + m_current_selection.m_maptype = MT_CHANNEL; + m_current_selection.m_guest_channel = guest_channel; + m_current_selection.m_node = node_id; + m_current_selection.m_node_channel = node_channel; + m_current_selection.m_db = 0.0; + m_generation --; + return true; + } + + case IPT_UI_CLEAR: { + if(m_current_selection.m_maptype == MT_NONE || m_current_selection.m_maptype == MT_INTERNAL) + return false; + + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_selection.m_node == 0) + machine().sound().config_remove_sound_io_connection_default(m_current_selection.m_dev); + else + machine().sound().config_remove_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node)); + } else { + if(m_current_selection.m_node == 0) + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + else + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel); + } + + // Find where the selection was + uint32_t cursel_index = 0; + for(uint32_t i = 0; i != m_selections.size(); i++) + if(m_selections[i] == m_current_selection) { + cursel_index = i; + break; + } + + // If the next item exists and is the same speaker, go there (visually, the cursor stays on the same line) + // Otherwise if the previous item exists and is the same speaker, go there (visually, the cursor goes up once) + // Otherwise create a MT_NONE, because one is going to appear at the same place + + if(cursel_index + 1 < m_selections.size() && m_selections[cursel_index+1].m_dev == m_current_selection.m_dev) + m_current_selection = m_selections[cursel_index+1]; + else if(cursel_index != 0 && m_selections[cursel_index-1].m_dev == m_current_selection.m_dev) + m_current_selection = m_selections[cursel_index-1]; + else { + m_current_selection.m_maptype = MT_NONE; + m_current_selection.m_guest_channel = 0; + m_current_selection.m_node = 0; + m_current_selection.m_node_channel = 0; + m_current_selection.m_db = 0.0; + } + + m_generation --; + return true; + } + + case IPT_UI_UP: + case IPT_UI_DOWN: + if(!ev->itemref) { + m_current_selection.m_maptype = MT_INTERNAL; + m_generation --; + return true; + } + + m_current_selection = *(select_entry *)(ev->itemref); + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_group == GRP_GUEST_CHANNEL || m_current_group == GRP_NODE_CHANNEL) + m_current_group = GRP_NODE; + } + m_generation --; + return true; + + case IPT_UI_NEXT_GROUP: + if(m_current_selection.m_maptype == MT_NONE || m_current_selection.m_maptype == MT_INTERNAL) + return false; + + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_group == GRP_NODE) + m_current_group = GRP_DB; + else + m_current_group = GRP_NODE; + + } else if(m_current_selection.m_maptype == MT_CHANNEL) { + if(m_current_group == GRP_NODE) + m_current_group = GRP_NODE_CHANNEL; + else if(m_current_group == GRP_NODE_CHANNEL) + m_current_group = GRP_DB; + else if(m_current_group == GRP_DB) + m_current_group = GRP_GUEST_CHANNEL; + else + m_current_group = GRP_NODE; + } + m_generation --; + return true; + + case IPT_UI_PREV_GROUP: + if(m_current_selection.m_maptype == MT_NONE || m_current_selection.m_maptype == MT_INTERNAL) + return false; + + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_group == GRP_NODE) + m_current_group = GRP_DB; + else + m_current_group = GRP_NODE; + + } else if(m_current_selection.m_maptype == MT_CHANNEL) { + if(m_current_group == GRP_NODE) + m_current_group = GRP_GUEST_CHANNEL; + else if(m_current_group == GRP_GUEST_CHANNEL) + m_current_group = GRP_DB; + else if(m_current_group == GRP_DB) + m_current_group = GRP_NODE_CHANNEL; + else + m_current_group = GRP_NODE; + } + m_generation --; + return true; + + case IPT_UI_LEFT: { + if(m_current_selection.m_maptype == MT_NONE || m_current_selection.m_maptype == MT_INTERNAL) + return false; + + switch(m_current_group) { + case GRP_NODE: { + if(m_current_selection.m_maptype == MT_FULL) { + uint32_t prev_node = m_current_selection.m_node; + uint32_t next_node = find_previous_available_node(m_current_selection.m_dev, prev_node); + if(next_node != 0xffffffff) { + m_current_selection.m_node = next_node; + if(prev_node) + machine().sound().config_remove_sound_io_connection_node(m_current_selection.m_dev, find_node_name(prev_node)); + else + machine().sound().config_remove_sound_io_connection_default(m_current_selection.m_dev); + if(next_node) + machine().sound().config_add_sound_io_connection_node(m_current_selection.m_dev, find_node_name(next_node), m_current_selection.m_db); + else + machine().sound().config_add_sound_io_connection_default(m_current_selection.m_dev, m_current_selection.m_db); + m_generation --; + return true; + } + } else if(m_current_selection.m_maptype == MT_CHANNEL) { + uint32_t prev_node = m_current_selection.m_node; + uint32_t next_node = find_previous_available_channel_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, prev_node, m_current_selection.m_node_channel); + if(next_node != 0xffffffff) { + m_current_selection.m_node = next_node; + if(prev_node) + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(prev_node), m_current_selection.m_node_channel); + else + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + if(next_node) + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(next_node), m_current_selection.m_node_channel, m_current_selection.m_db); + else + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, m_current_selection.m_db); + m_generation --; + return true; + } + } + break; + } + + case GRP_DB: { + double db = dec_db(m_current_selection.m_db); + m_current_selection.m_db = db; + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_selection.m_node == 0) + machine().sound().config_set_volume_sound_io_connection_default(m_current_selection.m_dev, db); + else + machine().sound().config_set_volume_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node), db); + } else { + if(m_current_selection.m_node == 0) + machine().sound().config_set_volume_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, db); + else + machine().sound().config_set_volume_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel, db); + } + m_generation --; + return true; + } + + case GRP_GUEST_CHANNEL: { + if(m_current_selection.m_maptype != MT_CHANNEL) + return false; + + u32 guest_channel_count = m_current_selection.m_dev->outputs(); + if(guest_channel_count == 1) + return false; + u32 guest_channel = m_current_selection.m_guest_channel; + for(;;) { + if(guest_channel == 0) + guest_channel = guest_channel_count - 1; + else + guest_channel --; + if(guest_channel == m_current_selection.m_guest_channel) + return false; + if(channel_mapping_available(m_current_selection.m_dev, guest_channel, m_current_selection.m_node, m_current_selection.m_node_channel)) { + if(m_current_selection.m_node) { + std::string node = find_node_name(m_current_selection.m_node); + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, node, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, guest_channel, node, m_current_selection.m_node_channel, m_current_selection.m_db); + } else { + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, guest_channel, m_current_selection.m_node_channel, m_current_selection.m_db); + } + m_current_selection.m_guest_channel = guest_channel; + m_generation --; + return true; + } + } + break; + } + + case GRP_NODE_CHANNEL: { + if(m_current_selection.m_maptype != MT_CHANNEL) + return false; + + u32 node_channel_count = find_node_channel_count(m_current_selection.m_node, m_current_selection.m_dev->is_output()); + if(node_channel_count == 1) + return false; + u32 node_channel = m_current_selection.m_node_channel; + for(;;) { + if(node_channel == 0) + node_channel = node_channel_count - 1; + else + node_channel --; + if(node_channel == m_current_selection.m_node_channel) + return false; + if(channel_mapping_available(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node, node_channel)) { + if(m_current_selection.m_node) { + std::string node = find_node_name(m_current_selection.m_node); + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, node, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, node, node_channel, m_current_selection.m_db); + } else { + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, node_channel, m_current_selection.m_db); + } + m_current_selection.m_node_channel = node_channel; + m_generation --; + return true; + } + } + break; + } + } + break; + } + + case IPT_UI_RIGHT: { + if(m_current_selection.m_maptype == MT_NONE || m_current_selection.m_maptype == MT_INTERNAL) + return false; + + switch(m_current_group) { + case GRP_NODE: { + if(m_current_selection.m_maptype == MT_FULL) { + uint32_t prev_node = m_current_selection.m_node; + uint32_t next_node = find_next_available_node(m_current_selection.m_dev, prev_node); + if(next_node != 0xffffffff) { + m_current_selection.m_node = next_node; + if(prev_node) + machine().sound().config_remove_sound_io_connection_node(m_current_selection.m_dev, find_node_name(prev_node)); + else + machine().sound().config_remove_sound_io_connection_default(m_current_selection.m_dev); + if(next_node) + machine().sound().config_add_sound_io_connection_node(m_current_selection.m_dev, find_node_name(next_node), m_current_selection.m_db); + else + machine().sound().config_add_sound_io_connection_default(m_current_selection.m_dev, m_current_selection.m_db); + m_generation --; + return true; + } + } else if(m_current_selection.m_maptype == MT_CHANNEL) { + uint32_t prev_node = m_current_selection.m_node; + uint32_t next_node = find_next_available_channel_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, prev_node, m_current_selection.m_node_channel); + if(next_node != 0xffffffff) { + m_current_selection.m_node = next_node; + if(prev_node) + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(prev_node), m_current_selection.m_node_channel); + else + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + if(next_node) + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(next_node), m_current_selection.m_node_channel, m_current_selection.m_db); + else + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, m_current_selection.m_db); + m_generation --; + return true; + } + } + break; + } + + case GRP_DB: { + double db = inc_db(m_current_selection.m_db); + m_current_selection.m_db = db; + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_selection.m_node == 0) + machine().sound().config_set_volume_sound_io_connection_default(m_current_selection.m_dev, db); + else + machine().sound().config_set_volume_sound_io_connection_node(m_current_selection.m_dev, find_node_name(m_current_selection.m_node), db); + } else { + if(m_current_selection.m_node == 0) + machine().sound().config_set_volume_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel, db); + else + machine().sound().config_set_volume_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, find_node_name(m_current_selection.m_node), m_current_selection.m_node_channel, db); + } + m_generation --; + return true; + } + + case GRP_GUEST_CHANNEL: { + if(m_current_selection.m_maptype != MT_CHANNEL) + return false; + + u32 guest_channel_count = m_current_selection.m_dev->outputs(); + if(guest_channel_count == 1) + return false; + u32 guest_channel = m_current_selection.m_guest_channel; + for(;;) { + guest_channel ++; + if(guest_channel == guest_channel_count) + guest_channel = 0; + if(guest_channel == m_current_selection.m_guest_channel) + return false; + if(channel_mapping_available(m_current_selection.m_dev, guest_channel, m_current_selection.m_node, m_current_selection.m_node_channel)) { + if(m_current_selection.m_node) { + std::string node = find_node_name(m_current_selection.m_node); + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, node, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, guest_channel, node, m_current_selection.m_node_channel, m_current_selection.m_db); + } else { + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, guest_channel, m_current_selection.m_node_channel, m_current_selection.m_db); + } + m_current_selection.m_guest_channel = guest_channel; + m_generation --; + return true; + } + } + break; + } + + case GRP_NODE_CHANNEL: { + if(m_current_selection.m_maptype != MT_CHANNEL) + return false; + + u32 node_channel_count = find_node_channel_count(m_current_selection.m_node, m_current_selection.m_dev->is_output()); + if(node_channel_count == 1) + return false; + u32 node_channel = m_current_selection.m_node_channel; + for(;;) { + node_channel ++; + if(node_channel == node_channel_count) + node_channel = 0; + if(node_channel == m_current_selection.m_node_channel) + return false; + if(channel_mapping_available(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node, node_channel)) { + if(m_current_selection.m_node) { + std::string node = find_node_name(m_current_selection.m_node); + machine().sound().config_remove_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, node, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_node(m_current_selection.m_dev, m_current_selection.m_guest_channel, node, node_channel, m_current_selection.m_db); + } else { + machine().sound().config_remove_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, m_current_selection.m_node_channel); + machine().sound().config_add_sound_io_channel_connection_default(m_current_selection.m_dev, m_current_selection.m_guest_channel, node_channel, m_current_selection.m_db); + } + m_current_selection.m_node_channel = node_channel; + m_generation --; + return true; + } + } + break; + } + } + break; + } + } + + return false; +} + + +//------------------------------------------------- +// menu_audio_mixer_populate - populate the audio_mixer +// menu +//------------------------------------------------- + +void menu_audio_mixer::populate() +{ + const auto &mapping = machine().sound().get_mappings(); + const auto &info = machine().sound().get_osd_info(); + m_generation = info.m_generation; + + auto find_node = [&info](u32 node_id) -> const osd::audio_info::node_info * { + for(const auto &node : info.m_nodes) + if(node.m_id == node_id) + return &node; + // Never happens + return nullptr; + }; + + // Rebuild the selections list + m_selections.clear(); + for(const auto &omap : mapping) { + for(const auto &nmap : omap.m_node_mappings) + m_selections.emplace_back(select_entry { MT_FULL, omap.m_dev, 0, nmap.m_is_system_default ? 0 : nmap.m_node, 0, nmap.m_db }); + for(const auto &cmap : omap.m_channel_mappings) + m_selections.emplace_back(select_entry { MT_CHANNEL, omap.m_dev, cmap.m_guest_channel, cmap.m_is_system_default ? 0 : cmap.m_node, cmap.m_node_channel, cmap.m_db }); + if(omap.m_node_mappings.empty() && omap.m_channel_mappings.empty()) + m_selections.emplace_back(select_entry { MT_NONE, omap.m_dev, 0, 0, 0, 0 }); + } + + // If there's nothing, get out of there + if(m_selections.empty()) + return; + + // Find the line of the current selection, if any. + // Otherwise default to the first line + + u32 cursel_line = 0xffffffff; + + for(u32 i = 0; i != m_selections.size(); i++) { + if(m_current_selection == m_selections[i]) { + cursel_line = i; + break; + } + } + + if(cursel_line == 0xffffffff) + for(u32 i = 0; i != m_selections.size(); i++) { + if(m_current_selection.m_dev == m_selections[i].m_dev) { + cursel_line = i; + break; + } + } + + if(cursel_line == 0xffffffff) + cursel_line = 0; + + if(m_current_selection.m_maptype == MT_INTERNAL) + cursel_line = 0xffffffff; + else + m_current_selection = m_selections[cursel_line]; + + if(m_current_selection.m_maptype == MT_FULL) { + if(m_current_group == GRP_GUEST_CHANNEL || m_current_group == GRP_NODE_CHANNEL) + m_current_group = GRP_NODE; + } + + // (Re)build the menu + u32 curline = 0; + for(const auto &omap : mapping) { + item_append(omap.m_dev->tag(), FLAG_UI_HEADING | FLAG_DISABLE, nullptr); + for(const auto &nmap : omap.m_node_mappings) { + const auto &node = find_node(nmap.m_node); + std::string lnode = nmap.m_is_system_default || node->m_name == "" ? "[default]" : node->m_name; + if(!omap.m_dev->is_output() && node->m_sinks) + lnode = util::string_format("Monitor of %s", lnode); + if(curline == cursel_line && m_current_group == GRP_NODE) + lnode = "\xe2\x86\x90" + lnode + "\xe2\x86\x92"; + + std::string line = (omap.m_dev->is_output() ? "> " : "< ") + lnode; + + std::string db = util::string_format("%g dB", nmap.m_db); + if(curline == cursel_line && m_current_group == GRP_DB) + db = "\xe2\x86\x90" + db + "\xe2\x86\x92"; + + item_append(line, db, 0, m_selections.data() + curline); + curline ++; + } + for(const auto &cmap : omap.m_channel_mappings) { + const auto &node = find_node(cmap.m_node); + std::string guest_channel = omap.m_dev->get_position_name(cmap.m_guest_channel); + if(curline == cursel_line && m_current_group == GRP_GUEST_CHANNEL) + guest_channel = "\xe2\x86\x90" + guest_channel + "\xe2\x86\x92"; + + std::string lnode = cmap.m_is_system_default || node->m_name == "" ? "[default]" : node->m_name; + if(!omap.m_dev->is_output() && node->m_sinks) + lnode = util::string_format("Monitor of %s", lnode); + if(curline == cursel_line && m_current_group == GRP_NODE) + lnode = "\xe2\x86\x90" + lnode + "\xe2\x86\x92"; + + std::string lnode_channel = node->m_port_names[cmap.m_node_channel]; + if(curline == cursel_line && m_current_group == GRP_NODE_CHANNEL) + lnode_channel = "\xe2\x86\x90" + lnode_channel + "\xe2\x86\x92"; + + std::string line = guest_channel + " > " + lnode + ":" + lnode_channel; + + std::string db = util::string_format("%g dB", cmap.m_db); + if(curline == cursel_line && m_current_group == GRP_DB) + db = "\xe2\x86\x90" + db + "\xe2\x86\x92"; + + item_append(line, db, 0, m_selections.data() + curline); + curline ++; + } + if(omap.m_node_mappings.empty() && omap.m_channel_mappings.empty()) { + item_append("[no mapping]", 0, m_selections.data() + curline); + curline ++; + } + } + item_append(menu_item_type::SEPARATOR); + item_append(util::string_format("%s: add a full mapping", ui().get_general_input_setting(IPT_UI_MIXER_ADD_FULL)), FLAG_DISABLE, nullptr); + item_append(util::string_format("%s: add a channel mapping", ui().get_general_input_setting(IPT_UI_MIXER_ADD_CHANNEL)), FLAG_DISABLE, nullptr); + item_append(util::string_format("%s: remove a mapping", ui().get_general_input_setting(IPT_UI_CLEAR)), FLAG_DISABLE, nullptr); + item_append(menu_item_type::SEPARATOR); + + if(cursel_line != 0xffffffff) + set_selection(m_selections.data() + cursel_line); +} + + +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void menu_audio_mixer::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + // set_custom_space(0.0f, 2.0f * line_height() + 2.0f * tb_border()); +} + + +//------------------------------------------------- +// menu_audio_mixer_custom_render - perform our special +// rendering +//------------------------------------------------- + +void menu_audio_mixer::custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) +{ +} + + +//------------------------------------------------- +// menu_activated - handle menu gaining focus +//------------------------------------------------- + +void menu_audio_mixer::menu_activated() +{ + // scripts or the other form of the menu could have changed something in the mean time + reset(reset_options::REMEMBER_POSITION); +} + + +//------------------------------------------------- +// menu_deactivated - handle menu losing focus +//------------------------------------------------- + +void menu_audio_mixer::menu_deactivated() +{ +} + +uint32_t menu_audio_mixer::find_node_index(uint32_t node) const +{ + const auto &info = machine().sound().get_osd_info(); + for(uint32_t i = 0; i != info.m_nodes.size(); i++) + if(info.m_nodes[i].m_id == node) + return i; + // Can't happen in theory + return 0xffffffff; +} + +std::string menu_audio_mixer::find_node_name(uint32_t node) const +{ + const auto &info = machine().sound().get_osd_info(); + for(uint32_t i = 0; i != info.m_nodes.size(); i++) + if(info.m_nodes[i].m_id == node) + return info.m_nodes[i].name(); + // Can't happen in theory + return ""; +} + +uint32_t menu_audio_mixer::find_node_channel_count(uint32_t node, bool is_output) const +{ + const auto &info = machine().sound().get_osd_info(); + if(!node) + node = info.m_default_sink; + for(uint32_t i = 0; i != info.m_nodes.size(); i++) + if(info.m_nodes[i].m_id == node) + return is_output ? info.m_nodes[i].m_sinks : info.m_nodes[i].m_sources; + // Can't happen in theory + return 0; +} + +uint32_t menu_audio_mixer::find_next_sink_node_index(uint32_t index) const +{ + if(index == 0xffffffff) + return index; + + const auto &info = machine().sound().get_osd_info(); + for(uint32_t idx = index + 1; idx != info.m_nodes.size(); idx++) + if(info.m_nodes[idx].m_sinks) + return idx; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_next_source_node_index(uint32_t index) const +{ + if(index == 0xffffffff) + return index; + + const auto &info = machine().sound().get_osd_info(); + for(uint32_t idx = index + 1; idx != info.m_nodes.size(); idx++) + if(info.m_nodes[idx].m_sources) + return idx; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_previous_sink_node_index(uint32_t index) const +{ + if(index == 0xffffffff) + return index; + + const auto &info = machine().sound().get_osd_info(); + for(uint32_t idx = index - 1; idx != 0xffffffff; idx--) + if(info.m_nodes[idx].m_sinks) + return idx; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_previous_source_node_index(uint32_t index) const +{ + if(index == 0xffffffff) + return index; + + const auto &info = machine().sound().get_osd_info(); + for(uint32_t idx = index - 1; idx != 0xffffffff; idx--) + if(info.m_nodes[idx].m_sources) + return idx; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_first_sink_node_index() const +{ + const auto &info = machine().sound().get_osd_info(); + for(uint32_t index = 0; index != info.m_nodes.size(); index ++) + if(info.m_nodes[index].m_sinks) + return index; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_first_source_node_index() const +{ + const auto &info = machine().sound().get_osd_info(); + for(uint32_t index = 0; index != info.m_nodes.size(); index ++) + if(info.m_nodes[index].m_sources) + return index; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_last_sink_node_index() const +{ + const auto &info = machine().sound().get_osd_info(); + for(uint32_t index = info.m_nodes.size() - 1; index != 0xffffffff; index --) + if(info.m_nodes[index].m_sinks) + return index; + return 0xffffffff; +} + +uint32_t menu_audio_mixer::find_last_source_node_index() const +{ + const auto &info = machine().sound().get_osd_info(); + for(uint32_t index = info.m_nodes.size() - 1; index != 0xffffffff; index --) + if(info.m_nodes[index].m_sources) + return index; + return 0xffffffff; +} + +bool menu_audio_mixer::full_mapping_available(sound_io_device *dev, uint32_t node) const +{ + if(dev->is_output() && !node && machine().sound().get_osd_info().m_default_sink == 0) + return false; + if(!dev->is_output() && !node && machine().sound().get_osd_info().m_default_source == 0) + return false; + + const auto &mapping = machine().sound().get_mappings(); + for(const auto &omap : mapping) + if(omap.m_dev == dev) { + for(const auto &nmap : omap.m_node_mappings) + if((node != 0 && nmap.m_node == node && !nmap.m_is_system_default) || (node == 0 && nmap.m_is_system_default)) + return false; + return true; + } + return true; +} + +bool menu_audio_mixer::channel_mapping_available(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const +{ + if(dev->is_output() && !node && machine().sound().get_osd_info().m_default_sink == 0) + return false; + if(!dev->is_output() && !node && machine().sound().get_osd_info().m_default_source == 0) + return false; + + const auto &mapping = machine().sound().get_mappings(); + for(const auto &omap : mapping) + if(omap.m_dev == dev) { + for(const auto &cmap : omap.m_channel_mappings) + if(cmap.m_guest_channel == guest_channel && + ((node != 0 && cmap.m_node == node && !cmap.m_is_system_default) || (node == 0 && cmap.m_is_system_default)) + && cmap.m_node_channel == node_channel) + return false; + return true; + } + return true; +} + +uint32_t menu_audio_mixer::find_next_available_node(sound_io_device *dev, uint32_t node) const +{ + const auto &info = machine().sound().get_osd_info(); + + if(dev->is_output()) { + if(node == 0) { + uint32_t index = find_first_sink_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_next_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_next_sink_node_index(index); + if(index != 0xffffffff && full_mapping_available(dev, info.m_nodes[index].m_id)) + return info.m_nodes[index].m_id; + } + + if(info.m_default_sink != 0 && full_mapping_available(dev, 0)) + return 0; + + index = find_first_sink_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_next_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } else { + if(node == 0) { + uint32_t index = find_first_source_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_next_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_next_source_node_index(index); + if(index != 0xffffffff && full_mapping_available(dev, info.m_nodes[index].m_id)) + return info.m_nodes[index].m_id; + } + + if(info.m_default_source != 0 && full_mapping_available(dev, 0)) + return 0; + + index = find_first_source_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_next_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } +} + +uint32_t menu_audio_mixer::find_previous_available_node(sound_io_device *dev, uint32_t node) const +{ + const auto &info = machine().sound().get_osd_info(); + + if(dev->is_output()) { + if(node == 0) { + uint32_t index = find_last_sink_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_previous_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_previous_sink_node_index(index); + if(index != 0xffffffff && full_mapping_available(dev, info.m_nodes[index].m_id)) + return info.m_nodes[index].m_id; + } + + if(info.m_default_sink != 0 && full_mapping_available(dev, 0)) + return 0; + + index = find_last_sink_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_previous_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + + } else { + if(node == 0) { + uint32_t index = find_last_source_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_previous_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_previous_source_node_index(index); + if(index != 0xffffffff && full_mapping_available(dev, info.m_nodes[index].m_id)) + return info.m_nodes[index].m_id; + } + + if(info.m_default_source != 0 && full_mapping_available(dev, 0)) + return 0; + + index = find_last_source_node_index(); + while(index != 0xffffffff && !full_mapping_available(dev, info.m_nodes[index].m_id)) + index = find_previous_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } +} + +uint32_t menu_audio_mixer::find_next_available_channel_node(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const +{ + const auto &info = machine().sound().get_osd_info(); + + if(dev->is_output()) { + if(node == 0) { + uint32_t index = find_first_sink_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_next_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_next_sink_node_index(index); + if(index != 0xffffffff && channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + return info.m_nodes[index].m_id; + } + + if(dev->is_output() && info.m_default_sink != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + if(!dev->is_output() && info.m_default_source != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + + index = find_first_sink_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_next_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + + } else { + if(node == 0) { + uint32_t index = find_first_source_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_next_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_next_source_node_index(index); + if(index != 0xffffffff && channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + return info.m_nodes[index].m_id; + } + + if(dev->is_output() && info.m_default_source != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + if(!dev->is_output() && info.m_default_source != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + + index = find_first_source_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_next_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } +} + +uint32_t menu_audio_mixer::find_previous_available_channel_node(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const +{ + const auto &info = machine().sound().get_osd_info(); + + if(dev->is_output()) { + if(node == 0) { + uint32_t index = find_last_sink_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_previous_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_previous_sink_node_index(index); + if(index != 0xffffffff && channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + return info.m_nodes[index].m_id; + } + + if(dev->is_output() && info.m_default_sink != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + if(!dev->is_output() && info.m_default_source != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + + index = find_last_sink_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_previous_sink_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + + } else { + if(node == 0) { + uint32_t index = find_last_source_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_previous_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } + + uint32_t index = find_node_index(node); + while(index != 0xffffffff) { + index = find_previous_source_node_index(index); + if(index != 0xffffffff && channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + return info.m_nodes[index].m_id; + } + + if(dev->is_output() && info.m_default_source != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + if(!dev->is_output() && info.m_default_source != 0 && channel_mapping_available(dev, guest_channel, 0, node_channel)) + return 0; + + index = find_last_source_node_index(); + while(index != 0xffffffff && !channel_mapping_available(dev, guest_channel, info.m_nodes[index].m_id, node_channel)) + index = find_previous_source_node_index(index); + return index == 0xffffffff ? 0xffffffff : info.m_nodes[index].m_id; + } +} + +float menu_audio_mixer::quantize_db(float db) +{ + if(db >= 12.0) + return 12.0; + if(db >= -12.0) + return floor(db*2 + 0.5) / 2; + if(db >= -24.0) + return floor(db + 0.5); + if(db >= -48.0) + return floor(db/2 + 0.5) * 2; + if(db >= -96.0) + return floor(db/4 + 0.5) * 4; + return -96.0; +} + +float menu_audio_mixer::inc_db(float db) +{ + db = quantize_db(db); + if(db >= 12) + return 12.0; + if(db >= -12.0) + return db + 0.5; + if(db >= -24.0) + return db + 1; + if(db >= -48.0) + return db + 2; + if(db >= -96.0 + 4) + return db + 4; + return -96.0 + 4; + +} + +float menu_audio_mixer::dec_db(float db) +{ + db = quantize_db(db); + if(db >= 12.5) + return 11.5; + if(db > -12.0) + return db - 0.5; + if(db > -24.0) + return db - 1; + if(db > -48.0) + return db - 2; + if(db >= -92.0) + return db - 4; + return -96.0; +} + +} // namespace ui + diff --git a/src/frontend/mame/ui/audiomix.h b/src/frontend/mame/ui/audiomix.h new file mode 100644 index 00000000000..880b4829782 --- /dev/null +++ b/src/frontend/mame/ui/audiomix.h @@ -0,0 +1,99 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + ui/audiomix.h + + Audio mixing/mapping control + +***************************************************************************/ + +#ifndef MAME_FRONTEND_UI_AUDIOMIX_H +#define MAME_FRONTEND_UI_AUDIOMIX_H + +#pragma once + +#include "ui/menu.h" + + +namespace ui { + +class menu_audio_mixer : public menu +{ +public: + menu_audio_mixer(mame_ui_manager &mui, render_container &container); + virtual ~menu_audio_mixer() override; + +protected: + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override; + virtual void custom_render(uint32_t flags, void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; + virtual void menu_activated() override; + virtual void menu_deactivated() override; + +private: + enum { + MT_UNDEFINED, // At startup + MT_NONE, // [no mapping] + MT_FULL, // Full mapping to node + MT_CHANNEL, // Channel-to-channel mapping + MT_INTERNAL // Go back to previous menu or other non-mapping entry + }; + + enum { + GRP_GUEST_CHANNEL, + GRP_NODE, + GRP_NODE_CHANNEL, + GRP_DB + }; + + struct select_entry { + u32 m_maptype; + sound_io_device *m_dev; + u32 m_guest_channel; + u32 m_node; + u32 m_node_channel; + float m_db; + + inline bool operator ==(const select_entry &sel) { + return sel.m_maptype == m_maptype && sel.m_dev == m_dev && sel.m_guest_channel == m_guest_channel && sel.m_node == m_node && sel.m_node_channel == m_node_channel; + } + }; + + uint32_t m_generation; + select_entry m_current_selection; + uint32_t m_current_group; + std::vector<select_entry> m_selections; + + virtual void populate() override; + virtual bool handle(event const *ev) override; + + uint32_t find_node_index(uint32_t node) const; + std::string find_node_name(uint32_t node) const; + uint32_t find_node_channel_count(uint32_t node, bool is_output) const; + + uint32_t find_next_sink_node_index(uint32_t index) const; + uint32_t find_next_source_node_index(uint32_t index) const; + uint32_t find_previous_sink_node_index(uint32_t index) const; + uint32_t find_previous_source_node_index(uint32_t index) const; + + uint32_t find_first_sink_node_index() const; + uint32_t find_first_source_node_index() const; + uint32_t find_last_sink_node_index() const; + uint32_t find_last_source_node_index() const; + + bool full_mapping_available(sound_io_device *dev, uint32_t node) const; + bool channel_mapping_available(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const; + + uint32_t find_next_available_node(sound_io_device *dev, uint32_t node) const; + uint32_t find_previous_available_node(sound_io_device *dev, uint32_t node) const; + uint32_t find_next_available_channel_node(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const; + uint32_t find_previous_available_channel_node(sound_io_device *dev, uint32_t guest_channel, uint32_t node, uint32_t node_channel) const; + + static float quantize_db(float db); + static float inc_db(float db); + static float dec_db(float db); +}; + +} // namespace ui + +#endif // MAME_FRONTEND_UI_AUDIOMIX_H diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp index 40f60d9b59f..fa8bb4fadce 100644 --- a/src/frontend/mame/ui/devopt.cpp +++ b/src/frontend/mame/ui/devopt.cpp @@ -167,7 +167,7 @@ void menu_device_config::populate_text(std::optional<text_layout> &layout, float std::unordered_set<std::string> soundtags; for (device_sound_interface &sound : snditer) { - if (!sound.issound() || !soundtags.insert(sound.device().tag()).second) + if (!soundtags.insert(sound.device().tag()).second) continue; // count how many identical sound chips we have diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index c2ba4af2cfb..7176779ea02 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -446,7 +446,7 @@ std::string machine_info::game_info_string() const bool found_sound = false; for (device_sound_interface &sound : snditer) { - if (!sound.issound() || !soundtags.insert(sound.device().tag()).second) + if (!soundtags.insert(sound.device().tag()).second) continue; // append the Sound: string diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index 16b7396e7f5..c7b23b8d19f 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -12,6 +12,8 @@ #include "ui/mainmenu.h" #include "ui/about.h" +#include "ui/audiomix.h" +#include "ui/audioeffects.h" #include "ui/barcode.h" #include "ui/cheatopt.h" #include "ui/confswitch.h" @@ -56,6 +58,8 @@ enum : unsigned { TAPE_CONTROL, SLOT_DEVICES, NETWORK_DEVICES, + AUDIO_MIXER, + AUDIO_EFFECTS, SLIDERS, VIDEO_TARGETS, CROSSHAIR, @@ -157,6 +161,10 @@ void menu_main::populate() if (network_interface_enumerator(machine().root_device()).first() != nullptr) item_append(_("menu-main", "Network Devices"), 0, (void*)NETWORK_DEVICES); + item_append(_("menu-main", "Audio Mixer"), 0, (void *)AUDIO_MIXER); + + item_append(_("menu-main", "Audio Effects"), 0, (void *)AUDIO_EFFECTS); + item_append(_("menu-main", "Slider Controls"), 0, (void *)SLIDERS); item_append(_("menu-main", "Video Options"), 0, (void *)VIDEO_TARGETS); @@ -262,6 +270,14 @@ bool menu_main::handle(event const *ev) menu::stack_push<menu_network_devices>(ui(), container()); break; + case AUDIO_MIXER: + menu::stack_push<menu_audio_mixer>(ui(), container()); + break; + + case AUDIO_EFFECTS: + menu::stack_push<menu_audio_effects>(ui(), container()); + break; + case SLIDERS: menu::stack_push<menu_sliders>(ui(), container(), false); break; diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp index dbfd5531be6..dc89ea755b7 100644 --- a/src/frontend/mame/ui/ui.cpp +++ b/src/frontend/mame/ui/ui.cpp @@ -882,20 +882,6 @@ bool mame_ui_manager::update_and_render(render_container &container) container.add_rect(0.0f, 0.0f, 1.0f, 1.0f, rgb_t(alpha,0x00,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } - // show red if overdriving sound - if (machine().options().speaker_report() != 0 && machine().phase() == machine_phase::RUNNING) - { - auto compressor = machine().sound().compressor_scale(); - if (compressor < 1.0) - { - float width = 0.05f + std::min(0.15f, (1.0f - compressor) * 0.4f); - container.add_rect(0.0f, 0.0f, 1.0f, width, rgb_t(0xc0,0xff,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - container.add_rect(0.0f, 1.0f - width, 1.0f, 1.0f, rgb_t(0xc0,0xff,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - container.add_rect(0.0f, width, width, 1.0f - width, rgb_t(0xc0,0xff,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - container.add_rect(1.0f - width, width, 1.0f, 1.0f - width, rgb_t(0xc0,0xff,0x00,0x00), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); - } - } - // render any cheat stuff at the bottom if (machine().phase() >= machine_phase::RESET) mame_machine_manager::instance()->cheat().render_text(*this, container); @@ -1874,22 +1860,19 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine m_sliders.clear(); // add overall volume - slider_alloc(_("Master Volume"), -32, 0, 0, 1, std::bind(&mame_ui_manager::slider_volume, this, _1, _2)); + slider_alloc(_("Master Volume"), -48, osd::linear_to_db(0), 6, 1, std::bind(&mame_ui_manager::slider_volume, this, _1, _2)); - // add per-channel volume - mixer_input info; - for (int item = 0; machine.sound().indexed_mixer_input(item, info); item++) + // add per-sound device and per-sound device channel volume + for (device_sound_interface &snd : sound_interface_enumerator(machine.root_device())) { - std::string str = string_format(_("%1$s Volume"), info.stream->input(info.inputnum).name()); - slider_alloc(std::move(str), 0, 1000, 4000, 20, std::bind(&mame_ui_manager::slider_mixervol, this, item, _1, _2)); - } + // Don't add microphones, speakers or devices without outputs + if (dynamic_cast<sound_io_device *>(&snd) || !snd.outputs()) + continue; - // add speaker panning - for (speaker_device &speaker : speaker_device_enumerator(machine.root_device())) - { - int defpan = floorf(speaker.defpan() * 1000.0f + 0.5f); - std::string str = string_format(_("%s '%s' Panning"), speaker.name(), speaker.tag()); - slider_alloc(std::move(str), -1000, defpan, 1000, 20, std::bind(&mame_ui_manager::slider_panning, this, std::ref(speaker), _1, _2)); + slider_alloc(util::string_format(_("%1$s volume"), snd.device().tag()), -48, osd::linear_to_db_int(snd.user_output_gain()), 6, 1, std::bind(&mame_ui_manager::slider_devvol, this, &snd, _1, _2)); + if (snd.outputs() != 1) + for (int channel = 0; channel != snd.outputs(); channel ++) + slider_alloc(util::string_format(_("%1$s channel %d volume"), snd.device().tag(), channel), -48, osd::linear_to_db_int(snd.user_output_gain(channel)), 6, 1, std::bind(&mame_ui_manager::slider_devvol_chan, this, &snd, channel, _1, _2)); } // add analog adjusters @@ -2032,84 +2015,68 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine int32_t mame_ui_manager::slider_volume(std::string *str, int32_t newval) { if (newval != SLIDER_NOCHANGE) - machine().sound().set_attenuation(newval); + machine().sound().set_master_gain(newval == -48 ? 0 : osd::db_to_linear(newval)); - int32_t curval = machine().sound().attenuation(); - if (str) - *str = string_format(_(u8"%1$3d\u00a0dB"), curval); + int curval = machine().sound().master_gain() == 0 ? -48 : osd::linear_to_db_int(machine().sound().master_gain()); + if (str) + { + if (curval == -48) + *str = _("Mute"); + else + *str = string_format(_(u8"%1$3d\u00a0dB"), curval); + } return curval; } //------------------------------------------------- -// slider_mixervol - single channel volume +// slider_devvol - device volume // slider callback //------------------------------------------------- -int32_t mame_ui_manager::slider_mixervol(int item, std::string *str, int32_t newval) +int32_t mame_ui_manager::slider_devvol(device_sound_interface *snd, std::string *str, int32_t newval) { - mixer_input info; - if (!machine().sound().indexed_mixer_input(item, info)) - return 0; - if (newval != SLIDER_NOCHANGE) - info.stream->input(info.inputnum).set_user_gain(float(newval) * 0.001f); + snd->set_user_output_gain(newval == -48 ? 0 : osd::db_to_linear(newval)); + + int curval = snd->user_output_gain() == 0 ? -48 : osd::linear_to_db_int(snd->user_output_gain()); - int32_t curval = floorf(info.stream->input(info.inputnum).user_gain() * 1000.0f + 0.5f); if (str) { - if (curval == 0) + if (curval == -48) *str = _("Mute"); - else if (curval % 10) - *str = string_format(_("%1$.1f%%"), float(curval) * 0.1f); else - *str = string_format(_("%1$3d%%"), curval / 10); + *str = string_format(_(u8"%1$3d\u00a0dB"), curval); } - return curval; } //------------------------------------------------- -// slider_panning - speaker panning slider -// callback +// slider_devvol_chan - device channel volume +// slider callback //------------------------------------------------- -int32_t mame_ui_manager::slider_panning(speaker_device &speaker, std::string *str, int32_t newval) +int32_t mame_ui_manager::slider_devvol_chan(device_sound_interface *snd, int channel, std::string *str, int32_t newval) { if (newval != SLIDER_NOCHANGE) - speaker.set_pan(float(newval) * 0.001f); + snd->set_user_output_gain(channel, newval == -48 ? 0 : osd::db_to_linear(newval)); + + int curval = snd->user_output_gain(channel) == 0 ? -48 : osd::linear_to_db_int(snd->user_output_gain(channel)); - int32_t curval = floorf(speaker.pan() * 1000.0f + 0.5f); if (str) { - switch (curval) - { - // preset strings for exact center/left/right - case 0: - *str = _("Center"); - break; - - case -1000: - *str = _("Left"); - break; - - case 1000: - *str = _("Right"); - break; - - // otherwise show as floating point - default: - *str = string_format(_("%1$.3f"), float(curval) * 0.001f); - break; - } + if (curval == -48) + *str = _("Mute"); + else + *str = string_format(_(u8"%1$3d\u00a0dB"), curval); } - return curval; } + //------------------------------------------------- // slider_adjuster - analog adjuster slider // callback diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h index 05017154d48..667f4b30aeb 100644 --- a/src/frontend/mame/ui/ui.h +++ b/src/frontend/mame/ui/ui.h @@ -349,8 +349,8 @@ private: // slider controls int32_t slider_volume(std::string *str, int32_t newval); - int32_t slider_mixervol(int item, std::string *str, int32_t newval); - int32_t slider_panning(speaker_device &speaker, std::string *str, int32_t newval); + int32_t slider_devvol(device_sound_interface *snd, std::string *str, int32_t newval); + int32_t slider_devvol_chan(device_sound_interface *snd, int channel, std::string *str, int32_t newval); int32_t slider_adjuster(ioport_field &field, std::string *str, int32_t newval); int32_t slider_overclock(device_t &device, std::string *str, int32_t newval); int32_t slider_refresh(screen_device &screen, std::string *str, int32_t newval); diff --git a/src/mame/access/acvirus.cpp b/src/mame/access/acvirus.cpp index 2d2bf966bb8..cd14ae6690a 100644 --- a/src/mame/access/acvirus.cpp +++ b/src/mame/access/acvirus.cpp @@ -114,8 +114,7 @@ void acvirus_state::virus(machine_config &config) SAB80C535(config, m_maincpu, XTAL(12'000'000)); m_maincpu->set_addrmap(AS_PROGRAM, &acvirus_state::virus_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } static INPUT_PORTS_START( virus ) diff --git a/src/mame/acorn/electron_ula.cpp b/src/mame/acorn/electron_ula.cpp index 66d6f6930c6..053f53aa82b 100644 --- a/src/mame/acorn/electron_ula.cpp +++ b/src/mame/acorn/electron_ula.cpp @@ -218,19 +218,14 @@ void electron_ula_device::set_cpu_clock(offs_t offset) // sound_stream_update - handle a stream update //------------------------------------------------- -void electron_ula_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void electron_ula_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - // if we're not enabled, just fill with 0 + // if we're not enabled, just leave the default 0-fill if (!m_sound_enable || m_sound_freq == 0) - { - buffer.fill(0); return; - } // fill in the sample - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { m_sound_incr -= m_sound_freq; while (m_sound_incr < 0) @@ -239,7 +234,7 @@ void electron_ula_device::sound_stream_update(sound_stream &stream, std::vector< m_sound_signal = -m_sound_signal; } - buffer.put(sampindex, m_sound_signal); + stream.put(0, sampindex, m_sound_signal); } } diff --git a/src/mame/acorn/electron_ula.h b/src/mame/acorn/electron_ula.h index 2c233e9e1a4..36f00a3afed 100644 --- a/src/mame/acorn/electron_ula.h +++ b/src/mame/acorn/electron_ula.h @@ -54,7 +54,7 @@ protected: virtual uint32_t palette_entries() const noexcept override { return 16; } // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface implementation virtual space_config_vector memory_space_config() const override; @@ -70,7 +70,7 @@ private: bool m_sound_enable; // enable beep uint32_t m_sound_freq; // set frequency int32_t m_sound_incr; // initial wave state - stream_buffer::sample_t m_sound_signal; // current signal + sound_stream::sample_t m_sound_signal; // current signal casin_delegate m_cas_in_cb; casout_delegate m_cas_out_cb; diff --git a/src/mame/acorn/ssfindo.cpp b/src/mame/acorn/ssfindo.cpp index dd3165c80cb..f975dfb5e01 100644 --- a/src/mame/acorn/ssfindo.cpp +++ b/src/mame/acorn/ssfindo.cpp @@ -630,15 +630,14 @@ void ssfindo_state::ssfindo(machine_config &config) m_iomd->iolines_read().set(FUNC(ssfindo_state::iolines_r)); m_iomd->iolines_write().set(FUNC(ssfindo_state::iolines_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); qs1000_device &qs1000(QS1000(config, "qs1000", 24_MHz_XTAL)); qs1000.set_external_rom(true); // qs1000.p1_out().set(FUNC()); // TODO: writes something here qs1000.p3_in().set([this]() { return u8(0xfeU | m_txd); }); - qs1000.add_route(0, "lspeaker", 0.25); - qs1000.add_route(1, "rspeaker", 0.25); + qs1000.add_route(0, "speaker", 0.25, 0); + qs1000.add_route(1, "speaker", 0.25, 1); } void ssfindo_state::ppcar(machine_config &config) diff --git a/src/mame/akai/mpc3000.cpp b/src/mame/akai/mpc3000.cpp index b2945bb890d..6e38fa00cc2 100644 --- a/src/mame/akai/mpc3000.cpp +++ b/src/mame/akai/mpc3000.cpp @@ -295,12 +295,11 @@ void mpc3000_state::mpc3000(machine_config &config) spc.out_dreq_callback().set(m_maincpu, FUNC(v53a_device::dreq_w<0>)); }); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); L7A1045(config, m_dsp, 16_MHz_XTAL); - m_dsp->add_route(0, "lspeaker", 1.0); - m_dsp->add_route(1, "rspeaker", 1.0); + m_dsp->add_route(0, "speaker", 1.0, 0); + m_dsp->add_route(1, "speaker", 1.0, 1); } static INPUT_PORTS_START( mpc3000 ) diff --git a/src/mame/alesis/alesis_a.cpp b/src/mame/alesis/alesis_a.cpp index bc48b0f234c..27d8c6231e4 100644 --- a/src/mame/alesis/alesis_a.cpp +++ b/src/mame/alesis/alesis_a.cpp @@ -47,11 +47,9 @@ alesis_dm3ag_device::alesis_dm3ag_device(const machine_config &mconfig, const ch void alesis_dm3ag_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker1").front_left(); - SPEAKER(config, "rspeaker1").front_right(); - SPEAKER(config, "lspeaker2").front_left(); - SPEAKER(config, "rspeaker2").front_right(); - PCM54HP(config, m_dac, 0).add_route(ALL_OUTPUTS, "lspeaker1", 1.0).add_route(ALL_OUTPUTS, "rspeaker1", 1.0); // PCM54HP DAC + R63/R73-75 + Sample and hold + SPEAKER(config, "speaker1").front(); + SPEAKER(config, "speaker2").front(); + PCM54HP(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker1", 1.0, 0).add_route(ALL_OUTPUTS, "speaker1", 1.0, 1); // PCM54HP DAC + R63/R73-75 + Sample and hold } //------------------------------------------------- diff --git a/src/mame/alesis/midiverb.cpp b/src/mame/alesis/midiverb.cpp index 00bf021c651..66dbc5775b0 100644 --- a/src/mame/alesis/midiverb.cpp +++ b/src/mame/alesis/midiverb.cpp @@ -37,17 +37,10 @@ MIDI is optional, and can be configured as follows: ./mame -listmidi # List MIDI devices, physical or virtual (e.g. DAWs). ./mame -window midiverb -midiin "{midi device}" -Audio inputs are emulated using MAME's sample playback mechanism. -- Create a new directory `midiverb` under the `samples` MAME directory. -- Copy the .wav files to be used as audio inputs into that directory. Use names: - left.wav and right.wav for the left and right input respectively. Note that - MAME does not support stereo .wav files, so they need to be separate. It is - also fine to just include one of the two files. -- When the emulation is running, press Space to trigger the processing of those - files. -- Look out for any errors, such as unsupported file format. -- If there is distortion or crackling, adjust INPUT LEVEL (in the Slider - Controls menu). +Audio inputs are emulated using MAME's audio input capabilities. + +- Select your input through the audio mixer menu. You can adjust level there too. + - Use the "DRY/WET MIX" Slider Control to adjust the wet/dry ratio. */ @@ -60,7 +53,6 @@ Audio inputs are emulated using MAME's sample playback mechanism. #include "sound/flt_biquad.h" #include "sound/flt_rc.h" #include "sound/mixer.h" -#include "sound/samples.h" #include "video/pwm.h" #include "speaker.h" @@ -85,7 +77,7 @@ public: protected: void device_start() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: u16 analog_to_digital(float sample) const; @@ -147,20 +139,14 @@ void midiverb_dsp_device::device_start() LOGMASKED(LOG_DSP_EXECUTION, __VA_ARGS__); \ } while(0) -void midiverb_dsp_device::sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) +void midiverb_dsp_device::sound_stream_update(sound_stream &stream) { static constexpr const u8 MAX_PC = 0x7f; static constexpr const int DEBUG_SAMPLES = 2; static constexpr const char* const OP_NAME[4] = { "ADDHF", "LDHF ", "STPOS", "STNEG" }; - assert(inputs.size() == 1); - assert(outputs.size() == 2); - - const read_stream_view &in = inputs[0]; - write_stream_view &left = outputs[0]; - write_stream_view &right = outputs[1]; - const int n = in.samples(); + const int n = stream.samples(); const u16 rom_base = u16(m_program) << 8; for (int sample_i = 0; sample_i < n; ++sample_i) @@ -200,7 +186,7 @@ void midiverb_dsp_device::sound_stream_update(sound_stream &stream, const std::v int num_bus_writes = 0; if (mode_rc0) { - bus_value = analog_to_digital(in.get(sample_i)); + bus_value = analog_to_digital(stream.get(0, sample_i)); ++num_bus_writes; } if (rd_r0) @@ -229,9 +215,9 @@ void midiverb_dsp_device::sound_stream_update(sound_stream &stream, const std::v if (ld_dac) { if (dac_left) - left.put(sample_i, digital_to_analog(bus_value)); + stream.put(0, sample_i, digital_to_analog(bus_value)); else - right.put(sample_i, digital_to_analog(bus_value)); + stream.put(1, sample_i, digital_to_analog(bus_value)); } if (clear_acc) @@ -305,7 +291,6 @@ public: , m_digit_device(*this, "pwm_digit_device") , m_digit_out(*this, "digit_%d", 1U) , m_mix(*this, "mix") - , m_input_level(*this, "audio_input_level") , m_audio_in(*this, "audio_input") , m_dsp(*this, "discrete_dsp") , m_left_out(*this, "left_mixer_out") @@ -316,8 +301,6 @@ public: void midiverb(machine_config &config) ATTR_COLD; DECLARE_INPUT_CHANGED_MEMBER(mix_changed); - DECLARE_INPUT_CHANGED_MEMBER(audio_input_play); - DECLARE_INPUT_CHANGED_MEMBER(audio_input_level); protected: void machine_start() override ATTR_COLD; @@ -331,7 +314,6 @@ private: void digit_out_update_w(offs_t offset, u8 data); void update_mix(); - void update_audio_input_level(); void program_map(address_map &map) ATTR_COLD; void external_memory_map(address_map &map) ATTR_COLD; @@ -341,8 +323,7 @@ private: required_device<pwm_display_device> m_digit_device; output_finder<2> m_digit_out; // 2 x MAN4710A (7-seg display), DS1 & DS2. required_ioport m_mix; - required_ioport m_input_level; - required_device<samples_device> m_audio_in; + required_device<microphone_device> m_audio_in; required_device<midiverb_dsp_device> m_dsp; required_device<mixer_device> m_left_out; required_device<mixer_device> m_right_out; @@ -409,13 +390,6 @@ void midiverb_state::update_mix() m_right_out->set_input_gain(1, wet); } -void midiverb_state::update_audio_input_level() -{ - const float gain = m_input_level->read() / 100.0F; - m_audio_in->set_output_gain(LEFT_CHANNEL, gain); - m_audio_in->set_output_gain(RIGHT_CHANNEL, gain); -} - void midiverb_state::program_map(address_map &map) { // 2764 ROM has A0-A11 connected to the MCU, and A12 tied high. ROM /OE @@ -429,26 +403,17 @@ void midiverb_state::external_memory_map(address_map &map) map(0x0000, 0x0000).mirror(0xffff).w(FUNC(midiverb_state::digit_latch_w)); } -static const char *const midiverb_sample_names[] = -{ - "left", - "right", - nullptr -}; - void midiverb_state::configure_audio(machine_config &config) { static constexpr const double SK_R3 = RES_M(999.99); static constexpr const double SK_R4 = RES_R(0.001); - // Audio input. Emulated with a "samples" device. - SAMPLES(config, m_audio_in); - m_audio_in->set_samples_names(midiverb_sample_names); - m_audio_in->set_channels(2); + // Audio input. + MICROPHONE(config, m_audio_in, 2).front(); // According to the user manual, input levels can be up to +6 dBV peak when // a single input is connected, or 0 dBV when both are connected. 0 dBV - // means the input voltage can peak at +/- 1.414V. The Samples device + // means the input voltage can peak at +/- 1.414V. The microphone device // returns samples in the range +/- 1. So we can just treat those as // voltages. @@ -545,19 +510,18 @@ void midiverb_state::configure_audio(machine_config &config) // corresponding original (dry) channel, based on the position of a // user-accessible, dual-gang potentiometer. MIXER(config, m_left_out); - left_amp_in.add_route(0, m_left_out, 1.0); - left_sk_out.add_route(0, m_left_out, 1.0); + left_amp_in.add_route(0, m_left_out, 1.0, 0); + left_sk_out.add_route(0, m_left_out, 1.0, 1); MIXER(config, m_right_out); - right_amp_in.add_route(0, m_right_out, 1.0); - right_sk_out.add_route(0, m_right_out, 1.0); + right_amp_in.add_route(0, m_right_out, 1.0, 0); + right_sk_out.add_route(0, m_right_out, 1.0, 1); // Finally, the signals are attenuated to line level, undoing the ~5x // amplification at the input. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); const double output_gain = RES_VOLTAGE_DIVIDER(RES_K(2.4), RES_R(500)); - m_left_out->add_route(ALL_OUTPUTS, "lspeaker", output_gain); - m_right_out->add_route(ALL_OUTPUTS, "rspeaker", output_gain); + m_left_out->add_route(ALL_OUTPUTS, "speaker", output_gain, 0); + m_right_out->add_route(ALL_OUTPUTS, "speaker", output_gain, 1); } void midiverb_state::machine_start() @@ -571,7 +535,6 @@ void midiverb_state::machine_start() void midiverb_state::machine_reset() { update_mix(); - update_audio_input_level(); } void midiverb_state::midiverb(machine_config &config) @@ -604,19 +567,6 @@ DECLARE_INPUT_CHANGED_MEMBER(midiverb_state::mix_changed) update_mix(); } -DECLARE_INPUT_CHANGED_MEMBER(midiverb_state::audio_input_play) -{ - if (newval == 0) - return; - m_audio_in->start(LEFT_CHANNEL, 0); - m_audio_in->start(RIGHT_CHANNEL, 1); -} - -DECLARE_INPUT_CHANGED_MEMBER(midiverb_state::audio_input_level) -{ - update_audio_input_level(); -} - INPUT_PORTS_START(midiverb) PORT_START("buttons") PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_OTHER) PORT_NAME("MIDI CHANNEL") PORT_CODE(KEYCODE_C) @@ -627,17 +577,6 @@ INPUT_PORTS_START(midiverb) PORT_START("mix") // MIX potentiometer at the back of the unit. PORT_ADJUSTER(100, "DRY/WET MIX") PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(midiverb_state::mix_changed), 0) - - // The following are not controls on the real unit. - // They control audio input. - - PORT_START("audio_input_control") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_OTHER) PORT_NAME("PLAY") PORT_CODE(KEYCODE_SPACE) - PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(midiverb_state::audio_input_play), 0) - - PORT_START("audio_input_level") - PORT_ADJUSTER(90, "INPUT LEVEL") - PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(midiverb_state::audio_input_level), 0) INPUT_PORTS_END ROM_START(midiverb) diff --git a/src/mame/amiga/akiko.cpp b/src/mame/amiga/akiko.cpp index be5d02c23c2..57f930e95ac 100644 --- a/src/mame/amiga/akiko.cpp +++ b/src/mame/amiga/akiko.cpp @@ -55,8 +55,8 @@ void akiko_device::device_add_mconfig(machine_config &config) { CDROM(config, m_cdrom).set_interface("cdrom"); CDDA(config, m_cdda); - m_cdda->add_route(0, ":lspeaker", 0.50); - m_cdda->add_route(1, ":rspeaker", 0.50); + m_cdda->add_route(0, ":speaker", 0.50, 0); + m_cdda->add_route(1, ":speaker", 0.50, 1); m_cdda->set_cdrom_tag(m_cdrom); } diff --git a/src/mame/amiga/alg.cpp b/src/mame/amiga/alg.cpp index cc9cfb843ea..ca0f625402e 100644 --- a/src/mame/amiga/alg.cpp +++ b/src/mame/amiga/alg.cpp @@ -356,19 +356,18 @@ void alg_state::alg_r1(machine_config &config) MCFG_VIDEO_START_OVERRIDE(alg_state,alg) // Sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PAULA_8364(config, m_paula, amiga_state::CLK_C1_NTSC); - m_paula->add_route(0, "lspeaker", 0.25); - m_paula->add_route(1, "rspeaker", 0.25); - m_paula->add_route(2, "rspeaker", 0.25); - m_paula->add_route(3, "lspeaker", 0.25); + m_paula->add_route(0, "speaker", 0.25, 0); + m_paula->add_route(1, "speaker", 0.25, 1); + m_paula->add_route(2, "speaker", 0.25, 1); + m_paula->add_route(3, "speaker", 0.25, 0); m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); // cia MOS8520(config, m_cia_0, amiga_state::CLK_E_NTSC); diff --git a/src/mame/amiga/amiga.cpp b/src/mame/amiga/amiga.cpp index ac82186d1bf..350aabe92cb 100644 --- a/src/mame/amiga/amiga.cpp +++ b/src/mame/amiga/amiga.cpp @@ -1725,13 +1725,12 @@ void amiga_state::amiga_base(machine_config &config) m_cia_1->pb_wr_callback().set(m_fdc, FUNC(paula_fdc_device::ciaaprb_w)); // audio - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PAULA_8364(config, m_paula, amiga_state::CLK_C1_PAL); - m_paula->add_route(0, "lspeaker", 0.50); - m_paula->add_route(1, "rspeaker", 0.50); - m_paula->add_route(2, "rspeaker", 0.50); - m_paula->add_route(3, "lspeaker", 0.50); + m_paula->add_route(0, "speaker", 0.50, 0); + m_paula->add_route(1, "speaker", 0.50, 1); + m_paula->add_route(2, "speaker", 0.50, 1); + m_paula->add_route(3, "speaker", 0.50, 0); m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); @@ -1979,8 +1978,8 @@ void cdtv_state::cdtv(machine_config &config) m_tpi->out_pb_cb().set(FUNC(cdtv_state::tpi_portb_w)); CR511B(config, m_cdrom, 0); - m_cdrom->add_route(0, "lspeaker", 1.0); - m_cdrom->add_route(1, "rspeaker", 1.0); + m_cdrom->add_route(0, "speaker", 1.0, 0); + m_cdrom->add_route(1, "speaker", 1.0, 1); m_cdrom->scor_cb().set(m_tpi, FUNC(tpi6525_device::i1_w)).invert(); m_cdrom->stch_cb().set(m_tpi, FUNC(tpi6525_device::i2_w)).invert(); m_cdrom->sten_cb().set(m_tpi, FUNC(tpi6525_device::i3_w)); diff --git a/src/mame/amiga/arsystems.cpp b/src/mame/amiga/arsystems.cpp index d717618fcfa..7385e2773b0 100644 --- a/src/mame/amiga/arsystems.cpp +++ b/src/mame/amiga/arsystems.cpp @@ -342,14 +342,13 @@ void arcadia_amiga_state::arcadia(machine_config &config) MCFG_VIDEO_START_OVERRIDE(arcadia_amiga_state,amiga) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PAULA_8364(config, m_paula, amiga_state::CLK_C1_NTSC); - m_paula->add_route(0, "lspeaker", 0.50); - m_paula->add_route(1, "rspeaker", 0.50); - m_paula->add_route(2, "rspeaker", 0.50); - m_paula->add_route(3, "lspeaker", 0.50); + m_paula->add_route(0, "speaker", 0.50, 0); + m_paula->add_route(1, "speaker", 0.50, 1); + m_paula->add_route(2, "speaker", 0.50, 1); + m_paula->add_route(3, "speaker", 0.50, 0); m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); diff --git a/src/mame/amiga/cubo.cpp b/src/mame/amiga/cubo.cpp index 5d0cea2dbd8..04b139d030d 100644 --- a/src/mame/amiga/cubo.cpp +++ b/src/mame/amiga/cubo.cpp @@ -1133,14 +1133,13 @@ void cubo_state::cubo(machine_config &config) MCFG_VIDEO_START_OVERRIDE(amiga_state, amiga_aga) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PAULA_8364(config, m_paula, amiga_state::CLK_C1_PAL); - m_paula->add_route(0, "lspeaker", 0.25); - m_paula->add_route(1, "rspeaker", 0.25); - m_paula->add_route(2, "rspeaker", 0.25); - m_paula->add_route(3, "lspeaker", 0.25); + m_paula->add_route(0, "speaker", 0.25, 0); + m_paula->add_route(1, "speaker", 0.25, 1); + m_paula->add_route(2, "speaker", 0.25, 1); + m_paula->add_route(3, "speaker", 0.25, 0); m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); diff --git a/src/mame/amiga/mquake.cpp b/src/mame/amiga/mquake.cpp index 6b1f5815a25..880640b2f35 100644 --- a/src/mame/amiga/mquake.cpp +++ b/src/mame/amiga/mquake.cpp @@ -339,22 +339,21 @@ void mquake_state::mquake(machine_config &config) MCFG_VIDEO_START_OVERRIDE(mquake_state,amiga) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PAULA_8364(config, m_paula, amiga_state::CLK_C1_NTSC); - m_paula->add_route(0, "lspeaker", 0.50); - m_paula->add_route(1, "rspeaker", 0.50); - m_paula->add_route(2, "rspeaker", 0.50); - m_paula->add_route(3, "lspeaker", 0.50); + m_paula->add_route(0, "speaker", 0.50, 0); + m_paula->add_route(1, "speaker", 0.50, 1); + m_paula->add_route(2, "speaker", 0.50, 1); + m_paula->add_route(3, "speaker", 0.50, 0); m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); ES5503(config, m_es5503, amiga_state::CLK_7M_NTSC); /* ES5503 is likely mono due to channel strobe used as bank select */ m_es5503->set_channels(1); m_es5503->set_addrmap(0, &mquake_state::mquake_es5503_map); - m_es5503->add_route(0, "lspeaker", 0.50); - m_es5503->add_route(0, "rspeaker", 0.50); + m_es5503->add_route(0, "speaker", 0.50, 0); + m_es5503->add_route(0, "speaker", 0.50, 1); /* cia */ MOS8520(config, m_cia_0, amiga_state::CLK_E_NTSC); diff --git a/src/mame/amiga/paula.cpp b/src/mame/amiga/paula.cpp index cd3627157e6..307ffe14ae3 100644 --- a/src/mame/amiga/paula.cpp +++ b/src/mame/amiga/paula.cpp @@ -273,7 +273,7 @@ std::string paula_device::print_audio_state() // sound_stream_update - handle a stream update //------------------------------------------------- -void paula_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void paula_device::sound_stream_update(sound_stream &stream) { int channum, sampoffs = 0; @@ -284,14 +284,10 @@ void paula_device::sound_stream_update(sound_stream &stream, std::vector<read_st m_channel[1].dma_enabled = m_channel[2].dma_enabled = m_channel[3].dma_enabled = false; - - // clear the sample data to 0 - for (channum = 0; channum < 4; channum++) - outputs[channum].fill(0); return; } - int samples = outputs[0].samples() * CLOCK_DIVIDER; + int samples = stream.samples() * CLOCK_DIVIDER; if (LIVE_AUDIO_VIEW) popmessage(print_audio_state()); @@ -351,7 +347,7 @@ void paula_device::sound_stream_update(sound_stream &stream, std::vector<read_st // fill the buffer with the sample for (i = 0; i < ticks; i += CLOCK_DIVIDER) - outputs[channum].put_int_clamp((sampoffs + i) / CLOCK_DIVIDER, sample, 32768); + stream.put_int_clamp(channum, (sampoffs + i) / CLOCK_DIVIDER, sample, 32768); // account for the ticks; if we hit 0, advance chan->curticks -= ticks; diff --git a/src/mame/amiga/paula.h b/src/mame/amiga/paula.h index f5d822e70a4..62461ba27b4 100644 --- a/src/mame/amiga/paula.h +++ b/src/mame/amiga/paula.h @@ -65,7 +65,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: template <u8 ch> void audxlch_w(u16 data); diff --git a/src/mame/amiga/upscope.cpp b/src/mame/amiga/upscope.cpp index 4caa4f0bc4e..c4c544f4ada 100644 --- a/src/mame/amiga/upscope.cpp +++ b/src/mame/amiga/upscope.cpp @@ -288,14 +288,13 @@ void upscope_state::upscope(machine_config &config) MCFG_VIDEO_START_OVERRIDE(upscope_state,amiga) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PAULA_8364(config, m_paula, amiga_state::CLK_C1_NTSC); - m_paula->add_route(0, "rspeaker", 0.50); - m_paula->add_route(1, "lspeaker", 0.50); - m_paula->add_route(2, "lspeaker", 0.50); - m_paula->add_route(3, "rspeaker", 0.50); + m_paula->add_route(0, "speaker", 0.50, 1); + m_paula->add_route(1, "speaker", 0.50, 0); + m_paula->add_route(2, "speaker", 0.50, 0); + m_paula->add_route(3, "speaker", 0.50, 1); m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); diff --git a/src/mame/apple/apple2gs.cpp b/src/mame/apple/apple2gs.cpp index 5ebfceda441..4eb4c1bd43a 100644 --- a/src/mame/apple/apple2gs.cpp +++ b/src/mame/apple/apple2gs.cpp @@ -3833,16 +3833,15 @@ void apple2gs_state::apple2gs(machine_config &config) SPEAKER(config, "mono").front_center(); SPEAKER_SOUND(config, m_speaker).add_route(ALL_OUTPUTS, "mono", 1.00); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ES5503(config, m_doc, A2GS_7M); m_doc->set_channels(2); m_doc->set_addrmap(0, &apple2gs_state::a2gs_es5503_map); m_doc->irq_func().set(FUNC(apple2gs_state::doc_irq_w)); m_doc->adc_func().set(FUNC(apple2gs_state::doc_adc_read)); // IIgs Tech Node #19 says even channels are right, odd are left, and 80s/90s stereo cards followed that. - m_doc->add_route(0, "rspeaker", 1.0); - m_doc->add_route(1, "lspeaker", 1.0); + m_doc->add_route(0, "speaker", 1.0, 1); + m_doc->add_route(1, "speaker", 1.0, 0); /* RAM */ RAM(config, m_ram).set_default_size("2M").set_extra_options("1M,3M,4M,5M,6M,7M,8M").set_default_value(0x00); diff --git a/src/mame/apple/awacs_macrisc.cpp b/src/mame/apple/awacs_macrisc.cpp index f40c8e11013..4e4735180fa 100644 --- a/src/mame/apple/awacs_macrisc.cpp +++ b/src/mame/apple/awacs_macrisc.cpp @@ -92,7 +92,7 @@ void screamer_device::device_reset() // our sound stream //------------------------------------------------- -void awacs_macrisc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void awacs_macrisc_device::sound_stream_update(sound_stream &stream) { // if we're active and not muted if ((m_active & ACTIVE_OUT) && !(m_registers[1] & REGISTER_1_MUTE)) @@ -106,13 +106,13 @@ void awacs_macrisc_device::sound_stream_update(sound_stream &stream, std::vector const s32 left = ((s32)l_raw * atten_L) >> 4; const s32 right = ((s32)r_raw * atten_R) >> 4; - outputs[0].put_int(0, left, 32768); - outputs[1].put_int(0, right, 32768); + stream.put_int(0, 0, left, 32768); + stream.put_int(1, 0, right, 32768); } else { - outputs[0].put_int(0, 0, 32768); - outputs[1].put_int(0, 0, 32768); + stream.put_int(0, 0, 0, 32768); + stream.put_int(1, 0, 0, 32768); } m_phase = (m_phase + 1) & 0xfff; diff --git a/src/mame/apple/awacs_macrisc.h b/src/mame/apple/awacs_macrisc.h index 02e3109f848..21aec3c188a 100644 --- a/src/mame/apple/awacs_macrisc.h +++ b/src/mame/apple/awacs_macrisc.h @@ -45,7 +45,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; devcb_read32 m_output_cb; devcb_write32 m_input_cb; diff --git a/src/mame/apple/burgundy.cpp b/src/mame/apple/burgundy.cpp index 2865b9e5574..995e64bae93 100644 --- a/src/mame/apple/burgundy.cpp +++ b/src/mame/apple/burgundy.cpp @@ -74,7 +74,7 @@ void burgundy_device::device_reset() // our sound stream //------------------------------------------------- -void burgundy_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void burgundy_device::sound_stream_update(sound_stream &stream) { if (m_codec_status & CODEC_BUSY) { @@ -88,13 +88,13 @@ void burgundy_device::sound_stream_update(sound_stream &stream, std::vector<read const u32 data = swapendian_int32(m_output_cb(m_phase)); const s16 left = data >> 16; const s16 right = data; - outputs[0].put_int(0, left, 32768); - outputs[1].put_int(0, right, 32768); + stream.put_int(0, 0, left, 32768); + stream.put_int(1, 0, right, 32768); } else { - outputs[0].put_int(0, 0, 32768); - outputs[1].put_int(0, 0, 32768); + stream.put_int(0, 0, 0, 32768); + stream.put_int(1, 0, 0, 32768); } m_phase = (m_phase + 1) & 0xfff; diff --git a/src/mame/apple/burgundy.h b/src/mame/apple/burgundy.h index 69950fc952a..f46065a8d25 100644 --- a/src/mame/apple/burgundy.h +++ b/src/mame/apple/burgundy.h @@ -41,7 +41,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; devcb_read32 m_output_cb; devcb_write32 m_input_cb; diff --git a/src/mame/apple/dfac.cpp b/src/mame/apple/dfac.cpp index 38e0c893350..95e6443c607 100644 --- a/src/mame/apple/dfac.cpp +++ b/src/mame/apple/dfac.cpp @@ -122,25 +122,19 @@ void dfac_device::device_start() save_item(NAME(m_settings_byte)); } -void dfac_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dfac_device::sound_stream_update(sound_stream &stream) { if (BIT(m_settings_byte, 1)) // LPF In can go through to Amp Out { - for (int i = 0; i < inputs[0].samples(); i++) - { - stream_buffer::sample_t l = inputs[0].get(i); - stream_buffer::sample_t r = inputs[1].get(i); - outputs[0].put(i, l * atten_table[m_settings_byte >> 5]); - outputs[1].put(i, r * atten_table[m_settings_byte >> 5]); - } + sound_stream::sample_t l = stream.get(0, 0); + sound_stream::sample_t r = stream.get(1, 0); + stream.put(0, 0, l * atten_table[m_settings_byte >> 5]); + stream.put(1, 0, r * atten_table[m_settings_byte >> 5]); } else { - for (int i = 0; i < inputs[0].samples(); i++) - { - outputs[0].put(i, 0.0); - outputs[1].put(i, 0.0); - } + stream.put(0, 0, 0.0); + stream.put(1, 0, 0.0); } } diff --git a/src/mame/apple/dfac.h b/src/mame/apple/dfac.h index 7936f04e57b..e34fca0d765 100644 --- a/src/mame/apple/dfac.h +++ b/src/mame/apple/dfac.h @@ -21,7 +21,7 @@ protected: // device_r overrides virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/mame/apple/f108.cpp b/src/mame/apple/f108.cpp index a7df93e9a99..01b8e914d6d 100644 --- a/src/mame/apple/f108.cpp +++ b/src/mame/apple/f108.cpp @@ -59,8 +59,8 @@ void f108_device::device_add_mconfig(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^^primetimeii:lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^^primetimeii:rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^^primetimeii:speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^^primetimeii:speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); diff --git a/src/mame/apple/imacg3.cpp b/src/mame/apple/imacg3.cpp index bd941ee170b..caeda269d54 100644 --- a/src/mame/apple/imacg3.cpp +++ b/src/mame/apple/imacg3.cpp @@ -213,10 +213,9 @@ void imac_state::imac(machine_config &config) paddington.codec_r_callback().set(burgundy, FUNC(burgundy_device::read_macrisc)); paddington.codec_w_callback().set(burgundy, FUNC(burgundy_device::write_macrisc)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - burgundy.add_route(0, "lspeaker", 1.0); - burgundy.add_route(1, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + burgundy.add_route(0, "speaker", 1.0, 0); + burgundy.add_route(1, "speaker", 1.0, 1); } ROM_START(imac) diff --git a/src/mame/apple/iosb.cpp b/src/mame/apple/iosb.cpp index 8a8a226067c..2b636a299fe 100644 --- a/src/mame/apple/iosb.cpp +++ b/src/mame/apple/iosb.cpp @@ -84,11 +84,10 @@ void iosb_base::device_add_mconfig(machine_config &config) m_via2->writepb_handler().set(FUNC(iosb_base::via2_out_b)); m_via2->irq_handler().set(FUNC(iosb_base::via2_irq)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_asc, C15M, asc_device::asc_type::SONORA); - m_asc->add_route(0, "lspeaker", 1.0); - m_asc->add_route(1, "rspeaker", 1.0); + m_asc->add_route(0, "speaker", 1.0, 0); + m_asc->add_route(1, "speaker", 1.0, 1); m_asc->irqf_callback().set(FUNC(iosb_base::asc_irq)); SWIM2(config, m_fdc, C15M); diff --git a/src/mame/apple/mac128.cpp b/src/mame/apple/mac128.cpp index a09b36d2a39..c06f9eee942 100644 --- a/src/mame/apple/mac128.cpp +++ b/src/mame/apple/mac128.cpp @@ -1161,8 +1161,7 @@ void mac128_state::macplus(machine_config &config) // SCSI bus and devices // These machines were strictly external CD-ROMs so sound didn't route back into them; the AppleCD SC had // RCA jacks for connection to speakers/a stereo. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); NSCSI_BUS(config, m_scsibus); NSCSI_CONNECTOR(config, "scsi:0", mac_scsi_devices, nullptr); @@ -1171,8 +1170,8 @@ void mac128_state::macplus(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); diff --git a/src/mame/apple/macii.cpp b/src/mame/apple/macii.cpp index 987306e743c..70e632a5e26 100644 --- a/src/mame/apple/macii.cpp +++ b/src/mame/apple/macii.cpp @@ -927,12 +927,11 @@ void macii_state::macii(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &macii_state::macii_map); m_maincpu->set_dasm_override(std::function(&mac68k_dasm_override), "mac68k_dasm_override"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_asc, C15M, asc_device::asc_type::ASC); m_asc->irqf_callback().set(FUNC(macii_state::mac_asc_irq)); - m_asc->add_route(0, "lspeaker", 1.0); - m_asc->add_route(1, "rspeaker", 1.0); + m_asc->add_route(0, "speaker", 1.0, 0); + m_asc->add_route(1, "speaker", 1.0, 1); RTC3430042(config, m_rtc, XTAL(32'768)); m_rtc->cko_cb().set(m_via1, FUNC(via6522_device::write_ca2)); @@ -965,8 +964,8 @@ void macii_state::macii(machine_config &config) NSCSI_CONNECTOR(config, "scsi:2", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config([](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); }); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:6", mac_scsi_devices, "harddisk"); diff --git a/src/mame/apple/maciici.cpp b/src/mame/apple/maciici.cpp index 7ecf3e9089c..333176d606a 100644 --- a/src/mame/apple/maciici.cpp +++ b/src/mame/apple/maciici.cpp @@ -545,12 +545,11 @@ void maciici_state::maciixi_base(machine_config &config) rs232b.dcd_handler().set(m_scc, FUNC(z80scc_device::dcdb_w)); rs232b.cts_handler().set(m_scc, FUNC(z80scc_device::ctsb_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_asc, C15M, asc_device::asc_type::ASC); m_asc->irqf_callback().set(m_rbv, FUNC(rbv_device::asc_irq_w)); - m_asc->add_route(0, "lspeaker", 1.0); - m_asc->add_route(1, "rspeaker", 1.0); + m_asc->add_route(0, "speaker", 1.0, 0); + m_asc->add_route(1, "speaker", 1.0, 1); R65NC22(config, m_via1, C7M / 10); m_via1->readpa_handler().set(FUNC(maciici_state::via_in_a)); @@ -567,8 +566,8 @@ void maciici_state::maciixi_base(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); diff --git a/src/mame/apple/maciifx.cpp b/src/mame/apple/maciifx.cpp index 04c9eef62a4..a96325156ed 100644 --- a/src/mame/apple/maciifx.cpp +++ b/src/mame/apple/maciifx.cpp @@ -449,11 +449,10 @@ void maciifx_state::maciifx(machine_config &config) m_scsidma->set_maincpu_tag("maincpu"); m_scsidma->write_irq().set(FUNC(maciifx_state::oss_interrupt<9>)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_asc, C15M, asc_device::asc_type::ASC); - m_asc->add_route(0, "lspeaker", 1.0); - m_asc->add_route(1, "rspeaker", 1.0); + m_asc->add_route(0, "speaker", 1.0, 0); + m_asc->add_route(1, "speaker", 1.0, 1); m_asc->irqf_callback().set(FUNC(maciifx_state::oss_interrupt<8>)); R65NC22(config, m_via1, C7M / 10); diff --git a/src/mame/apple/maciivx.cpp b/src/mame/apple/maciivx.cpp index 2c8699fe7d8..90ee8c2add8 100644 --- a/src/mame/apple/maciivx.cpp +++ b/src/mame/apple/maciivx.cpp @@ -320,8 +320,8 @@ void maciivx_state::maciiv_base(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); @@ -360,12 +360,11 @@ void maciivx_state::maciiv_base(machine_config &config) rs232b.dcd_handler().set(m_scc, FUNC(z80scc_device::dcdb_w)); rs232b.cts_handler().set(m_scc, FUNC(z80scc_device::ctsb_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); APPLE_DFAC(config, m_dfac, 22257); - m_dfac->add_route(0, "lspeaker", 1.0); - m_dfac->add_route(1, "rspeaker", 1.0); + m_dfac->add_route(0, "speaker", 1.0, 0); + m_dfac->add_route(1, "speaker", 1.0, 1); VASP(config, m_vasp, C15M); m_vasp->set_maincpu_tag("maincpu"); diff --git a/src/mame/apple/maclc.cpp b/src/mame/apple/maclc.cpp index 422aa1ca682..b260b7029b2 100644 --- a/src/mame/apple/maclc.cpp +++ b/src/mame/apple/maclc.cpp @@ -346,8 +346,8 @@ void maclc_state::maclc_base(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); @@ -386,12 +386,11 @@ void maclc_state::maclc_base(machine_config &config) rs232b.dcd_handler().set(m_scc, FUNC(z80scc_device::dcdb_w)); rs232b.cts_handler().set(m_scc, FUNC(z80scc_device::ctsb_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); APPLE_DFAC(config, m_dfac, 22257); - m_dfac->add_route(0, "lspeaker", 1.0); - m_dfac->add_route(1, "rspeaker", 1.0); + m_dfac->add_route(0, "speaker", 1.0, 0); + m_dfac->add_route(1, "speaker", 1.0, 1); V8(config, m_v8, C15M); m_v8->set_maincpu_tag("maincpu"); @@ -494,8 +493,8 @@ void maclc_state::maccclas(machine_config &config) m_v8->pb4_callback().set(m_cuda, FUNC(cuda_device::set_byteack)); m_v8->pb5_callback().set(m_cuda, FUNC(cuda_device::set_tip)); m_v8->cb2_callback().set(m_cuda, FUNC(cuda_device::set_via_data)); - m_v8->add_route(0, "lspeaker", 1.0); - m_v8->add_route(1, "rspeaker", 1.0); + m_v8->add_route(0, "speaker", 1.0, 0); + m_v8->add_route(1, "speaker", 1.0, 1); config.device_remove("dfac"); @@ -539,8 +538,8 @@ void maclc_state::mactv(machine_config &config) m_v8->pb4_callback().set(m_cuda, FUNC(cuda_device::set_byteack)); m_v8->pb5_callback().set(m_cuda, FUNC(cuda_device::set_tip)); m_v8->cb2_callback().set(m_cuda, FUNC(cuda_device::set_via_data)); - m_v8->add_route(0, "lspeaker", 1.0); - m_v8->add_route(1, "rspeaker", 1.0); + m_v8->add_route(0, "speaker", 1.0, 0); + m_v8->add_route(1, "speaker", 1.0, 1); config.device_remove("dfac"); diff --git a/src/mame/apple/maclc3.cpp b/src/mame/apple/maclc3.cpp index 2c28aaebcae..6b5c2089327 100644 --- a/src/mame/apple/maclc3.cpp +++ b/src/mame/apple/maclc3.cpp @@ -269,8 +269,8 @@ void macvail_state::maclc3_base(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); @@ -309,12 +309,11 @@ void macvail_state::maclc3_base(machine_config &config) rs232b.dcd_handler().set(m_scc, FUNC(z80scc_device::dcdb_w)); rs232b.cts_handler().set(m_scc, FUNC(z80scc_device::ctsb_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); APPLE_DFAC(config, m_dfac, 22257); - m_dfac->add_route(0, "lspeaker", 1.0); - m_dfac->add_route(1, "rspeaker", 1.0); + m_dfac->add_route(0, "speaker", 1.0, 0); + m_dfac->add_route(1, "speaker", 1.0, 1); APPLE_OMEGA(config, m_omega, 31.3344_MHz_XTAL); m_omega->pclock_changed().set(m_sonora, FUNC(sonora_device::pixel_clock_w)); @@ -396,8 +395,8 @@ void macvail_state::maclc520(machine_config &config) // DFAC only is found in machines with Egret, and not the IIsi m_sonora->reset_routes(); - m_sonora->add_route(0, "lspeaker", 1.0); - m_sonora->add_route(1, "rspeaker", 1.0); + m_sonora->add_route(0, "speaker", 1.0, 0); + m_sonora->add_route(1, "speaker", 1.0, 1); config.device_remove("dfac"); } diff --git a/src/mame/apple/macpdm.cpp b/src/mame/apple/macpdm.cpp index bfe708f806e..46962ebeb12 100644 --- a/src/mame/apple/macpdm.cpp +++ b/src/mame/apple/macpdm.cpp @@ -1182,8 +1182,7 @@ void macpdm_state::macpdm(machine_config &config) m_video->set_PDM(); m_video->screen_vblank().set(FUNC(macpdm_state::vblank_irq)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AWACS(config, m_awacs, SOUND_CLOCK/2); m_awacs->irq_out_cb().set(FUNC(macpdm_state::sndo_dma_irq)); @@ -1191,8 +1190,8 @@ void macpdm_state::macpdm(machine_config &config) m_awacs->dma_output().set(FUNC(macpdm_state::sound_dma_output)); m_awacs->dma_input().set(FUNC(macpdm_state::sound_dma_input)); - m_awacs->add_route(0, "lspeaker", 1.0); - m_awacs->add_route(1, "rspeaker", 1.0); + m_awacs->add_route(0, "speaker", 1.0, 0); + m_awacs->add_route(1, "speaker", 1.0, 1); NSCSI_BUS(config, m_scsibus); NSCSI_CONNECTOR(config, "scsi:0", default_scsi_devices, "harddisk"); @@ -1201,8 +1200,8 @@ void macpdm_state::macpdm(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", default_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", default_scsi_devices, nullptr); diff --git a/src/mame/apple/macprtb.cpp b/src/mame/apple/macprtb.cpp index 0e9d8264268..26257de402c 100644 --- a/src/mame/apple/macprtb.cpp +++ b/src/mame/apple/macprtb.cpp @@ -754,8 +754,8 @@ void macportable_state::macprtb(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); @@ -785,12 +785,11 @@ void macportable_state::macprtb(machine_config &config) m_via1->writepb_handler().set(FUNC(macportable_state::via_out_b)); m_via1->irq_handler().set(FUNC(macportable_state::via_irq_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_asc, 15.6672_MHz_XTAL, asc_device::asc_type::ASC); m_asc->irqf_callback().set(FUNC(macportable_state::asc_irq_w)); - m_asc->add_route(0, "lspeaker", 1.0); - m_asc->add_route(1, "rspeaker", 1.0); + m_asc->add_route(0, "speaker", 1.0, 0); + m_asc->add_route(1, "speaker", 1.0, 1); RAM(config, m_ram); m_ram->set_default_size("1M"); diff --git a/src/mame/apple/macpwrbk030.cpp b/src/mame/apple/macpwrbk030.cpp index 258261ee79c..18a23bdacd8 100644 --- a/src/mame/apple/macpwrbk030.cpp +++ b/src/mame/apple/macpwrbk030.cpp @@ -1282,8 +1282,8 @@ void macpb030_state::macpb140(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); @@ -1319,12 +1319,11 @@ void macpb030_state::macpb140(machine_config &config) m_pseudovia->writepb_handler().set(FUNC(macpb030_state::via2_out_b)); m_pseudovia->irq_callback().set(FUNC(macpb030_state::via2_irq_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_asc, 22.5792_MHz_XTAL, asc_device::asc_type::EASC); m_asc->irqf_callback().set(m_pseudovia, FUNC(pseudovia_device::asc_irq_w)); - m_asc->add_route(0, "lspeaker", 1.0); - m_asc->add_route(1, "rspeaker", 1.0); + m_asc->add_route(0, "speaker", 1.0, 0); + m_asc->add_route(1, "speaker", 1.0, 1); RAM(config, m_ram); m_ram->set_default_size("2M"); diff --git a/src/mame/apple/macpwrbkmsc.cpp b/src/mame/apple/macpwrbkmsc.cpp index 6c0a4d104e9..bf9f660cbc8 100644 --- a/src/mame/apple/macpwrbkmsc.cpp +++ b/src/mame/apple/macpwrbkmsc.cpp @@ -804,8 +804,8 @@ void macpbmsc_state::macpd210(machine_config &config) m_msc->vbl_callback().set(FUNC(macpbmsc_state::vbl_w)); APPLE_DFAC(config, m_dfac, 22257); - m_dfac->add_route(0, "lspeaker", 1.0); - m_dfac->add_route(1, "rspeaker", 1.0); + m_dfac->add_route(0, "speaker", 1.0, 0); + m_dfac->add_route(1, "speaker", 1.0, 1); GSC(config, m_gsc, 31.3344_MHz_XTAL); m_gsc->set_panel_id(6); @@ -817,8 +817,8 @@ void macpbmsc_state::macpd210(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); @@ -842,8 +842,7 @@ void macpbmsc_state::macpd210(machine_config &config) DS2401(config, m_battserial, 0); // actually DS2400, but 2400/2401 are compatible - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); RAM(config, m_ram); m_ram->set_default_size("4M"); diff --git a/src/mame/apple/macquadra605.cpp b/src/mame/apple/macquadra605.cpp index 5dd7526e24b..609b18aaa2d 100644 --- a/src/mame/apple/macquadra605.cpp +++ b/src/mame/apple/macquadra605.cpp @@ -189,8 +189,8 @@ void quadra605_state::macqd605(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^primetime:lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^primetime:rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^primetime:speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^primetime:speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); diff --git a/src/mame/apple/macquadra700.cpp b/src/mame/apple/macquadra700.cpp index a18c140fb1a..98d63d3804b 100644 --- a/src/mame/apple/macquadra700.cpp +++ b/src/mame/apple/macquadra700.cpp @@ -759,8 +759,8 @@ void eclipse_state::via2_out_b_q900(u8 data) NSCSI_CONNECTOR(config, "scsi:2", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config([](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); }); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:6", mac_scsi_devices, "harddisk"); @@ -800,12 +800,11 @@ void eclipse_state::via2_out_b_q900(u8 data) MACADB(config, m_macadb, C15M); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASC(config, m_easc, 22.5792_MHz_XTAL, asc_device::asc_type::EASC); m_easc->irqf_callback().set(m_via2, FUNC(via6522_device::write_cb1)).invert(); - m_easc->add_route(0, "lspeaker", 1.0); - m_easc->add_route(1, "rspeaker", 1.0); + m_easc->add_route(0, "speaker", 1.0, 0); + m_easc->add_route(1, "speaker", 1.0, 1); // DFAC is only for audio input on Q700/Q800 APPLE_DFAC(config, m_dfac, 22257); diff --git a/src/mame/apple/macquadra800.cpp b/src/mame/apple/macquadra800.cpp index 9e733f77efb..de1be30f6a1 100644 --- a/src/mame/apple/macquadra800.cpp +++ b/src/mame/apple/macquadra800.cpp @@ -225,8 +225,8 @@ void quadra800_state::macqd800(machine_config &config) NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^iosb:lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^iosb:rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^iosb:speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^iosb:speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); diff --git a/src/mame/apple/msc.cpp b/src/mame/apple/msc.cpp index b5c9aeff0d3..7ffc0742e64 100644 --- a/src/mame/apple/msc.cpp +++ b/src/mame/apple/msc.cpp @@ -160,13 +160,10 @@ void msc_device::device_reset() space.install_rom(0x00000000, memory_end & ~memory_mirror, memory_mirror, m_rom_ptr); } -void msc_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void msc_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < inputs[0].samples(); i++) - { - outputs[0].put(i, inputs[0].get(i)); - outputs[1].put(i, inputs[1].get(i)); - } + stream.copy(0, 0); + stream.copy(1, 1); } u32 msc_device::rom_switch_r(offs_t offset) diff --git a/src/mame/apple/msc.h b/src/mame/apple/msc.h index 1b51a4cc11a..afb6b726d7c 100644 --- a/src/mame/apple/msc.h +++ b/src/mame/apple/msc.h @@ -74,7 +74,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: devcb_write_line write_pb4, write_pb5, write_cb2, write_vbl; diff --git a/src/mame/apple/pippin.cpp b/src/mame/apple/pippin.cpp index 6f3ba3c2ebf..0337a527844 100644 --- a/src/mame/apple/pippin.cpp +++ b/src/mame/apple/pippin.cpp @@ -189,10 +189,9 @@ void pippin_state::pippin(machine_config &config) grandcentral.codec_r_callback().set(awacs, FUNC(awacs_macrisc_device::read_macrisc)); grandcentral.codec_w_callback().set(awacs, FUNC(awacs_macrisc_device::write_macrisc)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - awacs.add_route(0, "lspeaker", 1.0); - awacs.add_route(1, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + awacs.add_route(0, "speaker", 1.0, 0); + awacs.add_route(1, "speaker", 1.0, 1); MACADB(config, m_macadb, 15.6672_MHz_XTAL); diff --git a/src/mame/apple/powermacg3.cpp b/src/mame/apple/powermacg3.cpp index df7a4596e05..8cda2f4dc9e 100644 --- a/src/mame/apple/powermacg3.cpp +++ b/src/mame/apple/powermacg3.cpp @@ -204,10 +204,9 @@ void pwrmacg3_state::pwrmacg3(machine_config &config) heathrow.codec_r_callback().set(screamer, FUNC(screamer_device::read_macrisc)); heathrow.codec_w_callback().set(screamer, FUNC(screamer_device::write_macrisc)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - screamer.add_route(0, "lspeaker", 1.0); - screamer.add_route(1, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + screamer.add_route(0, "speaker", 1.0, 0); + screamer.add_route(1, "speaker", 1.0, 1); } /* diff --git a/src/mame/apple/scsidma.cpp b/src/mame/apple/scsidma.cpp index 850e7a39543..a73d1fbf1fa 100644 --- a/src/mame/apple/scsidma.cpp +++ b/src/mame/apple/scsidma.cpp @@ -55,8 +55,8 @@ void scsidma_device::device_add_mconfig(machine_config &config) NSCSI_CONNECTOR(config, "scsi:2", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:3").option_set("cdrom", NSCSI_CDROM_APPLE).machine_config([](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:4", mac_scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:5", mac_scsi_devices, nullptr); diff --git a/src/mame/apple/sonora.cpp b/src/mame/apple/sonora.cpp index 581bef5abb2..94453d48e72 100644 --- a/src/mame/apple/sonora.cpp +++ b/src/mame/apple/sonora.cpp @@ -174,13 +174,10 @@ void sonora_device::device_reset() space.install_rom(0x00000000, memory_end & ~memory_mirror, memory_mirror, m_rom_ptr); } -void sonora_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sonora_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < inputs[0].samples(); i++) - { - outputs[0].put(i, inputs[0].get(i)); - outputs[1].put(i, inputs[1].get(i)); - } + stream.copy(0, 0); + stream.copy(1, 1); } u32 sonora_device::rom_switch_r(offs_t offset) diff --git a/src/mame/apple/sonora.h b/src/mame/apple/sonora.h index b6ee52517cd..c6f7078aa01 100644 --- a/src/mame/apple/sonora.h +++ b/src/mame/apple/sonora.h @@ -55,7 +55,7 @@ protected: virtual void device_reset() override ATTR_COLD; virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: devcb_write_line write_pb4, write_pb5, write_cb2; diff --git a/src/mame/apple/v8.cpp b/src/mame/apple/v8.cpp index e1a3798e8c9..0bfdeb37d5c 100644 --- a/src/mame/apple/v8.cpp +++ b/src/mame/apple/v8.cpp @@ -217,13 +217,10 @@ void v8_device::device_reset() space.install_rom(0x00000000, memory_end & ~memory_mirror, memory_mirror, &m_rom[0]); } -void v8_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void v8_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < inputs[0].samples(); i++) - { - outputs[0].put(i, inputs[0].get(i)); - outputs[1].put(i, inputs[1].get(i)); - } + stream.copy(0, 0); + stream.copy(1, 1); } u32 v8_device::rom_switch_r(offs_t offset) diff --git a/src/mame/apple/v8.h b/src/mame/apple/v8.h index 153b1246b29..c27b82dea4d 100644 --- a/src/mame/apple/v8.h +++ b/src/mame/apple/v8.h @@ -66,7 +66,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual ioport_constructor device_input_ports() const override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void ram_size(u8 config); diff --git a/src/mame/apple/vasp.cpp b/src/mame/apple/vasp.cpp index b7277387123..275e8a28dd7 100644 --- a/src/mame/apple/vasp.cpp +++ b/src/mame/apple/vasp.cpp @@ -179,13 +179,10 @@ void vasp_device::device_reset() space.install_rom(0x00000000, memory_end & ~memory_mirror, memory_mirror, m_rom_ptr); } -void vasp_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vasp_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < inputs[0].samples(); i++) - { - outputs[0].put(i, inputs[0].get(i)); - outputs[1].put(i, inputs[1].get(i)); - } + stream.copy(0, 0); + stream.copy(1, 1); } u32 vasp_device::rom_switch_r(offs_t offset) diff --git a/src/mame/apple/vasp.h b/src/mame/apple/vasp.h index 5341af968cf..eee007b274b 100644 --- a/src/mame/apple/vasp.h +++ b/src/mame/apple/vasp.h @@ -54,7 +54,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; virtual ioport_constructor device_input_ports() const override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: devcb_write_line write_pb4, write_pb5, write_cb2, write_hdsel; diff --git a/src/mame/arcadia/arcadia_a.cpp b/src/mame/arcadia/arcadia_a.cpp index f4498fc18b7..0859d381493 100644 --- a/src/mame/arcadia/arcadia_a.cpp +++ b/src/mame/arcadia/arcadia_a.cpp @@ -80,12 +80,9 @@ void arcadia_sound_device::device_reset() // our sound stream //------------------------------------------------- -void arcadia_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void arcadia_sound_device::sound_stream_update(sound_stream &stream) { - int i; - auto &buffer = outputs[0]; - - for (i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 result = 0; @@ -132,7 +129,7 @@ void arcadia_sound_device::sound_stream_update(sound_stream &stream, std::vector m_pos = 0; } } - buffer.put_int(i, result, 32768); + stream.put_int(0, i, result, 32768); } } diff --git a/src/mame/arcadia/arcadia_a.h b/src/mame/arcadia/arcadia_a.h index 29f1e42309f..523e6087b43 100644 --- a/src/mame/arcadia/arcadia_a.h +++ b/src/mame/arcadia/arcadia_a.h @@ -21,7 +21,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; sound_stream *m_channel = nullptr; uint8_t m_reg[3]{}; diff --git a/src/mame/atari/atarigt.cpp b/src/mame/atari/atarigt.cpp index 63fe14900d0..6199a3bef05 100644 --- a/src/mame/atari/atarigt.cpp +++ b/src/mame/atari/atarigt.cpp @@ -902,15 +902,14 @@ void atarigt_state::atarigt_stereo(machine_config &config) // 3 Channel output directly from CAGE or through motherboard JAMMA output // based on dedicated cabinet configuration; // 'universal' kit supports mono and stereo, with/without subwoofer. - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SPEAKER(config, "subwoofer").front_floor(); // Next to the coin door at dedicated cabinet, just silence for now (not implemented) // TODO: correct? sound board has only 1 DAC populated. - m_cage->add_route(0, "rspeaker", 1.0); - m_cage->add_route(1, "lspeaker", 1.0); - m_cage->add_route(2, "lspeaker", 1.0); - m_cage->add_route(3, "rspeaker", 1.0); + m_cage->add_route(0, "speaker", 1.0, 1); + m_cage->add_route(1, "speaker", 1.0, 0); + m_cage->add_route(2, "speaker", 1.0, 0); + m_cage->add_route(3, "speaker", 1.0, 1); m_cage->add_route(4, "subwoofer", 1.0); } @@ -925,17 +924,14 @@ void atarigt_state::tmek(machine_config &config) m_adc->in_callback<7>().set_ioport("AN3"); // 5 Channel output (4 Channel input connected to Quad Amp PCB) - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); + SPEAKER(config, "speaker").front_left().headrest_left(2).headrest_right(3); //SPEAKER(config, "subwoofer").seat(); Not implemented, Quad Amp PCB output; m_cage->set_speedup(0x4fad); - m_cage->add_route(0, "frspeaker", 1.0); // Foward Right - m_cage->add_route(1, "rlspeaker", 1.0); // Back Left - m_cage->add_route(2, "flspeaker", 1.0); // Foward Left - m_cage->add_route(3, "rrspeaker", 1.0); // Back Right + m_cage->add_route(0, "speaker", 1.0, 1); // Foward Right + m_cage->add_route(1, "speaker", 1.0, 2); // Back Left + m_cage->add_route(2, "speaker", 1.0, 0); // Foward Left + m_cage->add_route(3, "speaker", 1.0, 3); // Back Right } void atarigt_state::primrage(machine_config &config) diff --git a/src/mame/atari/atarigx2.cpp b/src/mame/atari/atarigx2.cpp index 19a001a939b..096b55c9694 100644 --- a/src/mame/atari/atarigx2.cpp +++ b/src/mame/atari/atarigx2.cpp @@ -1514,14 +1514,13 @@ void atarigx2_state::atarigx2(machine_config &config) m_screen->screen_vblank().set_inputline(m_maincpu, M68K_IRQ_4, ASSERT_LINE); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_JSA_IIIS(config, m_jsa, 0); m_jsa->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_5); m_jsa->test_read_cb().set_ioport("SERVICE").bit(6); - m_jsa->add_route(0, "lspeaker", 0.7); - m_jsa->add_route(1, "rspeaker", 0.7); + m_jsa->add_route(0, "speaker", 0.7, 0); + m_jsa->add_route(1, "speaker", 0.7, 1); } void atarigx2_state::atarigx2_0x200(machine_config &config) diff --git a/src/mame/atari/atarijsa.cpp b/src/mame/atari/atarijsa.cpp index d4908848a4c..2581c7286d0 100644 --- a/src/mame/atari/atarijsa.cpp +++ b/src/mame/atari/atarijsa.cpp @@ -234,9 +234,9 @@ INPUT_PORTS_END // atari_jsa_base_device - constructor //------------------------------------------------- -atari_jsa_base_device::atari_jsa_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock, int channels) +atari_jsa_base_device::atari_jsa_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, devtype, tag, owner, clock), - device_mixer_interface(mconfig, *this, channels), + device_mixer_interface(mconfig, *this), m_soundcomm(*this, "soundcomm"), m_jsacpu(*this, "cpu"), m_ym2151(*this, "ym2151"), @@ -426,8 +426,8 @@ void atari_jsa_base_device::update_sound_irq() // atari_jsa_oki_base_device: Constructor //------------------------------------------------- -atari_jsa_oki_base_device::atari_jsa_oki_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock, int channels) - : atari_jsa_base_device(mconfig, devtype, tag, owner, clock, channels), +atari_jsa_oki_base_device::atari_jsa_oki_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock) + : atari_jsa_base_device(mconfig, devtype, tag, owner, clock), m_oki1(*this, "oki1"), m_oki2(*this, "oki2"), m_oki1_region(*this, "oki1"), @@ -644,7 +644,7 @@ void atari_jsa_oki_base_device::update_all_volumes() //------------------------------------------------- atari_jsa_i_device::atari_jsa_i_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : atari_jsa_base_device(mconfig, ATARI_JSA_I, tag, owner, clock, 2), + : atari_jsa_base_device(mconfig, ATARI_JSA_I, tag, owner, clock), m_pokey(*this, "pokey"), m_tms5220(*this, "tms"), m_jsai(*this, "JSAI"), @@ -799,16 +799,16 @@ void atari_jsa_i_device::device_add_mconfig(machine_config &config) YM2151(config, m_ym2151, JSA_MASTER_CLOCK); m_ym2151->irq_handler().set(FUNC(atari_jsa_i_device::ym2151_irq_gen)); m_ym2151->port_write_handler().set(FUNC(atari_jsa_base_device::ym2151_port_w)); - m_ym2151->add_route(0, *this, 0.60, AUTO_ALLOC_INPUT, 0); - m_ym2151->add_route(1, *this, 0.60, AUTO_ALLOC_INPUT, 1); + m_ym2151->add_route(0, *this, 0.60, 0); + m_ym2151->add_route(1, *this, 0.60, 1); POKEY(config, m_pokey, JSA_MASTER_CLOCK/2); - m_pokey->add_route(ALL_OUTPUTS, *this, 0.40, AUTO_ALLOC_INPUT, 0); - m_pokey->add_route(ALL_OUTPUTS, *this, 0.40, AUTO_ALLOC_INPUT, 1); + m_pokey->add_route(ALL_OUTPUTS, *this, 0.40, 0); + m_pokey->add_route(ALL_OUTPUTS, *this, 0.40, 1); TMS5220C(config, m_tms5220, JSA_MASTER_CLOCK*2/11); // potentially JSA_MASTER_CLOCK/9 as well - m_tms5220->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_tms5220->add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_tms5220->add_route(ALL_OUTPUTS, *this, 1.0, 0); + m_tms5220->add_route(ALL_OUTPUTS, *this, 1.0, 1); } @@ -879,7 +879,7 @@ void atari_jsa_i_device::update_all_volumes() //------------------------------------------------- atari_jsa_ii_device::atari_jsa_ii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : atari_jsa_oki_base_device(mconfig, ATARI_JSA_II, tag, owner, clock, 1) + : atari_jsa_oki_base_device(mconfig, ATARI_JSA_II, tag, owner, clock) , m_jsaii(*this, "JSAII") { } @@ -930,10 +930,10 @@ void atari_jsa_ii_device::device_add_mconfig(machine_config &config) YM2151(config, m_ym2151, JSA_MASTER_CLOCK); m_ym2151->irq_handler().set(FUNC(atari_jsa_ii_device::ym2151_irq_gen)); m_ym2151->port_write_handler().set(FUNC(atari_jsa_base_device::ym2151_port_w)); - m_ym2151->add_route(ALL_OUTPUTS, *this, 0.60, AUTO_ALLOC_INPUT, 0); + m_ym2151->add_route(ALL_OUTPUTS, *this, 0.60, 0); OKIM6295(config, m_oki1, JSA_MASTER_CLOCK/3, okim6295_device::PIN7_HIGH); - m_oki1->add_route(ALL_OUTPUTS, *this, 0.75, AUTO_ALLOC_INPUT, 0); + m_oki1->add_route(ALL_OUTPUTS, *this, 0.75, 0); } @@ -958,12 +958,12 @@ ioport_constructor atari_jsa_ii_device::device_input_ports() const //------------------------------------------------- atari_jsa_iii_device::atari_jsa_iii_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : atari_jsa_iii_device(mconfig, ATARI_JSA_III, tag, owner, clock, 1) + : atari_jsa_iii_device(mconfig, ATARI_JSA_III, tag, owner, clock) { } -atari_jsa_iii_device::atari_jsa_iii_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock, int channels) - : atari_jsa_oki_base_device(mconfig, devtype, tag, owner, clock, channels) +atari_jsa_iii_device::atari_jsa_iii_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock) + : atari_jsa_oki_base_device(mconfig, devtype, tag, owner, clock) , m_jsaiii(*this, "JSAIII") { } @@ -1013,11 +1013,11 @@ void atari_jsa_iii_device::device_add_mconfig(machine_config &config) YM2151(config, m_ym2151, JSA_MASTER_CLOCK); m_ym2151->irq_handler().set(FUNC(atari_jsa_iii_device::ym2151_irq_gen)); m_ym2151->port_write_handler().set(FUNC(atari_jsa_base_device::ym2151_port_w)); - m_ym2151->add_route(ALL_OUTPUTS, *this, 0.60, AUTO_ALLOC_INPUT, 0); + m_ym2151->add_route(ALL_OUTPUTS, *this, 0.60, 0); OKIM6295(config, m_oki1, JSA_MASTER_CLOCK/3, okim6295_device::PIN7_HIGH); m_oki1->set_addrmap(0, &atari_jsa_iii_device::jsa3_oki1_map); - m_oki1->add_route(ALL_OUTPUTS, *this, 0.75, AUTO_ALLOC_INPUT, 0); + m_oki1->add_route(ALL_OUTPUTS, *this, 0.75, 0); } @@ -1042,7 +1042,7 @@ ioport_constructor atari_jsa_iii_device::device_input_ports() const //------------------------------------------------- atari_jsa_iiis_device::atari_jsa_iiis_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : atari_jsa_iii_device(mconfig, ATARI_JSA_IIIS, tag, owner, clock, 2) + : atari_jsa_iii_device(mconfig, ATARI_JSA_IIIS, tag, owner, clock) { } @@ -1057,10 +1057,10 @@ void atari_jsa_iiis_device::device_add_mconfig(machine_config &config) atari_jsa_iii_device::device_add_mconfig(config); m_ym2151->reset_routes(); - m_ym2151->add_route(0, *this, 0.60, AUTO_ALLOC_INPUT, 0); - m_ym2151->add_route(1, *this, 0.60, AUTO_ALLOC_INPUT, 1); + m_ym2151->add_route(0, *this, 0.60, 0); + m_ym2151->add_route(1, *this, 0.60, 1); OKIM6295(config, m_oki2, JSA_MASTER_CLOCK/3, okim6295_device::PIN7_HIGH); - m_oki2->add_route(ALL_OUTPUTS, *this, 0.75, AUTO_ALLOC_INPUT, 1); + m_oki2->add_route(ALL_OUTPUTS, *this, 0.75, 1); m_oki2->set_addrmap(0, &atari_jsa_iiis_device::jsa3_oki2_map); } diff --git a/src/mame/atari/atarijsa.h b/src/mame/atari/atarijsa.h index fcd77d6b17a..dd3ee742824 100644 --- a/src/mame/atari/atarijsa.h +++ b/src/mame/atari/atarijsa.h @@ -54,7 +54,7 @@ class atari_jsa_base_device : public device_t, { protected: // construction/destruction - atari_jsa_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock, int channels); + atari_jsa_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock); public: // configuration @@ -125,7 +125,7 @@ class atari_jsa_oki_base_device : public atari_jsa_base_device { protected: // derived construction/destruction - atari_jsa_oki_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock, int channels); + atari_jsa_oki_base_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock); public: // read/write handlers @@ -234,7 +234,7 @@ public: void jsa3_oki1_map(address_map &map) ATTR_COLD; protected: // derived construction/destruction - atari_jsa_iii_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock, int channels); + atari_jsa_iii_device(const machine_config &mconfig, device_type devtype, const char *tag, device_t *owner, uint32_t clock); public: // read/write handlers diff --git a/src/mame/atari/atarisac.cpp b/src/mame/atari/atarisac.cpp index 9a2982774eb..51153208a30 100644 --- a/src/mame/atari/atarisac.cpp +++ b/src/mame/atari/atarisac.cpp @@ -95,7 +95,7 @@ INPUT_PORTS_END //------------------------------------------------- atari_sac_device::atari_sac_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock) - : atari_jsa_base_device(mconfig, ATARI_SAC, tag, owner, clock, 2) + : atari_jsa_base_device(mconfig, ATARI_SAC, tag, owner, clock) , m_daccpu(*this, "dac") , m_datin(*this, "datin") , m_datout(*this, "datout") @@ -265,12 +265,12 @@ void atari_sac_device::device_add_mconfig(machine_config &config) YM2151(config, m_ym2151, 14.318181_MHz_XTAL/4); m_ym2151->irq_handler().set(FUNC(atari_sac_device::ym2151_irq_gen)); m_ym2151->port_write_handler().set(FUNC(atari_sac_device::ym2151_port_w)); - m_ym2151->add_route(0, *this, 0.60, AUTO_ALLOC_INPUT, 0); - m_ym2151->add_route(1, *this, 0.60, AUTO_ALLOC_INPUT, 1); + m_ym2151->add_route(0, *this, 0.60, 0); + m_ym2151->add_route(1, *this, 0.60, 1); // FIXME: there is actually only one DAC (plus some analog switches) - AM6012(config, m_rdac).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 1); // AM6012.6j - AM6012(config, m_ldac).add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); // AM6012.6j + AM6012(config, m_rdac).add_route(ALL_OUTPUTS, *this, 0.5, 1); // AM6012.6j + AM6012(config, m_ldac).add_route(ALL_OUTPUTS, *this, 0.5, 0); // AM6012.6j } diff --git a/src/mame/atari/atarist.cpp b/src/mame/atari/atarist.cpp index 81470df514c..aabdb5aaaae 100644 --- a/src/mame/atari/atarist.cpp +++ b/src/mame/atari/atarist.cpp @@ -9,10 +9,9 @@ #include "stvideo.h" #include "bus/centronics/ctronics.h" -#include "bus/generic/slot.h" -#include "bus/generic/carts.h" #include "bus/midi/midi.h" #include "bus/rs232/rs232.h" +#include "bus/st/stcart.h" #include "cpu/m68000/m68000.h" #include "imagedev/floppy.h" #include "machine/6850acia.h" @@ -138,7 +137,7 @@ protected: required_device<mc68901_device> m_mfp; required_device_array<acia6850_device, 2> m_acia; required_device<centronics_device> m_centronics; - required_device<generic_slot_device> m_cart; + required_device<stcart_connector> m_cart; required_device<ram_device> m_ramcfg; required_device<rs232_port_device> m_rs232; required_device<ym2149_device> m_ymsnd; @@ -808,7 +807,6 @@ void st_state::st_super_map(address_map &map) map(0x000000, 0x000007).rom().region(M68000_TAG, 0); map(0x000000, 0x000007).before_delay(NAME([](offs_t) { return 64; })).w(m_maincpu, FUNC(m68000_device::berr_w)); map(0x400000, 0xf9ffff).before_delay(NAME([](offs_t) { return 64; })).rw(m_maincpu, FUNC(m68000_device::berr_r), FUNC(m68000_device::berr_w)); - map(0xfa0000, 0xfbffff).noprw(); // mapped by the cartslot map(0xfc0000, 0xfeffff).rom().region(M68000_TAG, 0); map(0xfc0000, 0xfeffff).before_delay(NAME([](offs_t) { return 64; })).w(m_maincpu, FUNC(m68000_device::berr_w)); @@ -840,7 +838,6 @@ void st_state::st_user_map(address_map &map) map.unmap_value_high(); map(0x000000, 0x0007ff).before_delay(NAME([](offs_t) { return 64; })).rw(m_maincpu, FUNC(m68000_device::berr_r), FUNC(m68000_device::berr_w)); map(0x400000, 0xf9ffff).before_delay(NAME([](offs_t) { return 64; })).rw(m_maincpu, FUNC(m68000_device::berr_r), FUNC(m68000_device::berr_w)); - map(0xfa0000, 0xfbffff).noprw(); // mapped by the cartslot map(0xfc0000, 0xfeffff).rom().region(M68000_TAG, 0).w(m_maincpu, FUNC(m68000_device::berr_w)); map(0xfc0000, 0xfeffff).before_delay(NAME([](offs_t) { return 64; })).w(m_maincpu, FUNC(m68000_device::berr_w)); map(0xff0000, 0xffffff).before_delay(NAME([](offs_t) { return 64; })).rw(m_maincpu, FUNC(m68000_device::berr_r), FUNC(m68000_device::berr_w)); @@ -1220,10 +1217,8 @@ void st_state::machine_start() { m_mmu->set_ram_size(m_ramcfg->size()); - if (m_cart->exists()) { - m_maincpu->space(AS_PROGRAM).install_read_handler(0xfa0000, 0xfbffff, read16s_delegate(*m_cart, FUNC(generic_slot_device::read16_rom))); - m_maincpu->space(m68000_device::AS_USER_PROGRAM).install_read_handler(0xfa0000, 0xfbffff, read16s_delegate(*m_cart, FUNC(generic_slot_device::read16_rom))); - } + m_cart->map(m_maincpu->space(AS_PROGRAM)); + m_cart->map(m_maincpu->space(m68000_device::AS_USER_PROGRAM)); /// TODO: get callbacks to trigger these. m_mfp->i0_w(1); @@ -1263,8 +1258,8 @@ void ste_state::machine_start() { m_mmu->set_ram_size(m_ramcfg->size()); - if (m_cart->exists()) - m_maincpu->space(AS_PROGRAM).install_read_handler(0xfa0000, 0xfbffff, read16s_delegate(*m_cart, FUNC(generic_slot_device::read16_rom))); + m_cart->map(m_maincpu->space(AS_PROGRAM)); + m_cart->map(m_maincpu->space(m68000_device::AS_USER_PROGRAM)); /* allocate timers */ m_dmasound_timer = timer_alloc(FUNC(ste_state::dmasound_tick), this); @@ -1309,8 +1304,8 @@ void stbook_state::machine_start() break; } - if (m_cart->exists()) - m_maincpu->space(AS_PROGRAM).install_read_handler(0xfa0000, 0xfbffff, read16s_delegate(*m_cart, FUNC(generic_slot_device::read16_rom))); + m_cart->map(m_maincpu->space(AS_PROGRAM)); + m_cart->map(m_maincpu->space(m68000_device::AS_USER_PROGRAM)); /* register for state saving */ ste_state::state_save(); @@ -1415,9 +1410,8 @@ void st_state::common(machine_config &config) acia_clock.signal_handler().append(m_acia[1], FUNC(acia6850_device::write_rxc)); // cartridge - GENERIC_CARTSLOT(config, m_cart, generic_linear_slot, "st_cart", "bin,rom"); - m_cart->set_width(GENERIC_ROM16_WIDTH); - m_cart->set_endian(ENDIANNESS_BIG); + + STCART_CONNECTOR(config, m_cart, stcart_intf, nullptr); // software lists SOFTWARE_LIST(config, "flop_list").set_original("st_flop"); @@ -1525,14 +1519,13 @@ void ste_state::ste(machine_config &config) m_videox->de_callback().set(m_mfp, FUNC(mc68901_device::tbi_w)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - m_ymsnd->add_route(0, "lspeaker", 0.50); - m_ymsnd->add_route(0, "rspeaker", 0.50); + SPEAKER(config, "speaker", 2).front(); + m_ymsnd->add_route(0, "speaker", 0.50, 0); + m_ymsnd->add_route(0, "speaker", 0.50, 1); /* custom_device &custom_dac(CUSTOM(config, "custom", 0)); // DAC - custom_dac.add_route(0, "rspeaker", 0.50); - custom_dac.add_route(1, "lspeaker", 0.50); + custom_dac.add_route(0, "speaker", 0.50); + custom_dac.add_route(1, "speaker", 0.50); */ LMC1992(config, LMC1992_TAG); diff --git a/src/mame/atari/atarisy1.cpp b/src/mame/atari/atarisy1.cpp index 6519058bd7d..4800808e6f9 100644 --- a/src/mame/atari/atarisy1.cpp +++ b/src/mame/atari/atarisy1.cpp @@ -718,8 +718,8 @@ void atarisy1_state::add_speech(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &atarisy1_state::sound_ext_map); TMS5220C(config, m_tms, 14.318181_MHz_XTAL/2/11); - m_tms->add_route(ALL_OUTPUTS, "lspeaker", 0.6); - m_tms->add_route(ALL_OUTPUTS, "rspeaker", 0.6); + m_tms->add_route(ALL_OUTPUTS, "speaker", 0.6, 0); + m_tms->add_route(ALL_OUTPUTS, "speaker", 0.6, 1); MOS6522(config, m_via, 14.318181_MHz_XTAL/8); m_via->readpa_handler().set(m_tms, FUNC(tms5220_device::status_r)); @@ -773,8 +773,7 @@ void atarisy1_state::atarisy1(machine_config &config) m_screen->screen_vblank().set_inputline(m_maincpu, M68K_IRQ_4, ASSERT_LINE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, m6502_device::NMI_LINE); @@ -785,12 +784,12 @@ void atarisy1_state::atarisy1(machine_config &config) ym2151_device &ymsnd(YM2151(config, "ymsnd", 14.318181_MHz_XTAL/4)); ymsnd.irq_handler().set_inputline(m_audiocpu, m6502_device::IRQ_LINE); - ymsnd.add_route(0, "lspeaker", 0.48); - ymsnd.add_route(1, "rspeaker", 0.48); + ymsnd.add_route(0, "speaker", 0.48, 0); + ymsnd.add_route(1, "speaker", 0.48, 1); pokey_device &pokey(POKEY(config, "pokey", 14.318181_MHz_XTAL/8)); - pokey.add_route(ALL_OUTPUTS, "lspeaker", 0.24); - pokey.add_route(ALL_OUTPUTS, "rspeaker", 0.24); + pokey.add_route(ALL_OUTPUTS, "speaker", 0.24, 0); + pokey.add_route(ALL_OUTPUTS, "speaker", 0.24, 1); } void atarisy1_state::marble(machine_config &config) diff --git a/src/mame/atari/atarisy2.cpp b/src/mame/atari/atarisy2.cpp index 98baffabf2c..94e8c995e5e 100644 --- a/src/mame/atari/atarisy2.cpp +++ b/src/mame/atari/atarisy2.cpp @@ -1224,8 +1224,7 @@ void atarisy2_state::atarisy2(machine_config &config) screen.screen_vblank().set(FUNC(atarisy2_state::vblank_int)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, m6502_device::NMI_LINE); @@ -1235,20 +1234,20 @@ void atarisy2_state::atarisy2(machine_config &config) GENERIC_LATCH_8(config, m_mainlatch); YM2151(config, m_ym2151, SOUND_CLOCK/4); - m_ym2151->add_route(0, "lspeaker", 0.60); - m_ym2151->add_route(1, "rspeaker", 0.60); + m_ym2151->add_route(0, "speaker", 0.60, 0); + m_ym2151->add_route(1, "speaker", 0.60, 1); POKEY(config, m_pokey[0], SOUND_CLOCK/8); m_pokey[0]->allpot_r().set_ioport("DSW0"); - m_pokey[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.35); + m_pokey[0]->add_route(ALL_OUTPUTS, "speaker", 1.35, 0); POKEY(config, m_pokey[1], SOUND_CLOCK/8); m_pokey[1]->allpot_r().set_ioport("DSW1"); - m_pokey[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.35); + m_pokey[1]->add_route(ALL_OUTPUTS, "speaker", 1.35, 1); TMS5220C(config, m_tms5220, MASTER_CLOCK/4/4/2); - m_tms5220->add_route(ALL_OUTPUTS, "lspeaker", 0.75); - m_tms5220->add_route(ALL_OUTPUTS, "rspeaker", 0.75); + m_tms5220->add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + m_tms5220->add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } diff --git a/src/mame/atari/blstroid.cpp b/src/mame/atari/blstroid.cpp index f406131fd3f..6ae8ec7777f 100644 --- a/src/mame/atari/blstroid.cpp +++ b/src/mame/atari/blstroid.cpp @@ -406,14 +406,13 @@ void blstroid_state::blstroid(machine_config &config) m_screen->screen_vblank().set_inputline(m_maincpu, M68K_IRQ_2, ASSERT_LINE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_JSA_I(config, m_jsa, 0); m_jsa->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_4); m_jsa->test_read_cb().set_ioport("IN0").bit(7); - m_jsa->add_route(0, "lspeaker", 1.0); - m_jsa->add_route(1, "rspeaker", 1.0); + m_jsa->add_route(0, "speaker", 1.0, 0); + m_jsa->add_route(1, "speaker", 1.0, 1); config.device_remove("jsa:pokey"); config.device_remove("jsa:tms"); } diff --git a/src/mame/atari/canyon.cpp b/src/mame/atari/canyon.cpp index da95e27cd60..222ded0a924 100644 --- a/src/mame/atari/canyon.cpp +++ b/src/mame/atari/canyon.cpp @@ -416,12 +416,11 @@ void canyon_state::canyon(machine_config &config) PALETTE(config, m_palette, FUNC(canyon_state::palette), 4); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DISCRETE(config, m_discrete, canyon_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/atari/cops.cpp b/src/mame/atari/cops.cpp index 25f7ec4fdb0..b2e1c54dcba 100644 --- a/src/mame/atari/cops.cpp +++ b/src/mame/atari/cops.cpp @@ -615,20 +615,18 @@ void cops_state::base(machine_config &config) SONY_LDP1450HLE(config, m_ld, 0); m_ld->set_screen("screen"); m_ld->set_overlay(256, 256, FUNC(cops_state::screen_update)); - m_ld->add_route(0, "lspeaker", 0.50); - m_ld->add_route(1, "rspeaker", 0.50); + m_ld->add_route(0, "speaker", 0.50, 0); + m_ld->add_route(1, "speaker", 0.50, 1); m_ld->set_baud(9600); m_ld->add_ntsc_screen(config, "screen"); m_ld->serial_tx().set("dacia", FUNC(r65c52_device::write_rxd1)); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); - SPEAKER(config, "lspeaker").front_left(); + SPEAKER(config, "speaker", 2).front(); SPEAKER(config, "mspeaker").front_center(); - SPEAKER(config, "rspeaker").front_right(); - R65C52(config, m_dacia, DACIA_CLOCK); m_dacia->txd1_handler().set("laserdisc", FUNC(sony_ldp1450hle_device::rx_w)); m_dacia->irq1_handler().set(FUNC(cops_state::acia1_irq)); diff --git a/src/mame/atari/copsnrob.cpp b/src/mame/atari/copsnrob.cpp index dcc0b8fbc12..b47e45869bc 100644 --- a/src/mame/atari/copsnrob.cpp +++ b/src/mame/atari/copsnrob.cpp @@ -440,12 +440,11 @@ void copsnrob_state::copsnrob(machine_config &config) PALETTE(config, m_palette, palette_device::MONOCHROME); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); discrete_sound_device &discrete(DISCRETE(config, "discrete", copsnrob_discrete)); - discrete.add_route(0, "lspeaker", 1.0); - discrete.add_route(1, "rspeaker", 1.0); + discrete.add_route(0, "speaker", 1.0, 0); + discrete.add_route(1, "speaker", 1.0, 1); f9334_device &latch(F9334(config, "latch")); // H3 on audio board latch.q_out_cb<0>().set("discrete", FUNC(discrete_device::write_line<COPSNROB_MOTOR3_INV>)); diff --git a/src/mame/atari/cyberbal.cpp b/src/mame/atari/cyberbal.cpp index b0467ab062e..04dd18e25df 100644 --- a/src/mame/atari/cyberbal.cpp +++ b/src/mame/atari/cyberbal.cpp @@ -773,14 +773,13 @@ void cyberbal_state::cyberbal(machine_config &config) m_rscreen->set_palette("rpalette"); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_SAC(config, m_sac); m_sac->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_1); m_sac->test_read_cb().set_ioport("IN0").bit(15); - m_sac->add_route(0, "lspeaker", 1.0); - m_sac->add_route(1, "rspeaker", 1.0); + m_sac->add_route(0, "speaker", 1.0, 0); + m_sac->add_route(1, "speaker", 1.0, 1); } void cyberbal_state::cyberbalt(machine_config &config) diff --git a/src/mame/atari/cybstorm.cpp b/src/mame/atari/cybstorm.cpp index db3dae9d38e..3ee3c2e1833 100644 --- a/src/mame/atari/cybstorm.cpp +++ b/src/mame/atari/cybstorm.cpp @@ -519,14 +519,13 @@ void cybstorm_state::cybstorm(machine_config &config) round2(config); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_JSA_IIIS(config, m_jsa, 0); m_jsa->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_6); m_jsa->test_read_cb().set_ioport("9F0010").bit(22); - m_jsa->add_route(0, "lspeaker", 0.9); - m_jsa->add_route(1, "rspeaker", 0.9); + m_jsa->add_route(0, "speaker", 0.9, 0); + m_jsa->add_route(1, "speaker", 0.9, 1); } diff --git a/src/mame/atari/dragrace.cpp b/src/mame/atari/dragrace.cpp index 8103a8b08bf..4df3319955f 100644 --- a/src/mame/atari/dragrace.cpp +++ b/src/mame/atari/dragrace.cpp @@ -451,12 +451,11 @@ void dragrace_state::dragrace(machine_config &config) PALETTE(config, "palette", FUNC(dragrace_state::palette), 16); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DISCRETE(config, m_discrete, dragrace_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); f9334_device &latch_f5(F9334(config, "latch_f5")); // F5 latch_f5.parallel_out_cb().set(FUNC(dragrace_state::speed1_w)).mask(0x1f); // set 3SPEED1-7SPEED1 diff --git a/src/mame/atari/firefox.cpp b/src/mame/atari/firefox.cpp index 3f316f7e355..ab1b89b141c 100644 --- a/src/mame/atari/firefox.cpp +++ b/src/mame/atari/firefox.cpp @@ -640,8 +640,8 @@ void firefox_state::firefox(machine_config &config) PHILIPS_22VP931(config, m_laserdisc, 0); m_laserdisc->set_overlay(64*8, 525, FUNC(firefox_state::screen_update_firefox)); m_laserdisc->set_overlay_clip(7*8, 53*8-1, 44, 480+44); - m_laserdisc->add_route(0, "lspeaker", 0.50); - m_laserdisc->add_route(1, "rspeaker", 0.50); + m_laserdisc->add_route(0, "speaker", 0.50, 0); + m_laserdisc->add_route(1, "speaker", 0.50, 1); m_laserdisc->add_ntsc_screen(config, "screen"); X2212(config, "nvram_1c").set_auto_save(true); @@ -658,8 +658,7 @@ void firefox_state::firefox(machine_config &config) m_riot->irq_wr_callback().set_inputline(m_audiocpu, M6502_IRQ_LINE); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, soundlatch[0]); soundlatch[0]->data_pending_callback().set(m_riot, FUNC(mos6532_device::pa_bit_w<7>)); // MAINFLAG @@ -672,13 +671,13 @@ void firefox_state::firefox(machine_config &config) for (int i = 0; i < 4; i++) { POKEY(config, m_pokey[i], MASTER_XTAL/8); - m_pokey[i]->add_route(ALL_OUTPUTS, "lspeaker", 0.30); - m_pokey[i]->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_pokey[i]->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + m_pokey[i]->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); } TMS5220(config, m_tms, MASTER_XTAL/2/11); - m_tms->add_route(ALL_OUTPUTS, "lspeaker", 0.75); - m_tms->add_route(ALL_OUTPUTS, "rspeaker", 0.75); + m_tms->add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + m_tms->add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } diff --git a/src/mame/atari/gauntlet.cpp b/src/mame/atari/gauntlet.cpp index 9a2cd4a5f90..1104ae5563f 100644 --- a/src/mame/atari/gauntlet.cpp +++ b/src/mame/atari/gauntlet.cpp @@ -784,8 +784,7 @@ void gauntlet_state::base(machine_config &config) m_screen->screen_vblank().set_inputline(m_maincpu, M68K_IRQ_4, ASSERT_LINE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, m6502_device::NMI_LINE); @@ -795,16 +794,16 @@ void gauntlet_state::base(machine_config &config) m_mainlatch->data_pending_callback().set_inputline(m_maincpu, M68K_IRQ_6); YM2151(config, m_ym2151, 14.318181_MHz_XTAL / 4); - m_ym2151->add_route(1, "lspeaker", 0.48); - m_ym2151->add_route(0, "rspeaker", 0.48); + m_ym2151->add_route(1, "speaker", 0.48, 0); + m_ym2151->add_route(0, "speaker", 0.48, 1); POKEY(config, m_pokey, 14.318181_MHz_XTAL / 8); - m_pokey->add_route(ALL_OUTPUTS, "lspeaker", 0.32); - m_pokey->add_route(ALL_OUTPUTS, "rspeaker", 0.32); + m_pokey->add_route(ALL_OUTPUTS, "speaker", 0.32, 0); + m_pokey->add_route(ALL_OUTPUTS, "speaker", 0.32, 1); TMS5220C(config, m_tms5220, 14.318181_MHz_XTAL / 2 / 11); // potentially 14.318181_MHz_XTAL / 2 / 9 as well - m_tms5220->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_tms5220->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_tms5220->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_tms5220->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); LS259(config, m_soundctl); // 16T/U m_soundctl->q_out_cb<0>().set(m_ym2151, FUNC(ym2151_device::reset_w)); // music reset, low reset diff --git a/src/mame/atari/harddriv.cpp b/src/mame/atari/harddriv.cpp index d2acec8b538..a872282cec5 100644 --- a/src/mame/atari/harddriv.cpp +++ b/src/mame/atari/harddriv.cpp @@ -1627,11 +1627,10 @@ void harddriv_state::ds3(machine_config &config) m_ds3xdsp->set_addrmap(AS_DATA, &harddriv_state::ds3xdsp_data_map); TIMER(config, "ds3xdsp_timer").configure_generic(FUNC(harddriv_state::ds3xdsp_internal_timer_callback)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // unknown DAC - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // unknown DAC + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // unknown DAC + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // unknown DAC } @@ -1932,8 +1931,7 @@ void steeltal_board_device_state::device_add_mconfig(machine_config &config) //t config.device_remove("ds3xdsp"); config.device_remove("ldac"); config.device_remove("rdac"); - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); ASIC65(config, m_asic65, 0, ASIC65_STEELTAL); /* ASIC65 on DSPCOM board */ diff --git a/src/mame/atari/jaguar.cpp b/src/mame/atari/jaguar.cpp index 6ef3347778b..df74019350c 100644 --- a/src/mame/atari/jaguar.cpp +++ b/src/mame/atari/jaguar.cpp @@ -1783,10 +1783,9 @@ void jaguar_state::cojagr3k(machine_config &config) PALETTE(config, m_palette, FUNC(jaguar_state::jagpal_ycc), 65536); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // unknown DAC - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // unknown DAC + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // unknown DAC // TODO: subwoofer speaker } @@ -1833,10 +1832,9 @@ void jaguar_state::jaguar(machine_config &config) PALETTE(config, m_palette, FUNC(jaguar_state::jagpal_ycc), 65536); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // unknown DAC - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // unknown DAC + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // unknown DAC /* quickload */ QUICKLOAD(config, "quickload", "abs,bin,cof,jag,prg,rom", attotime::from_seconds(1)).set_load_callback(FUNC(jaguar_state::quickload_cb)); diff --git a/src/mame/atari/jedi.cpp b/src/mame/atari/jedi.cpp index 1b0a657c56c..dc8c0740fa3 100644 --- a/src/mame/atari/jedi.cpp +++ b/src/mame/atari/jedi.cpp @@ -946,30 +946,29 @@ void jedi_state::jedi(machine_config &config) M6502(config, m_audiocpu, JEDI_AUDIO_CPU_CLOCK); m_audiocpu->set_addrmap(AS_PROGRAM, &jedi_state::audio_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); pokey_device &pokey1(POKEY(config, "pokey1", JEDI_POKEY_CLOCK)); pokey1.set_output_opamp(RES_K(1), 0.0, 5.0); - pokey1.add_route(ALL_OUTPUTS, "lspeaker", 0.30); - pokey1.add_route(ALL_OUTPUTS, "rspeaker", 0.30); + pokey1.add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + pokey1.add_route(ALL_OUTPUTS, "speaker", 0.30, 1); pokey_device &pokey2(POKEY(config, "pokey2", JEDI_POKEY_CLOCK)); pokey2.set_output_opamp(RES_K(1), 0.0, 5.0); - pokey2.add_route(ALL_OUTPUTS, "lspeaker", 0.30); - pokey2.add_route(ALL_OUTPUTS, "rspeaker", 0.30); + pokey2.add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + pokey2.add_route(ALL_OUTPUTS, "speaker", 0.30, 1); pokey_device &pokey3(POKEY(config, "pokey3", JEDI_POKEY_CLOCK)); pokey3.set_output_opamp(RES_K(1), 0.0, 5.0); - pokey3.add_route(ALL_OUTPUTS, "lspeaker", 0.30); + pokey3.add_route(ALL_OUTPUTS, "speaker", 0.30, 0); pokey_device &pokey4(POKEY(config, "pokey4", JEDI_POKEY_CLOCK)); pokey4.set_output_opamp(RES_K(1), 0.0, 5.0); - pokey4.add_route(ALL_OUTPUTS, "rspeaker", 0.30); + pokey4.add_route(ALL_OUTPUTS, "speaker", 0.30, 1); TMS5220(config, m_tms, JEDI_TMS5220_CLOCK); - m_tms->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_tms->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_tms->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_tms->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); GENERIC_LATCH_8(config, m_soundlatch); // 5E (LS374) + 3E (LS279) pins 13-15 GENERIC_LATCH_8(config, m_sacklatch); // 4E (LS374) + 3E (LS279) pins 1-4 diff --git a/src/mame/atari/lynx.cpp b/src/mame/atari/lynx.cpp index 7b8e730278a..fb4732510c0 100644 --- a/src/mame/atari/lynx.cpp +++ b/src/mame/atari/lynx.cpp @@ -118,12 +118,11 @@ void lynx_state::lynx2(machine_config &config) /* sound hardware */ config.device_remove("mono"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); LYNX2_SND(config.replace(), m_sound, XTAL(16'000'000)); m_sound->set_timer_delegate(FUNC(lynx_state::sound_cb)); - m_sound->add_route(0, "lspeaker", 0.50); - m_sound->add_route(1, "rspeaker", 0.50); + m_sound->add_route(0, "speaker", 0.50, 0); + m_sound->add_route(1, "speaker", 0.50, 1); } #endif diff --git a/src/mame/atari/mediagx.cpp b/src/mame/atari/mediagx.cpp index ef413948a6c..ea6d9a342f5 100644 --- a/src/mame/atari/mediagx.cpp +++ b/src/mame/atari/mediagx.cpp @@ -912,12 +912,11 @@ void mediagx_state::mediagx(machine_config &config) PALETTE(config, m_palette).set_entries(256); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "lspeaker", 1.0); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/atari/metalmx.cpp b/src/mame/atari/metalmx.cpp index 66e8c8f11c0..aba61fe4add 100644 --- a/src/mame/atari/metalmx.cpp +++ b/src/mame/atari/metalmx.cpp @@ -760,19 +760,16 @@ void metalmx_state::metalmx(machine_config &config) // TODO: copied from atarigt.cpp; Same configurations as T-Mek? // 5 Channel output (4 Channel input connected to Quad Amp PCB) - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); + SPEAKER(config, "speaker").front().headrest_left(2).headrest_right(3); //SPEAKER(config, "subwoofer").seat(); Not implemented, Quad Amp PCB output; ATARI_CAGE(config, m_cage, 0); m_cage->set_speedup(0); // TODO: speedup address m_cage->irq_handler().set(FUNC(metalmx_state::cage_irq_callback)); - m_cage->add_route(0, "frspeaker", 1.0); // Foward Right - m_cage->add_route(1, "rlspeaker", 1.0); // Back Left - m_cage->add_route(2, "flspeaker", 1.0); // Foward Left - m_cage->add_route(3, "rrspeaker", 1.0); // Back Right + m_cage->add_route(0, "speaker", 1.0, 1); // Foward Right + m_cage->add_route(1, "speaker", 1.0, 2); // Back Left + m_cage->add_route(2, "speaker", 1.0, 0); // Foward Left + m_cage->add_route(3, "speaker", 1.0, 3); // Back Right } diff --git a/src/mame/atari/orbit.cpp b/src/mame/atari/orbit.cpp index 91a3650adf5..70d3ee54879 100644 --- a/src/mame/atari/orbit.cpp +++ b/src/mame/atari/orbit.cpp @@ -471,12 +471,11 @@ void orbit_state::orbit(machine_config &config) PALETTE(config, m_palette, palette_device::MONOCHROME); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DISCRETE(config, m_discrete, orbit_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/atari/redbaron.cpp b/src/mame/atari/redbaron.cpp index 43989e8d85a..14932230a3a 100644 --- a/src/mame/atari/redbaron.cpp +++ b/src/mame/atari/redbaron.cpp @@ -123,10 +123,9 @@ void redbaron_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void redbaron_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void redbaron_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int sum = 0; @@ -225,7 +224,7 @@ void redbaron_sound_device::sound_stream_update(sound_stream &stream, std::vecto if( m_squeal_out ) sum += 32767 * 40 / 100; - buffer.put_int(sampindex, sum, 32768); + stream.put_int(0, sampindex, sum, 32768); } } diff --git a/src/mame/atari/redbaron.h b/src/mame/atari/redbaron.h index 8a9e303624b..4ddc5ff5f36 100644 --- a/src/mame/atari/redbaron.h +++ b/src/mame/atari/redbaron.h @@ -19,7 +19,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: std::unique_ptr<int16_t[]> m_vol_lookup; diff --git a/src/mame/atari/sprint2.cpp b/src/mame/atari/sprint2.cpp index b89eb436bb6..58f843b0c4c 100644 --- a/src/mame/atari/sprint2.cpp +++ b/src/mame/atari/sprint2.cpp @@ -784,8 +784,7 @@ void sprint2_state::sprint2(machine_config &config) PALETTE(config, m_palette, FUNC(sprint2_state::palette), 12, 4); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); F9334(config, m_outlatch); // at H8 m_outlatch->q_out_cb<0>().set("discrete", FUNC(discrete_device::write_line<SPRINT2_ATTRACT_EN>)); // also DOMINOS_ATTRACT_EN @@ -796,8 +795,8 @@ void sprint2_state::sprint2(machine_config &config) //m_outlatch->q_out_cb<6>().set(FUNC(sprint2_state::spare_w)); DISCRETE(config, m_discrete, sprint2_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } @@ -806,8 +805,7 @@ void sprint2_state::sprint1(machine_config &config) sprint2(config); // sound hardware - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); SPEAKER(config, "mono").front_center(); DISCRETE(config.replace(), m_discrete, sprint1_discrete).add_route(ALL_OUTPUTS, "mono", 1.0); diff --git a/src/mame/atari/sprint4.cpp b/src/mame/atari/sprint4.cpp index 3523519b953..45ca84f4d9e 100644 --- a/src/mame/atari/sprint4.cpp +++ b/src/mame/atari/sprint4.cpp @@ -583,8 +583,7 @@ void sprint4_state::sprint4(machine_config &config) PALETTE(config, m_palette, FUNC(sprint4_state::palette_init), 10, 6); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); f9334_device &latch(F9334(config, "latch")); // at E11 latch.q_out_cb<0>().set_output("led0"); // START LAMP 1 @@ -597,8 +596,8 @@ void sprint4_state::sprint4(machine_config &config) latch.q_out_cb<7>().set("discrete", FUNC(discrete_device::write_line<SPRINT4_SCREECH_EN_4>)); DISCRETE(config, m_discrete, sprint4_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } // NOTE: SPRINT 4 A008716 PCB can accept both 8bit ROMs and 4bit BPROMs or combination thereof diff --git a/src/mame/atari/subs.cpp b/src/mame/atari/subs.cpp index f6d06092766..a5e644da352 100644 --- a/src/mame/atari/subs.cpp +++ b/src/mame/atari/subs.cpp @@ -501,10 +501,9 @@ void subs_state::subs(machine_config &config) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DISCRETE(config, m_discrete, subs_discrete).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + DISCRETE(config, m_discrete, subs_discrete).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); ls259_device &latch(LS259(config, "latch")); // C9 latch.q_out_cb<0>().set_output("led0").invert(); // START LAMP 1 diff --git a/src/mame/atari/tomcat.cpp b/src/mame/atari/tomcat.cpp index 8f87dcb25c6..af5d183c809 100644 --- a/src/mame/atari/tomcat.cpp +++ b/src/mame/atari/tomcat.cpp @@ -376,17 +376,16 @@ void tomcat_state::tomcat(machine_config &config) avg.set_vector("vector"); avg.set_memory(m_maincpu, AS_PROGRAM, 0x800000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - POKEY(config, "pokey1", XTAL(14'318'181) / 8).add_route(ALL_OUTPUTS, "lspeaker", 0.20); + SPEAKER(config, "speaker", 2).front(); + POKEY(config, "pokey1", XTAL(14'318'181) / 8).add_route(ALL_OUTPUTS, "speaker", 0.20, 0); - POKEY(config, "pokey2", XTAL(14'318'181) / 8).add_route(ALL_OUTPUTS, "rspeaker", 0.20); + POKEY(config, "pokey2", XTAL(14'318'181) / 8).add_route(ALL_OUTPUTS, "speaker", 0.20, 1); TMS5220(config, m_tms, 325000); - m_tms->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_tms->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_tms->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_tms->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); - YM2151(config, "ymsnd", XTAL(14'318'181)/4).add_route(0, "lspeaker", 0.60).add_route(1, "rspeaker", 0.60); + YM2151(config, "ymsnd", XTAL(14'318'181)/4).add_route(0, "speaker", 0.60, 0).add_route(1, "speaker", 0.60, 1); } ROM_START( tomcat ) diff --git a/src/mame/atari/toobin.cpp b/src/mame/atari/toobin.cpp index d2fcb9ae39a..ccab5578336 100644 --- a/src/mame/atari/toobin.cpp +++ b/src/mame/atari/toobin.cpp @@ -542,14 +542,13 @@ void toobin_state::toobin(machine_config &config) PALETTE(config, m_palette).set_entries(1024); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_JSA_I(config, m_jsa, 0); m_jsa->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_IPL1); m_jsa->test_read_cb().set_ioport("FF9000").bit(12); - m_jsa->add_route(0, "lspeaker", 1.0); - m_jsa->add_route(1, "rspeaker", 1.0); + m_jsa->add_route(0, "speaker", 1.0, 0); + m_jsa->add_route(1, "speaker", 1.0, 1); config.device_remove("jsa:tms"); } diff --git a/src/mame/atari/vindictr.cpp b/src/mame/atari/vindictr.cpp index 54526e5dc99..1c72a5a7692 100644 --- a/src/mame/atari/vindictr.cpp +++ b/src/mame/atari/vindictr.cpp @@ -551,14 +551,13 @@ void vindictr_state::vindictr(machine_config &config) m_screen->set_palette(m_palette); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_JSA_I(config, m_jsa, 0); m_jsa->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_6); m_jsa->test_read_cb().set_ioport("260010").bit(12); - m_jsa->add_route(0, "lspeaker", 1.0); - m_jsa->add_route(1, "rspeaker", 1.0); + m_jsa->add_route(0, "speaker", 1.0, 0); + m_jsa->add_route(1, "speaker", 1.0, 1); config.device_remove("jsa:tms"); } diff --git a/src/mame/atari/xybots.cpp b/src/mame/atari/xybots.cpp index 8ce1adc3a42..9dc810a2e43 100644 --- a/src/mame/atari/xybots.cpp +++ b/src/mame/atari/xybots.cpp @@ -389,15 +389,14 @@ void xybots_state::xybots(machine_config &config) m_screen->screen_vblank().set_inputline(m_maincpu, M68K_IRQ_1, ASSERT_LINE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ATARI_JSA_I(config, m_jsa, 0); m_jsa->set_swapped_coins(true); m_jsa->main_int_cb().set_inputline(m_maincpu, M68K_IRQ_2); m_jsa->test_read_cb().set_ioport("FFE200").bit(8); - m_jsa->add_route(0, "rspeaker", 1.0); - m_jsa->add_route(1, "lspeaker", 1.0); + m_jsa->add_route(0, "speaker", 1.0, 1); + m_jsa->add_route(1, "speaker", 1.0, 0); config.device_remove("jsa:pokey"); config.device_remove("jsa:tms"); } diff --git a/src/mame/atlus/rallypnt.cpp b/src/mame/atlus/rallypnt.cpp index 4ab4fb40f5c..d3714d84148 100644 --- a/src/mame/atlus/rallypnt.cpp +++ b/src/mame/atlus/rallypnt.cpp @@ -131,12 +131,11 @@ void rallypnt_state::rallypnt(machine_config &config) // no video, only lamps // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 32_MHz_XTAL / 2)); // divider unknown (or 16.9344 MHz internal?) - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/ausnz/applix.cpp b/src/mame/ausnz/applix.cpp index 47bf2659a34..2b47b7192aa 100644 --- a/src/mame/ausnz/applix.cpp +++ b/src/mame/ausnz/applix.cpp @@ -870,10 +870,9 @@ void applix_state::applix(machine_config &config) PALETTE(config, m_palette, FUNC(applix_state::applix_palette), 16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC0800(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // 74ls374.u20 + dac0800.u21 + 4052.u23 - DAC0800(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // 74ls374.u20 + dac0800.u21 + 4052.u23 + SPEAKER(config, "speaker", 2).front(); + DAC0800(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // 74ls374.u20 + dac0800.u21 + 4052.u23 + DAC0800(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // 74ls374.u20 + dac0800.u21 + 4052.u23 /* Devices */ MC6845(config, m_crtc, 30_MHz_XTAL / 16); // MC6545 @ 1.875 MHz @@ -902,7 +901,7 @@ void applix_state::applix(machine_config &config) CASSETTE(config, m_cass); m_cass->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED); - m_cass->add_route(ALL_OUTPUTS, "lspeaker", 0.10); + m_cass->add_route(ALL_OUTPUTS, "speaker", 0.10, 0); WD1772(config, m_fdc, 16_MHz_XTAL / 2); //connected to Z80H clock pin FLOPPY_CONNECTOR(config, m_floppy[0], applix_floppies, "35dd", applix_state::floppy_formats).enable_sound(true); diff --git a/src/mame/bandai/wswan.cpp b/src/mame/bandai/wswan.cpp index fc149da6ce1..a2304d8489a 100644 --- a/src/mame/bandai/wswan.cpp +++ b/src/mame/bandai/wswan.cpp @@ -311,12 +311,11 @@ void wswan_state::wswan_base(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); WSWAN_SND(config, m_sound, X1 / 4); m_sound->set_addrmap(0, &wswan_state::snd_map); - m_sound->add_route(0, "lspeaker", 0.50); - m_sound->add_route(1, "rspeaker", 0.50); + m_sound->add_route(0, "speaker", 0.50, 0); + m_sound->add_route(1, "speaker", 0.50, 1); // cartridge WS_CART_SLOT(config, m_cart, X1 / 32, wswan_cart, nullptr); diff --git a/src/mame/barcrest/mpu4vid.cpp b/src/mame/barcrest/mpu4vid.cpp index 3788820e6cc..691a4f92f30 100644 --- a/src/mame/barcrest/mpu4vid.cpp +++ b/src/mame/barcrest/mpu4vid.cpp @@ -2086,8 +2086,8 @@ void mpu4vid_state::mpu4_vid(machine_config &config) AY8913(config, m_ay8913, MPU4_MASTER_CLOCK/4); m_ay8913->set_flags(AY8910_SINGLE_OUTPUT); m_ay8913->set_resistors_load(820, 0, 0); - m_ay8913->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_ay8913->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_ay8913->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_ay8913->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); /* confirm */ @@ -2124,13 +2124,12 @@ void mpu4vid_state::mpu4_vid(machine_config &config) m_ptm->o3_callback().set(FUNC(mpu4vid_state::vid_o3_callback)); m_ptm->irq_callback().set(FUNC(mpu4vid_state::cpu1_ptm_irq)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* Present on all video cards */ saa1099_device &saa(SAA1099(config, "saa", 8000000)); - saa.add_route(0, "lspeaker", 0.5); - saa.add_route(1, "rspeaker", 0.5); + saa.add_route(0, "speaker", 0.5, 0); + saa.add_route(1, "speaker", 0.5, 1); ACIA6850(config, m_acia_0, 0); m_acia_0->txd_handler().set("acia6850_1", FUNC(acia6850_device::write_rxd)); @@ -2187,8 +2186,8 @@ void mpu4vid_state::vid_oki(machine_config &config) //and all samples are adjusted to fit the different clock speed. MPU4_OKI_SAMPLED_SOUND(config, m_okicard, VIDEO_MASTER_CLOCK/10); - m_okicard->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_okicard->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_okicard->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_okicard->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); m_okicard->cb2_handler().set(FUNC(mpu4vid_state::pia_gb_cb2_w)); diff --git a/src/mame/barcrest/mpu5.cpp b/src/mame/barcrest/mpu5.cpp index 2e7bcda10ba..60d0e4df7db 100644 --- a/src/mame/barcrest/mpu5.cpp +++ b/src/mame/barcrest/mpu5.cpp @@ -441,7 +441,6 @@ void mpu5_state::mpu5(machine_config &config) config.set_default_layout(layout_mpu5); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* unknown sound */ } diff --git a/src/mame/bfm/bfm_ad5.cpp b/src/mame/bfm/bfm_ad5.cpp index 35066900f67..e14a404e1f6 100644 --- a/src/mame/bfm/bfm_ad5.cpp +++ b/src/mame/bfm/bfm_ad5.cpp @@ -187,7 +187,6 @@ void adder5_state::bfm_ad5(machine_config &config) m_maincpu->set_periodic_int(FUNC(adder5_state::ad5_fake_timer_int), attotime::from_hz(1000)); MCF5206E_PERIPHERAL(config, "maincpu_onboard", 0, m_maincpu); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* unknown sound */ } diff --git a/src/mame/bfm/rastersp.cpp b/src/mame/bfm/rastersp.cpp index dd3ca04dc96..338eb0ad1ee 100644 --- a/src/mame/bfm/rastersp.cpp +++ b/src/mame/bfm/rastersp.cpp @@ -1472,13 +1472,12 @@ void rastersp_state::rs_config_base(machine_config &config) PALETTE(config, m_palette, palette_device::RGB_565); /* Sound */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0); DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0); - m_ldac->add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - m_rdac->add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + m_ldac->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + m_rdac->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC SCC85C30(config, m_duart, 8'000'000); m_duart->configure_channels(1'843'200, 0, 1'843'200, 0); diff --git a/src/mame/bitcorp/gamate.cpp b/src/mame/bitcorp/gamate.cpp index af5fff060b5..a9eb5cee877 100644 --- a/src/mame/bitcorp/gamate.cpp +++ b/src/mame/bitcorp/gamate.cpp @@ -191,13 +191,13 @@ void gamate_state::gamate(machine_config &config) GAMATE_VIDEO(config, "video", 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); // Stereo headphone output - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // Stereo headphone output + AY8910(config, m_ay, 4433000 / 4); // AY compatible, no actual AY chip present - m_ay->add_route(0, "lspeaker", 0.5); - m_ay->add_route(1, "rspeaker", 0.5); - m_ay->add_route(2, "lspeaker", 0.25); - m_ay->add_route(2, "rspeaker", 0.25); + m_ay->add_route(0, "speaker", 0.5, 0); + m_ay->add_route(1, "speaker", 0.5, 1); + m_ay->add_route(2, "speaker", 0.25, 0); + m_ay->add_route(2, "speaker", 0.25, 1); GAMATE_CART_SLOT(config, m_cartslot, gamate_cart, nullptr); diff --git a/src/mame/bmc/bmcbowl.cpp b/src/mame/bmc/bmcbowl.cpp index 5d8f450bb61..37022194108 100644 --- a/src/mame/bmc/bmcbowl.cpp +++ b/src/mame/bmc/bmcbowl.cpp @@ -487,22 +487,21 @@ void bmcbowl_state::bmcbowl(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2413_device &ymsnd(YM2413(config, "ymsnd", 3.579545_MHz_XTAL)); // guessed chip type - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); ay8910_device &aysnd(AY8910(config, "aysnd", 21.477272_MHz_XTAL / 16)); // matches PCB recording aysnd.port_a_read_callback().set(FUNC(bmcbowl_state::dips1_r)); aysnd.port_b_write_callback().set(FUNC(bmcbowl_state::input_mux_w)); - aysnd.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - aysnd.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + aysnd.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + aysnd.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); okim6295_device &oki(OKIM6295(config, "oki", 21.477272_MHz_XTAL / 16, okim6295_device::PIN7_LOW)); // matches PCB recording - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); /* via */ via6522_device &via(MOS6522(config, "via6522", 13.3_MHz_XTAL / 16)); // clock not verified (controls music tempo) diff --git a/src/mame/bmc/koftball.cpp b/src/mame/bmc/koftball.cpp index 7c118605121..eb3b4e0bf5a 100644 --- a/src/mame/bmc/koftball.cpp +++ b/src/mame/bmc/koftball.cpp @@ -578,16 +578,15 @@ void koftball_state::koftball(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_koftball); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2413_device &ymsnd(YM2413(config, "ymsnd", 3.579545_MHz_XTAL)); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); okim6295_device &oki(OKIM6295(config, "oki", 21.477272_MHz_XTAL / 22, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 verified for jxzh - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } void koftball_state::jxzh(machine_config &config) diff --git a/src/mame/capcom/cps1.cpp b/src/mame/capcom/cps1.cpp index 1a77f2ac80b..2df3cb7002f 100644 --- a/src/mame/capcom/cps1.cpp +++ b/src/mame/capcom/cps1.cpp @@ -3984,8 +3984,7 @@ void cps_state::qsound(machine_config &config) /* sound hardware */ config.device_remove("mono"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.device_remove("soundlatch"); config.device_remove("soundlatch2"); @@ -3993,8 +3992,8 @@ void cps_state::qsound(machine_config &config) config.device_remove("oki"); qsound_device &qsound(QSOUND(config, "qsound")); - qsound.add_route(0, "lspeaker", 1.0); - qsound.add_route(1, "rspeaker", 1.0); + qsound.add_route(0, "speaker", 1.0, 0); + qsound.add_route(1, "speaker", 1.0, 1); } void cps_state::wofhfh(machine_config &config) diff --git a/src/mame/capcom/cps2.cpp b/src/mame/capcom/cps2.cpp index 4c94caa778a..13e356aba0e 100644 --- a/src/mame/capcom/cps2.cpp +++ b/src/mame/capcom/cps2.cpp @@ -1903,12 +1903,11 @@ void cps2_state::cps2(machine_config &config) PALETTE(config, m_palette, palette_device::BLACK).set_entries(0xc00); // Sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); QSOUND(config, m_qsound); - m_qsound->add_route(0, "lspeaker", 1.0); - m_qsound->add_route(1, "rspeaker", 1.0); + m_qsound->add_route(0, "speaker", 1.0, 0); + m_qsound->add_route(1, "speaker", 1.0, 1); } void cps2_state::cps2comm(machine_config &config) @@ -1945,8 +1944,8 @@ void cps2_state::gigaman2(machine_config &config) config.device_remove("qsound"); OKIM6295(config, m_oki, XTAL(32'000'000)/32, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.47); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.47); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } /************************************* diff --git a/src/mame/capcom/cps3.cpp b/src/mame/capcom/cps3.cpp index 2242cc2f8d2..53d3fe301d3 100644 --- a/src/mame/capcom/cps3.cpp +++ b/src/mame/capcom/cps3.cpp @@ -2522,12 +2522,11 @@ void cps3_state::cps3(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfxdecode_device::empty); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); CPS3(config, m_cps3sound, XTAL(42'954'545) / 3); - m_cps3sound->add_route(1, "lspeaker", 1.0); - m_cps3sound->add_route(0, "rspeaker", 1.0); + m_cps3sound->add_route(1, "speaker", 1.0, 0); + m_cps3sound->add_route(0, "speaker", 1.0, 1); } diff --git a/src/mame/capcom/cps3_a.cpp b/src/mame/capcom/cps3_a.cpp index 95dfe625c3e..21d463a2554 100644 --- a/src/mame/capcom/cps3_a.cpp +++ b/src/mame/capcom/cps3_a.cpp @@ -55,12 +55,8 @@ void cps3_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void cps3_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cps3_sound_device::sound_stream_update(sound_stream &stream) { - /* Clear the buffers */ - outputs[0].fill(0); - outputs[1].fill(0); - for (int i = 0; i < 16; i ++) { if (m_key & (1 << i)) @@ -103,7 +99,7 @@ void cps3_sound_device::sound_stream_update(sound_stream &stream, std::vector<re loop -= 0x400000; /* Go through the buffer and add voice contributions */ - for (int j = 0; j < outputs[0].samples(); j++) + for (int j = 0; j < stream.samples(); j++) { int32_t sample; @@ -127,21 +123,14 @@ void cps3_sound_device::sound_stream_update(sound_stream &stream, std::vector<re sample = m_base[BYTE4_XOR_LE(start + pos)]; frac += step; - outputs[0].add_int(j, sample * vol_l, 32768 << 8); - outputs[1].add_int(j, sample * vol_r, 32768 << 8); + stream.add_int(0, j, sample * vol_l, 32768 << 8); + stream.add_int(1, j, sample * vol_r, 32768 << 8); } vptr->pos = pos; vptr->frac = frac; } } - - // clamp the output; unknown what the real chip does - for (int sampindex = 0; sampindex < outputs[0].samples(); sampindex++) - { - outputs[0].put_clamp(sampindex, outputs[0].getraw(sampindex)); - outputs[1].put_clamp(sampindex, outputs[1].getraw(sampindex)); - } } diff --git a/src/mame/capcom/cps3_a.h b/src/mame/capcom/cps3_a.h index 4bbd5e3856a..4453a821512 100644 --- a/src/mame/capcom/cps3_a.h +++ b/src/mame/capcom/cps3_a.h @@ -46,7 +46,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/mame/capcom/sf.cpp b/src/mame/capcom/sf.cpp index 91de15e5884..60abe668009 100644 --- a/src/mame/capcom/sf.cpp +++ b/src/mame/capcom/sf.cpp @@ -775,25 +775,24 @@ void sf_state::sfan(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_444, 1024); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); MSM5205(config, m_msm[0], 384000); m_msm[0]->set_prescaler_selector(msm5205_device::SEX_4B); /* 8KHz playback ? */ - m_msm[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_msm[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_msm[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_msm[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); MSM5205(config, m_msm[1], 384000); m_msm[1]->set_prescaler_selector(msm5205_device::SEX_4B); /* 8KHz playback ? */ - m_msm[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_msm[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_msm[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_msm[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void sf_state::sfus(machine_config &config) diff --git a/src/mame/casio/ct8000.cpp b/src/mame/casio/ct8000.cpp index 5e4d9273bf6..2a1f82b4794 100644 --- a/src/mame/casio/ct8000.cpp +++ b/src/mame/casio/ct8000.cpp @@ -95,6 +95,7 @@ protected: void ct8000_io_map(address_map &map) ATTR_COLD; virtual void driver_start() override ATTR_COLD; + virtual void driver_reset() override ATTR_COLD; void p1_w(u8 data); u8 p1_r(); @@ -118,8 +119,6 @@ protected: void pll_w(offs_t offset, u8 data); virtual void update_clocks(); - attoseconds_t chorus_cv(attotime const &curtime); - required_device<i8049_device> m_maincpu; required_device_array<i8243_device, 2> m_io; @@ -136,6 +135,11 @@ protected: optional_ioport_array<13> m_inputs; + TIMER_CALLBACK_MEMBER(bbd_tick); + void bbd_setup_next_tick(); + + emu_timer *m_bbd_timer; + u16 m_key_select; u8 m_key_enable; @@ -200,12 +204,11 @@ void ct8000_state::ctmb1(machine_config &config) { config_base(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MIXER(config, m_mixer); - m_mixer->add_route(0, "lspeaker", 1.0); - m_mixer->add_route(0, "rspeaker", 1.0); + m_mixer->add_route(0, "speaker", 1.0, 0); + m_mixer->add_route(0, "speaker", 1.0, 1); // 931 A - sub (consonant) waveform UPD931(config, m_931a, m_maincpu->clock()); @@ -240,13 +243,13 @@ void ct8000_state::ctmb1(machine_config &config) FILTER_RC(config, "filter_ac1").set_ac().add_route(0, m_mixer, 1.0); - MN3207(config, m_bbd).set_cv_handler(FUNC(ct8000_state::chorus_cv)); + MN3207(config, m_bbd); m_mixer->add_route(0, m_bbd, 1.0); m_bbd->add_route(ALL_OUTPUTS, "chorus", 0.5); auto &bbd_mixer = MIXER(config, "chorus"); - bbd_mixer.add_route(0, "lspeaker", 0.4); - bbd_mixer.add_route(0, "rspeaker", -0.4); + bbd_mixer.add_route(0, "speaker", 0.4, 0); + bbd_mixer.add_route(0, "speaker", -0.4, 1); } //************************************************************************** @@ -284,6 +287,8 @@ void ct8000_state::ctfk1(machine_config &config) //************************************************************************** void ct8000_state::driver_start() { + m_bbd_timer = timer_alloc(FUNC(ct8000_state::bbd_tick), this); + m_bank->configure_entries(0, 2, memregion("bankrom")->base(), 0x800); m_key_select = 0xffff; @@ -306,6 +311,11 @@ void ct8000_state::driver_start() save_item(NAME(m_clock_div)); } +void ct8000_state::driver_reset() +{ + bbd_setup_next_tick(); +} + //************************************************************************** void ct8000_state::p1_w(u8 data) { @@ -632,15 +642,21 @@ void ct8000_state::update_clocks() } //************************************************************************** -attoseconds_t ct8000_state::chorus_cv(attotime const &cvtime) +TIMER_CALLBACK_MEMBER(ct8000_state::bbd_tick) +{ + m_bbd->tick(); + bbd_setup_next_tick(); +} + +void ct8000_state::bbd_setup_next_tick() { // 62.5 to 80 kHz, varies at 0.6666... Hz - double pos = cvtime.as_double() / 1.5; + double pos = machine().time().as_double() / 1.5; pos -= std::floor(pos); pos = (pos < 0.5) ? (2 * pos) : 2 * (1.0 - pos); const double bbd_freq = 62500 + (80000 - 62500) * pos; - return HZ_TO_ATTOSECONDS(bbd_freq); + m_bbd_timer->adjust(attotime::from_ticks(1, bbd_freq)); } diff --git a/src/mame/casio/ctk551.cpp b/src/mame/casio/ctk551.cpp index 8747bd29010..33c52981fdf 100644 --- a/src/mame/casio/ctk551.cpp +++ b/src/mame/casio/ctk551.cpp @@ -449,8 +449,8 @@ void ctk551_state::ap10(machine_config& config) // CPU GT913(config, m_maincpu, 24_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_DATA, &ctk551_state::ap10_map); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); m_maincpu->read_adc<0>().set_constant(0); m_maincpu->read_adc<1>().set_constant(0); m_maincpu->read_port1().set_ioport("P1"); @@ -474,8 +474,7 @@ void ctk551_state::ap10(machine_config& config) midiout_slot(mdout); m_maincpu->write_sci_tx<0>().set(mdout, FUNC(midi_port_device::write_txd)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.set_default_layout(layout_ap10); } @@ -485,8 +484,8 @@ void ctk551_state::ctk530(machine_config& config) // CPU GT913(config, m_maincpu, 20_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_DATA, &ctk551_state::ctk530_map); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); m_maincpu->read_adc<0>().set_constant(0); m_maincpu->read_adc<1>().set_constant(0); m_maincpu->read_port1().set_ioport("P1"); @@ -509,8 +508,7 @@ void ctk551_state::ctk530(machine_config& config) m_pwm->set_size(4, 8); m_pwm->set_segmask(0x7, 0xff); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.set_default_layout(layout_ctk530); } @@ -520,8 +518,8 @@ void ctk551_state::gz70sp(machine_config& config) // CPU GT913(config, m_maincpu, 30_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_DATA, &ctk551_state::gz70sp_map); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); m_maincpu->read_adc<0>().set_constant(0); m_maincpu->read_adc<1>().set_constant(0); m_maincpu->read_port1().set_ioport("P1"); @@ -537,8 +535,7 @@ void ctk551_state::gz70sp(machine_config& config) midiin_slot(mdin); mdin.rxd_handler().set(m_maincpu, FUNC(gt913_device::sci_rx_w<1>)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void ctk551_state::ctk601(machine_config& config) @@ -546,8 +543,8 @@ void ctk551_state::ctk601(machine_config& config) // CPU GT913(config, m_maincpu, 30_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_DATA, &ctk551_state::ctk601_map); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); m_maincpu->read_adc<0>().set_constant(0); m_maincpu->read_adc<1>().set_constant(0); m_maincpu->read_port1().set_ioport("P1_R"); @@ -579,8 +576,7 @@ void ctk551_state::ctk601(machine_config& config) screen.set_visarea_full(); screen.screen_vblank().set(FUNC(ctk551_state::render_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); m_switch = 0x8; } @@ -590,8 +586,8 @@ void ctk551_state::ctk551(machine_config &config) // CPU GT913(config, m_maincpu, 30'000'000 / 2); m_maincpu->set_addrmap(AS_DATA, &ctk551_state::ctk530_map); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); m_maincpu->read_adc<0>().set_ioport("AN0"); m_maincpu->read_adc<1>().set_ioport("AN1"); m_maincpu->read_port1().set_ioport("P1_R"); @@ -621,8 +617,7 @@ void ctk551_state::ctk551(machine_config &config) screen.set_visarea_full(); screen.screen_vblank().set(FUNC(ctk551_state::render_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); m_switch = 0x2; } diff --git a/src/mame/casio/cz1.cpp b/src/mame/casio/cz1.cpp index 1f4f6e1963d..866ccf8a2f8 100644 --- a/src/mame/casio/cz1.cpp +++ b/src/mame/casio/cz1.cpp @@ -877,11 +877,10 @@ void cz1_state::mz1(machine_config &config) config.set_default_layout(layout_mz1); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - MIXER(config, m_mixer[0]).add_route(0, "lspeaker", 1.0); - MIXER(config, m_mixer[1]).add_route(0, "rspeaker", 1.0); + MIXER(config, m_mixer[0]).add_route(0, "speaker", 1.0, 0); + MIXER(config, m_mixer[1]).add_route(0, "speaker", 1.0, 1); UPD933(config, m_upd933[0], 8.96_MHz_XTAL / 2); m_upd933[0]->irq_cb().set("irq", FUNC(input_merger_any_high_device::in_w<0>)); diff --git a/src/mame/casio/pv1000.cpp b/src/mame/casio/pv1000.cpp index 9ce06f3af3d..5f0f7dfebae 100644 --- a/src/mame/casio/pv1000.cpp +++ b/src/mame/casio/pv1000.cpp @@ -32,7 +32,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state @@ -117,14 +117,12 @@ void pv1000_sound_device::voice_w(offs_t offset, uint8_t data) square1 via i/o$F8 is -6dB, square2 via i/o$F9 is -3dB, defining square3 via i/o$FA as 0dB */ -void pv1000_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void pv1000_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - // Each channel has a different volume via resistor mixing which correspond to -6dB, -3dB, 0dB drops static const int volumes[3] = { 0x1000, 0x1800, 0x2000 }; - for (int index = 0; index < buffer.samples(); index++) + for (int index = 0; index < stream.samples(); index++) { s32 sum = 0; @@ -161,7 +159,7 @@ void pv1000_sound_device::sound_stream_update(sound_stream &stream, std::vector< sum += m_voice[2].val * volumes[2]; } - buffer.put_int(index, sum, 32768); + stream.put_int(0, index, sum, 32768); } } diff --git a/src/mame/casio/wk1800.cpp b/src/mame/casio/wk1800.cpp index 103ad490cde..f4aa2d87c31 100644 --- a/src/mame/casio/wk1800.cpp +++ b/src/mame/casio/wk1800.cpp @@ -321,12 +321,11 @@ void wk1600_state::wk1600(machine_config &config) screen.set_visarea_full(); screen.screen_vblank().set(FUNC(wk1600_state::render_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GT155(config, m_gt155, 24.576_MHz_XTAL); - m_gt155->add_route(0, "lspeaker", 1.0); - m_gt155->add_route(1, "rspeaker", 1.0); + m_gt155->add_route(0, "speaker", 1.0, 0); + m_gt155->add_route(1, "speaker", 1.0, 1); } /**************************************************************************/ diff --git a/src/mame/cinematronics/dlair.cpp b/src/mame/cinematronics/dlair.cpp index 396e80347cd..187ff0e85a2 100644 --- a/src/mame/cinematronics/dlair.cpp +++ b/src/mame/cinematronics/dlair.cpp @@ -736,13 +736,12 @@ void dlair_state::dlair_base(machine_config &config) m_maincpu->set_periodic_int(FUNC(dlair_state::irq0_line_hold), attotime::from_hz((double)MASTER_CLOCK_US/8/16/16/16/16)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ay8910_device &aysnd(AY8910(config, "aysnd", MASTER_CLOCK_US/8)); aysnd.port_a_read_callback().set_ioport("DSW1"); aysnd.port_b_read_callback().set_ioport("DSW2"); - aysnd.add_route(ALL_OUTPUTS, "rspeaker", 0.33); + aysnd.add_route(ALL_OUTPUTS, "speaker", 0.33, 1); } @@ -750,8 +749,8 @@ void dlair_state::dlair_pr7820(machine_config &config) { dlair_base(config); PIONEER_PR7820(config, m_pr7820, 0); - m_pr7820->add_route(0, "lspeaker", 1.0); - m_pr7820->add_route(1, "rspeaker", 1.0); + m_pr7820->add_route(0, "speaker", 1.0, 0); + m_pr7820->add_route(1, "speaker", 1.0, 1); m_pr7820->add_ntsc_screen(config, "screen"); } @@ -760,8 +759,8 @@ void dlair_state::dlair_ldv1000(machine_config &config) { dlair_base(config); PIONEER_LDV1000HLE(config, m_ldv1000, 0); - m_ldv1000->add_route(0, "lspeaker", 1.0); - m_ldv1000->add_route(1, "rspeaker", 1.0); + m_ldv1000->add_route(0, "speaker", 1.0, 0); + m_ldv1000->add_route(1, "speaker", 1.0, 1); m_ldv1000->add_ntsc_screen(config, "screen"); } @@ -786,8 +785,8 @@ void dlair_state::dleuro(machine_config &config) PHILIPS_22VP932(config, m_22vp932, 0); m_22vp932->set_overlay(256, 256, FUNC(dlair_state::screen_update_dleuro)); - m_22vp932->add_route(0, "lspeaker", 1.0); - m_22vp932->add_route(1, "rspeaker", 1.0); + m_22vp932->add_route(0, "speaker", 1.0, 0); + m_22vp932->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_22vp932->add_pal_screen(config, "screen"); @@ -796,12 +795,11 @@ void dlair_state::dleuro(machine_config &config) PALETTE(config, m_palette, FUNC(dlair_state::dleuro_palette), 16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SPEAKER_SOUND(config, m_speaker); - m_speaker->add_route(ALL_OUTPUTS, "lspeaker", 0.33); - m_speaker->add_route(ALL_OUTPUTS, "rspeaker", 0.33); + m_speaker->add_route(ALL_OUTPUTS, "speaker", 0.33, 0); + m_speaker->add_route(ALL_OUTPUTS, "speaker", 0.33, 1); } diff --git a/src/mame/commodore/c65.cpp b/src/mame/commodore/c65.cpp index 242564db746..88ea38d3bf7 100644 --- a/src/mame/commodore/c65.cpp +++ b/src/mame/commodore/c65.cpp @@ -1457,18 +1457,17 @@ void c65_state::c65(machine_config &config) PALETTE(config, m_palette, FUNC(c65_state::palette_init), 0x100); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // 8580 SID MOS6581(config, m_sid[0], MAIN_C64_CLOCK); //m_sid->potx().set(FUNC(c64_state::sid_potx_r)); //m_sid->poty().set(FUNC(c64_state::sid_poty_r)); - m_sid[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.50); + m_sid[0]->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); MOS6581(config, m_sid[1], MAIN_C64_CLOCK); //m_sid->potx().set(FUNC(c64_state::sid_potx_r)); //m_sid->poty().set(FUNC(c64_state::sid_poty_r)); - m_sid[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_sid[1]->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); VCS_CONTROL_PORT(config, m_joy[0], vcs_control_port_devices, "joy"); //m_joy1->trigger_wr_callback().set(MOS6567_TAG, FUNC(mos6567_device::lp_w)); diff --git a/src/mame/dai/dai.cpp b/src/mame/dai/dai.cpp index 1a328b774ce..daad3cdb88c 100644 --- a/src/mame/dai/dai.cpp +++ b/src/mame/dai/dai.cpp @@ -215,9 +215,8 @@ void dai_state::dai(machine_config &config) /* sound hardware */ SPEAKER(config, "mono").front_center(); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAI_SOUND(config, m_sound).add_route(0, "lspeaker", 0.50).add_route(1, "rspeaker", 0.50); + SPEAKER(config, "speaker", 2).front(); + DAI_SOUND(config, m_sound).add_route(0, "speaker", 0.50, 0).add_route(1, "speaker", 0.50, 1); /* cassette */ CASSETTE(config, m_cassette); diff --git a/src/mame/dai/dai_snd.cpp b/src/mame/dai/dai_snd.cpp index 4c61ec57e01..d5bdf459ed8 100644 --- a/src/mame/dai/dai_snd.cpp +++ b/src/mame/dai/dai_snd.cpp @@ -119,23 +119,20 @@ void dai_sound_device::set_input_ch2(int state) // our sound stream //------------------------------------------------- -void dai_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dai_sound_device::sound_stream_update(sound_stream &stream) { - auto &sample_left = outputs[0]; - auto &sample_right = outputs[1]; - int16_t channel_0_signal = m_dai_input[0] ? s_osc_volume_table[m_osc_volume[0]] : -s_osc_volume_table[m_osc_volume[0]]; int16_t channel_1_signal = m_dai_input[1] ? s_osc_volume_table[m_osc_volume[1]] : -s_osc_volume_table[m_osc_volume[1]]; int16_t channel_2_signal = m_dai_input[2] ? s_osc_volume_table[m_osc_volume[2]] : -s_osc_volume_table[m_osc_volume[2]]; - for (int sampindex = 0; sampindex < sample_left.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int16_t noise = machine().rand()&0x01 ? s_noise_volume_table[m_noise_volume] : -s_noise_volume_table[m_noise_volume]; /* channel 0 + channel 1 + noise */ - sample_left.put_int(sampindex, channel_0_signal + channel_1_signal + noise, 32768); + stream.put_int(0, sampindex, channel_0_signal + channel_1_signal + noise, 32768); /* channel 1 + channel 2 + noise */ - sample_right.put_int(sampindex, channel_1_signal + channel_2_signal + noise, 32768); + stream.put_int(1, sampindex, channel_1_signal + channel_2_signal + noise, 32768); } } diff --git a/src/mame/dai/dai_snd.h b/src/mame/dai/dai_snd.h index 9b37744170c..0792848cd2f 100644 --- a/src/mame/dai/dai_snd.h +++ b/src/mame/dai/dai_snd.h @@ -27,7 +27,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream * m_mixer_channel = nullptr; diff --git a/src/mame/dataeast/backfire.cpp b/src/mame/dataeast/backfire.cpp index 79715a95eb7..539853481e6 100644 --- a/src/mame/dataeast/backfire.cpp +++ b/src/mame/dataeast/backfire.cpp @@ -418,12 +418,11 @@ void backfire_state::backfire(machine_config &config) m_sprgen[1]->set_pri_callback(FUNC(backfire_state::pri_callback)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 28000000 / 2)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/dataeast/boogwing.cpp b/src/mame/dataeast/boogwing.cpp index 55b6c749017..bde499b67d6 100644 --- a/src/mame/dataeast/boogwing.cpp +++ b/src/mame/dataeast/boogwing.cpp @@ -338,8 +338,8 @@ void boogwing_state::boogwing(machine_config &config) H6280(config, m_audiocpu, SOUND_XTAL/4); m_audiocpu->set_addrmap(AS_PROGRAM, &boogwing_state::audio_map); - m_audiocpu->add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - m_audiocpu->add_route(ALL_OUTPUTS, "rspeaker", 0); + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 1); /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); @@ -391,22 +391,21 @@ void boogwing_state::boogwing(machine_config &config) m_deco104->set_use_magic_read_address_xor(true); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", SOUND_XTAL/9)); ymsnd.irq_handler().set_inputline(m_audiocpu, 1); /* IRQ2 */ ymsnd.port_write_handler().set(FUNC(boogwing_state::sound_bankswitch_w)); - ymsnd.add_route(0, "lspeaker", 0.32); - ymsnd.add_route(1, "rspeaker", 0.32); + ymsnd.add_route(0, "speaker", 0.32, 0); + ymsnd.add_route(1, "speaker", 0.32, 1); OKIM6295(config, m_oki[0], SOUND_XTAL/32, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.56); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.56); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.56, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.56, 1); OKIM6295(config, m_oki[1], SOUND_XTAL/16, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.12); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.12); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.12, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.12, 1); } /**********************************************************************************/ diff --git a/src/mame/dataeast/dassault.cpp b/src/mame/dataeast/dassault.cpp index dd2b89a4f56..a2884a2f643 100644 --- a/src/mame/dataeast/dassault.cpp +++ b/src/mame/dataeast/dassault.cpp @@ -744,8 +744,8 @@ void dassault_state::dassault(machine_config &config) H6280(config, m_audiocpu, XTAL(32'220'000) / 8); // Accurate m_audiocpu->set_addrmap(AS_PROGRAM, &dassault_state::sound_map); - m_audiocpu->add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - m_audiocpu->add_route(ALL_OUTPUTS, "rspeaker", 0); + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 1); config.set_maximum_quantum(attotime::from_hz(m_maincpu->clock() / 4)); // I was seeing random lockups.. let's see if this helps @@ -794,29 +794,28 @@ void dassault_state::dassault(machine_config &config) DECO_SPRITE(config, m_sprgen[1], 0, m_palette, gfx_dassault_spr2); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); // IRQ1 ym2203_device &ym1(YM2203(config, "ym1", XTAL(32'220'000) / 8)); - ym1.add_route(ALL_OUTPUTS, "lspeaker", 0.40); - ym1.add_route(ALL_OUTPUTS, "rspeaker", 0.40); + ym1.add_route(ALL_OUTPUTS, "speaker", 0.40, 0); + ym1.add_route(ALL_OUTPUTS, "speaker", 0.40, 1); ym2151_device &ym2(YM2151(config, "ym2", XTAL(32'220'000) / 9)); ym2.irq_handler().set_inputline(m_audiocpu, 1); ym2.port_write_handler().set(FUNC(dassault_state::sound_bankswitch_w)); - ym2.add_route(0, "lspeaker", 0.45); - ym2.add_route(1, "rspeaker", 0.45); + ym2.add_route(0, "speaker", 0.45, 0); + ym2.add_route(1, "speaker", 0.45, 1); okim6295_device &oki1(OKIM6295(config, "oki1", XTAL(32'220'000) / 32, okim6295_device::PIN7_HIGH)); // verified - oki1.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); OKIM6295(config, m_oki2, XTAL(32'220'000) / 16, okim6295_device::PIN7_HIGH); // verified - m_oki2->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_oki2->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } /**********************************************************************************/ diff --git a/src/mame/dataeast/deco156.cpp b/src/mame/dataeast/deco156.cpp index 9f4e755ef73..4a5fdf97743 100644 --- a/src/mame/dataeast/deco156.cpp +++ b/src/mame/dataeast/deco156.cpp @@ -393,12 +393,11 @@ void deco156_state::wcvol95(machine_config &config) m_sprgen->set_pri_callback(FUNC(deco156_state::pri_callback)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 28000000 / 2)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/dataeast/deco32.cpp b/src/mame/dataeast/deco32.cpp index cce80c1f347..ebefef14d40 100644 --- a/src/mame/dataeast/deco32.cpp +++ b/src/mame/dataeast/deco32.cpp @@ -1906,8 +1906,8 @@ void captaven_state::captaven(machine_config &config) h6280_device &audiocpu(H6280(config, m_audiocpu, XTAL(32'220'000)/4/3)); // pin 10 is 32mhz/4, pin 14 is High so internal divisor is 3 (verified on pcb) audiocpu.set_addrmap(AS_PROGRAM, &captaven_state::h6280_sound_map); - audiocpu.add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - audiocpu.add_route(ALL_OUTPUTS, "rspeaker", 0); + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 1); INPUT_MERGER_ANY_HIGH(config, "irq_merger").output_handler().set_inputline(m_maincpu, ARM_IRQ_LINE); @@ -1960,22 +1960,21 @@ void captaven_state::captaven(machine_config &config) m_ioprot->soundlatch_irq_cb().set_inputline(m_audiocpu, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, XTAL(32'220'000)/9); // verified on pcb m_ym2151->irq_handler().set_inputline(m_audiocpu, 1); m_ym2151->port_write_handler().set(FUNC(deco32_state::sound_bankswitch_w)); - m_ym2151->add_route(0, "lspeaker", 0.42); - m_ym2151->add_route(1, "rspeaker", 0.42); + m_ym2151->add_route(0, "speaker", 0.42, 0); + m_ym2151->add_route(1, "speaker", 0.42, 1); OKIM6295(config, m_oki[0], XTAL(32'220'000)/32, okim6295_device::PIN7_HIGH); // verified on pcb; pin 7 is floating to 2.5V (left unconnected), so I presume High - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); OKIM6295(config, m_oki[1], XTAL(32'220'000)/16, okim6295_device::PIN7_HIGH); // verified on pcb; pin 7 is floating to 2.5V (left unconnected), so I presume High - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.35); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.35); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 1); } // DE-0380-2 @@ -1987,8 +1986,8 @@ void fghthist_state::fghthist(machine_config &config) h6280_device &audiocpu(H6280(config, m_audiocpu, XTAL(32'220'000) / 8)); audiocpu.set_addrmap(AS_PROGRAM, &fghthist_state::h6280_sound_custom_latch_map); - audiocpu.add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - audiocpu.add_route(ALL_OUTPUTS, "rspeaker", 0); + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 1); EEPROM_93C46_16BIT(config, m_eeprom); @@ -2036,8 +2035,7 @@ void fghthist_state::fghthist(machine_config &config) m_ioprot->set_use_magic_read_address_xor(true); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); @@ -2045,16 +2043,16 @@ void fghthist_state::fghthist(machine_config &config) YM2151(config, m_ym2151, 32220000/9); m_ym2151->irq_handler().set_inputline(m_audiocpu, 1); m_ym2151->port_write_handler().set(FUNC(deco32_state::sound_bankswitch_w)); - m_ym2151->add_route(0, "lspeaker", 0.42); - m_ym2151->add_route(1, "rspeaker", 0.42); + m_ym2151->add_route(0, "speaker", 0.42, 0); + m_ym2151->add_route(1, "speaker", 0.42, 1); OKIM6295(config, m_oki[0], 32220000/32, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); OKIM6295(config, m_oki[1], 32220000/16, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.35); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.35); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 1); } // DE-0395-1 @@ -2084,8 +2082,8 @@ void fghthist_state::fghthistu(machine_config &config) m_ym2151->irq_handler().set("sound_irq_merger", FUNC(input_merger_any_high_device::in_w<1>)); m_ym2151->reset_routes(); - m_ym2151->add_route(0, "lspeaker", 0.40); - m_ym2151->add_route(1, "rspeaker", 0.40); + m_ym2151->add_route(0, "speaker", 0.40, 0); + m_ym2151->add_route(1, "speaker", 0.40, 1); } // DE-0359-2 + Bottom board DE-0360-4 @@ -2097,8 +2095,8 @@ void dragngun_state::dragngun(machine_config &config) h6280_device &audiocpu(H6280(config, m_audiocpu, 32220000/8)); audiocpu.set_addrmap(AS_PROGRAM, &dragngun_state::h6280_sound_map); - audiocpu.add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - audiocpu.add_route(ALL_OUTPUTS, "rspeaker", 0); + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 1); INPUT_MERGER_ANY_HIGH(config, "irq_merger").output_handler().set_inputline("maincpu", ARM_IRQ_LINE); @@ -2160,22 +2158,21 @@ void dragngun_state::dragngun(machine_config &config) m_ioprot->set_interface_scramble_reverse(); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, 32220000/9); m_ym2151->irq_handler().set_inputline(m_audiocpu, 1); m_ym2151->port_write_handler().set(FUNC(deco32_state::sound_bankswitch_w)); - m_ym2151->add_route(0, "lspeaker", 0.42); - m_ym2151->add_route(1, "rspeaker", 0.42); + m_ym2151->add_route(0, "speaker", 0.42, 0); + m_ym2151->add_route(1, "speaker", 0.42, 1); OKIM6295(config, m_oki[0], 32220000/32, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); OKIM6295(config, m_oki[1], 32220000/16, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.35); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.35); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 1); SPEAKER(config, "gun_speaker").front_center(); @@ -2294,22 +2291,21 @@ void dragngun_state::lockload(machine_config &config) m_ioprot->set_interface_scramble_reverse(); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, 32220000/9); m_ym2151->irq_handler().set("sound_irq_merger", FUNC(input_merger_any_high_device::in_w<1>)); m_ym2151->port_write_handler().set(FUNC(dragngun_state::lockload_okibank_lo_w)); - m_ym2151->add_route(0, "lspeaker", 0.42); - m_ym2151->add_route(1, "rspeaker", 0.42); + m_ym2151->add_route(0, "speaker", 0.42, 0); + m_ym2151->add_route(1, "speaker", 0.42, 1); OKIM6295(config, m_oki[0], 32220000/32, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); OKIM6295(config, m_oki[1], 32220000/16, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.35); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.35); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.35, 1); LC7535(config, m_vol_main); m_vol_main->select().set_constant(1); @@ -2371,12 +2367,11 @@ void tattass_state::tattass(machine_config &config) m_ioprot->set_interface_scramble_interleave(); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DECOBSMT(config, m_decobsmt, 0); - m_decobsmt->add_route(0, "lspeaker", 1.0); - m_decobsmt->add_route(1, "rspeaker", 1.0); + m_decobsmt->add_route(0, "speaker", 1.0, 0); + m_decobsmt->add_route(1, "speaker", 1.0, 1); } void nslasher_state::nslasher(machine_config &config) @@ -2442,22 +2437,21 @@ void nslasher_state::nslasher(machine_config &config) m_ioprot->set_interface_scramble_interleave(); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, 32220000/9); m_ym2151->irq_handler().set("sound_irq_merger", FUNC(input_merger_any_high_device::in_w<1>)); m_ym2151->port_write_handler().set(FUNC(deco32_state::sound_bankswitch_w)); - m_ym2151->add_route(0, "lspeaker", 0.40); - m_ym2151->add_route(1, "rspeaker", 0.40); + m_ym2151->add_route(0, "speaker", 0.40, 0); + m_ym2151->add_route(1, "speaker", 0.40, 1); OKIM6295(config, m_oki[0], 32220000/32, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); OKIM6295(config, m_oki[1], 32220000/16, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.10); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.10); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.10, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.10, 1); } // the US release uses a H6280 instead of a Z80, much like Lock 'n' Loaded @@ -2468,8 +2462,8 @@ void nslasher_state::nslasheru(machine_config &config) h6280_device &audiocpu(H6280(config, m_audiocpu, 32220000/8)); audiocpu.set_addrmap(AS_PROGRAM, &nslasher_state::h6280_sound_map); - audiocpu.add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - audiocpu.add_route(ALL_OUTPUTS, "rspeaker", 0); + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + audiocpu.add_route(ALL_OUTPUTS, "speaker", 0, 1); config.device_remove("sound_irq_merger"); diff --git a/src/mame/dataeast/deco_ld.cpp b/src/mame/dataeast/deco_ld.cpp index 361ef3942e6..01e63c0efde 100644 --- a/src/mame/dataeast/deco_ld.cpp +++ b/src/mame/dataeast/deco_ld.cpp @@ -484,8 +484,8 @@ void deco_ld_state::rblaster(machine_config &config) SONY_LDP1000(config, m_laserdisc, 0); m_laserdisc->set_overlay(256, 256, FUNC(deco_ld_state::screen_update)); //m_laserdisc->set_overlay_clip(0, 256-1, 8, 240-1); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_laserdisc->add_ntsc_screen(config, "screen"); @@ -498,17 +498,16 @@ void deco_ld_state::rblaster(machine_config &config) /* sound hardware */ // TODO: mixing with laserdisc - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); GENERIC_LATCH_8(config, m_soundlatch2); - AY8910(config, "ay1", 1500000).add_route(ALL_OUTPUTS, "lspeaker", 0.25).add_route(ALL_OUTPUTS, "rspeaker", 0.25); + AY8910(config, "ay1", 1500000).add_route(ALL_OUTPUTS, "speaker", 0.25, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); - AY8910(config, "ay2", 1500000).add_route(ALL_OUTPUTS, "lspeaker", 0.25).add_route(ALL_OUTPUTS, "rspeaker", 0.25); + AY8910(config, "ay2", 1500000).add_route(ALL_OUTPUTS, "speaker", 0.25, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } /*************************************************************************** diff --git a/src/mame/dataeast/deco_mlc.cpp b/src/mame/dataeast/deco_mlc.cpp index a881296639a..4b2386d96b9 100644 --- a/src/mame/dataeast/deco_mlc.cpp +++ b/src/mame/dataeast/deco_mlc.cpp @@ -560,12 +560,11 @@ void deco_mlc_state::avengrgs(machine_config &config) m_palette->set_membits(16); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, 42000000 / 3); - m_ymz->add_route(0, "lspeaker", 1.0); - m_ymz->add_route(1, "rspeaker", 1.0); + m_ymz->add_route(0, "speaker", 1.0, 0); + m_ymz->add_route(1, "speaker", 1.0, 1); } void deco_mlc_state::mlc(machine_config &config) @@ -592,12 +591,11 @@ void deco_mlc_state::mlc(machine_config &config) m_palette->set_membits(16); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, 42000000 / 3); - m_ymz->add_route(0, "lspeaker", 1.0); - m_ymz->add_route(1, "rspeaker", 1.0); + m_ymz->add_route(0, "speaker", 1.0, 0); + m_ymz->add_route(1, "speaker", 1.0, 1); } void deco_mlc_state::mlc_6bpp(machine_config &config) @@ -614,8 +612,8 @@ void deco_mlc_state::mlc_5bpp(machine_config &config) m_gfxdecode->set_info(gfx_5bpp); // TODO: mono? ch.0 doesn't output any sound in-game - m_ymz->add_route(1, "lspeaker", 1.0); - m_ymz->add_route(0, "rspeaker", 1.0); + m_ymz->add_route(1, "speaker", 1.0, 0); + m_ymz->add_route(0, "speaker", 1.0, 1); } void deco_mlc_state::stadhr96(machine_config &config) diff --git a/src/mame/dataeast/funkyjet.cpp b/src/mame/dataeast/funkyjet.cpp index 4a1912f76d0..5780b18c55c 100644 --- a/src/mame/dataeast/funkyjet.cpp +++ b/src/mame/dataeast/funkyjet.cpp @@ -405,8 +405,8 @@ void funkyjet_state::funkyjet(machine_config &config) H6280(config, m_audiocpu, XTAL(32'220'000)/4); // Custom chip 45, Audio section crystal is 32.220 MHz m_audiocpu->set_addrmap(AS_PROGRAM, &funkyjet_state::sound_map); - m_audiocpu->add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - m_audiocpu->add_route(ALL_OUTPUTS, "rspeaker", 0); + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 1); // video hardware SCREEN(config, m_screen, SCREEN_TYPE_RASTER); @@ -441,17 +441,16 @@ void funkyjet_state::funkyjet(machine_config &config) DECO_SPRITE(config, m_sprgen, 0, "palette", gfx_funkyjet_spr); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(32'220'000)/9)); ymsnd.irq_handler().set_inputline(m_audiocpu, 1); // IRQ2 - ymsnd.add_route(0, "lspeaker", 0.45); - ymsnd.add_route(1, "rspeaker", 0.45); + ymsnd.add_route(0, "speaker", 0.45, 0); + ymsnd.add_route(1, "speaker", 0.45, 1); okim6295_device &oki(OKIM6295(config, "oki", XTAL(28'000'000)/28, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } /******************************************************************************/ diff --git a/src/mame/dataeast/lemmings.cpp b/src/mame/dataeast/lemmings.cpp index 6a81a6be8ef..9e08988023a 100644 --- a/src/mame/dataeast/lemmings.cpp +++ b/src/mame/dataeast/lemmings.cpp @@ -482,19 +482,18 @@ void lemmings_state::lemmings(machine_config &config) m_deco146->soundlatch_irq_cb().set_inputline(m_audiocpu, M6809_FIRQ_LINE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym2151_device &ymsnd(YM2151(config, "ymsnd", 32.22_MHz_XTAL / 9)); // clock likely wrong ymsnd.irq_handler().set_inputline(m_audiocpu, M6809_IRQ_LINE); - ymsnd.add_route(0, "lspeaker", 0.45); - ymsnd.add_route(1, "rspeaker", 0.45); + ymsnd.add_route(0, "speaker", 0.45, 0); + ymsnd.add_route(1, "speaker", 0.45, 1); okim6295_device &oki(OKIM6295(config, "oki", 1023924, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } /******************************************************************************/ diff --git a/src/mame/dataeast/rohga.cpp b/src/mame/dataeast/rohga.cpp index 7fc8d33a3ce..f156d07eda9 100644 --- a/src/mame/dataeast/rohga.cpp +++ b/src/mame/dataeast/rohga.cpp @@ -873,8 +873,8 @@ void rohga_state::rohga_base(machine_config &config) H6280(config, m_audiocpu, 32'220'000/4/3); // verified on PCB (8.050Mhz is XIN on pin 10 of H6280 m_audiocpu->set_addrmap(AS_PROGRAM, &rohga_state::sound_map); - m_audiocpu->add_route(ALL_OUTPUTS, "lspeaker", 0); // internal sound unused - m_audiocpu->add_route(ALL_OUTPUTS, "rspeaker", 0); + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 0); // internal sound unused + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0, 1); // video hardware BUFFERED_SPRITERAM16(config, m_spriteram[0]); @@ -924,23 +924,22 @@ void rohga_state::rohga_base(machine_config &config) m_ioprot->port_c_cb().set_ioport("DSW"); m_ioprot->soundlatch_irq_cb().set_inputline("audiocpu", 0); - // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + /* sound hardware */ + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", 32'220'000/9)); ymsnd.irq_handler().set_inputline(m_audiocpu, 1); // IRQ2 ymsnd.port_write_handler().set(FUNC(rohga_state::sound_bankswitch_w)); - ymsnd.add_route(0, "lspeaker", 0.36); - ymsnd.add_route(1, "rspeaker", 0.36); + ymsnd.add_route(0, "speaker", 0.36, 0); + ymsnd.add_route(1, "speaker", 0.36, 1); OKIM6295(config, m_oki[0], 32'220'000/32, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.46); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.46); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.46, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.46, 1); OKIM6295(config, m_oki[1], 32'220'000/16, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.18); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.18); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.18, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.18, 1); } void rohga_state::rohga(machine_config &config) diff --git a/src/mame/dgrm/blackt96.cpp b/src/mame/dgrm/blackt96.cpp index 75659d0936b..f28098ff917 100644 --- a/src/mame/dgrm/blackt96.cpp +++ b/src/mame/dgrm/blackt96.cpp @@ -518,17 +518,16 @@ void blackt96_state::blackt96(machine_config &config) m_sprites->set_xpos_shift(12); m_sprites->set_color_entry_mask(0x7f); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki[0], 8_MHz_XTAL / 8, okim6295_device::PIN7_HIGH); // music - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.47); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.47); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.47, 1); m_oki[0]->set_addrmap(0, &blackt96_state::oki1_map); OKIM6295(config, m_oki[1], 8_MHz_XTAL / 8, okim6295_device::PIN7_HIGH); // sfx - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.47); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.47); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } diff --git a/src/mame/dynax/realbrk.cpp b/src/mame/dynax/realbrk.cpp index 6a3dc6e0316..1b732458063 100644 --- a/src/mame/dynax/realbrk.cpp +++ b/src/mame/dynax/realbrk.cpp @@ -768,16 +768,15 @@ void realbrk_state::realbrk(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x8000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(33'868'800) / 2)); - ymz.add_route(0, "lspeaker", 0.50); - ymz.add_route(1, "rspeaker", 0.50); + ymz.add_route(0, "speaker", 0.50, 0); + ymz.add_route(1, "speaker", 0.50, 1); ym2413_device &ymsnd(YM2413(config, "ymsnd", XTAL(3'579'545))); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.25); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.25); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } void realbrk_state::pkgnsh(machine_config &config) diff --git a/src/mame/edevices/mugsmash.cpp b/src/mame/edevices/mugsmash.cpp index 39340ea95e9..71339261716 100644 --- a/src/mame/edevices/mugsmash.cpp +++ b/src/mame/edevices/mugsmash.cpp @@ -504,20 +504,19 @@ void mugsmash_state::mugsmash(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x300); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3'579'545)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 1.00); // music - ymsnd.add_route(1, "rspeaker", 1.00); + ymsnd.add_route(0, "speaker", 1.00, 0); // music + ymsnd.add_route(1, "speaker", 1.00, 1); okim6295_device &oki(OKIM6295(config, "oki", 1'122'000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); // sound fx - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); // sound fx + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } ROM_START( mugsmash ) diff --git a/src/mame/elektron/elektronmono.cpp b/src/mame/elektron/elektronmono.cpp index 47f537c6889..a99cd3f735b 100644 --- a/src/mame/elektron/elektronmono.cpp +++ b/src/mame/elektron/elektronmono.cpp @@ -161,8 +161,7 @@ void elekmono_state::elektron(machine_config &config) MCF5206E(config, m_maincpu, XTAL(25'447'000)); m_maincpu->set_addrmap(AS_PROGRAM, &elekmono_state::elektron_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } static INPUT_PORTS_START( elektron ) diff --git a/src/mame/ensoniq/esq1.cpp b/src/mame/ensoniq/esq1.cpp index ce2250f0acf..34b1f951546 100644 --- a/src/mame/ensoniq/esq1.cpp +++ b/src/mame/ensoniq/esq1.cpp @@ -210,7 +210,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct filter { @@ -341,7 +341,7 @@ void esq1_filters::device_start() recalc_filter(elem); } -void esq1_filters::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void esq1_filters::sound_stream_update(sound_stream &stream) { /* if(0) { for(int i=0; i<8; i++) @@ -353,11 +353,11 @@ void esq1_filters::sound_stream_update(sound_stream &stream, std::vector<read_st fprintf(stderr, "\n"); }*/ - for(int i=0; i<outputs[0].samples(); i++) { + for(int i=0; i<stream.samples(); i++) { double l=0, r=0; for(int j=0; j<8; j++) { filter &f = filters[j]; - double x = inputs[j].get(i); + double x = stream.get(j, i); double y = (x*f.a[0] + f.x[0]*f.a[1] + f.x[1]*f.a[2] + f.x[2]*f.a[3] + f.x[3]*f.a[4] - f.y[0]*f.b[1] - f.y[1]*f.b[2] - f.y[2]*f.b[3] - f.y[3]*f.b[4]) / f.b[0]; @@ -379,8 +379,8 @@ void esq1_filters::sound_stream_update(sound_stream &stream, std::vector<read_st // r *= 6553; l *= 2; r *= 2; - outputs[0].put_clamp(i, l, 1.0); - outputs[1].put_clamp(i, r, 1.0); + stream.put_clamp(0, i, l, 1.0); + stream.put_clamp(1, i, r, 1.0); } } @@ -631,12 +631,11 @@ void esq1_state::esq1(machine_config &config) midiout_slot(MIDI_PORT(config, "mdout")); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ1_FILTERS(config, m_filters); - m_filters->add_route(0, "lspeaker", 1.0); - m_filters->add_route(1, "rspeaker", 1.0); + m_filters->add_route(0, "speaker", 1.0, 0); + m_filters->add_route(1, "speaker", 1.0, 1); ES5503(config, m_es5503, 8_MHz_XTAL); m_es5503->set_channels(8); diff --git a/src/mame/ensoniq/esq5505.cpp b/src/mame/ensoniq/esq5505.cpp index e6ef200b123..3289b3b98e0 100644 --- a/src/mame/ensoniq/esq5505.cpp +++ b/src/mame/ensoniq/esq5505.cpp @@ -658,13 +658,12 @@ void esq5505_state::vfx(machine_config &config) midiout_slot(MIDI_PORT(config, "mdout")); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ_5505_5510_PUMP(config, m_pump, 10_MHz_XTAL / (16 * 21)); m_pump->set_esp(m_esp); - m_pump->add_route(0, "lspeaker", 1.0); - m_pump->add_route(1, "rspeaker", 1.0); + m_pump->add_route(0, "speaker", 1.0, 0); + m_pump->add_route(1, "speaker", 1.0, 1); auto &es5505(ES5505(config, "otis", 10_MHz_XTAL)); es5505.sample_rate_changed().set(FUNC(esq5505_state::es5505_clock_changed)); @@ -749,13 +748,12 @@ void esq5505_state::vfx32(machine_config &config) midiout_slot(MIDI_PORT(config, "mdout")); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ_5505_5510_PUMP(config, m_pump, 30.47618_MHz_XTAL / (2 * 16 * 32)); m_pump->set_esp(m_esp); - m_pump->add_route(0, "lspeaker", 1.0); - m_pump->add_route(1, "rspeaker", 1.0); + m_pump->add_route(0, "speaker", 1.0, 0); + m_pump->add_route(1, "speaker", 1.0, 1); auto &es5505(ES5505(config, "otis", 30.47618_MHz_XTAL / 2)); es5505.sample_rate_changed().set(FUNC(esq5505_state::es5505_clock_changed)); diff --git a/src/mame/ensoniq/esqasr.cpp b/src/mame/ensoniq/esqasr.cpp index 9236473cdf6..c891449183a 100644 --- a/src/mame/ensoniq/esqasr.cpp +++ b/src/mame/ensoniq/esqasr.cpp @@ -130,13 +130,12 @@ void esqasr_state::asr(machine_config &config) ESQ2X40_SQ1(config, m_sq1vfd, 60); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ_5505_5510_PUMP(config, m_pump, XTAL(16'000'000) / (16 * 32)); m_pump->set_esp(m_esp); - m_pump->add_route(0, "lspeaker", 1.0); - m_pump->add_route(1, "rspeaker", 1.0); + m_pump->add_route(0, "speaker", 1.0, 0); + m_pump->add_route(1, "speaker", 1.0, 1); es5506_device &ensoniq(ES5506(config, "ensoniq", XTAL(16'000'000))); ensoniq.sample_rate_changed().set(FUNC(esqasr_state::es5506_clock_changed)); @@ -167,13 +166,12 @@ void esqasr_state::asrx(machine_config &config) ESQ2X40_SQ1(config, m_sq1vfd, 60); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ_5505_5510_PUMP(config, m_pump, XTAL(16'000'000) / (16 * 32)); // Actually ES5511 m_pump->set_esp(m_esp); - m_pump->add_route(0, "lspeaker", 1.0); - m_pump->add_route(1, "rspeaker", 1.0); + m_pump->add_route(0, "speaker", 1.0, 0); + m_pump->add_route(1, "speaker", 1.0, 1); es5506_device &ensoniq(ES5506(config, "ensoniq", XTAL(16'000'000))); ensoniq.sample_rate_changed().set(FUNC(esqasr_state::es5506_clock_changed)); diff --git a/src/mame/ensoniq/esqkt.cpp b/src/mame/ensoniq/esqkt.cpp index 647f7fbaacd..6b69a19443c 100644 --- a/src/mame/ensoniq/esqkt.cpp +++ b/src/mame/ensoniq/esqkt.cpp @@ -273,13 +273,12 @@ void esqkt_state::kt(machine_config &config) midiout_slot(MIDI_PORT(config, "mdout")); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ_5505_5510_PUMP(config, m_pump, 16_MHz_XTAL / (16 * 32)); m_pump->set_esp(m_esp); - m_pump->add_route(0, "lspeaker", 1.0); - m_pump->add_route(1, "rspeaker", 1.0); + m_pump->add_route(0, "speaker", 1.0, 0); + m_pump->add_route(1, "speaker", 1.0, 1); auto &es5506a(ES5506(config, "ensoniq1", 16_MHz_XTAL)); es5506a.sample_rate_changed().set(FUNC(esqkt_state::es5506_clock_changed)); // TODO : Sync with 2 chips? @@ -305,14 +304,14 @@ void esqkt_state::kt(machine_config &config) es5506b.set_region2("waverom3"); /* Bank 0 */ es5506b.set_region3("waverom4"); /* Bank 1 */ es5506b.set_channels(4); /* channels */ - es5506b.add_route(0, "lspeaker", 1.0); - es5506b.add_route(1, "rspeaker", 1.0); - es5506b.add_route(2, "lspeaker", 1.0); - es5506b.add_route(3, "rspeaker", 1.0); - es5506b.add_route(4, "lspeaker", 1.0); - es5506b.add_route(5, "rspeaker", 1.0); - es5506b.add_route(6, "lspeaker", 1.0); - es5506b.add_route(7, "rspeaker", 1.0); + es5506b.add_route(0, "speaker", 1.0, 0); + es5506b.add_route(1, "speaker", 1.0, 1); + es5506b.add_route(2, "speaker", 1.0, 0); + es5506b.add_route(3, "speaker", 1.0, 1); + es5506b.add_route(4, "speaker", 1.0, 0); + es5506b.add_route(5, "speaker", 1.0, 1); + es5506b.add_route(6, "speaker", 1.0, 0); + es5506b.add_route(7, "speaker", 1.0, 1); } void esqkt_state::ts(machine_config &config) @@ -338,13 +337,12 @@ void esqkt_state::ts(machine_config &config) midiout_slot(MIDI_PORT(config, "mdout")); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ESQ_5505_5510_PUMP(config, m_pump, 16_MHz_XTAL / (16 * 32)); m_pump->set_esp(m_esp); - m_pump->add_route(0, "lspeaker", 1.0); - m_pump->add_route(1, "rspeaker", 1.0); + m_pump->add_route(0, "speaker", 1.0, 0); + m_pump->add_route(1, "speaker", 1.0, 1); auto &es5506a(ES5506(config, "ensoniq", 16_MHz_XTAL)); es5506a.sample_rate_changed().set(FUNC(esqkt_state::es5506_clock_changed)); diff --git a/src/mame/ensoniq/esqmr.cpp b/src/mame/ensoniq/esqmr.cpp index 5a20eb7c03b..7d0c374393f 100644 --- a/src/mame/ensoniq/esqmr.cpp +++ b/src/mame/ensoniq/esqmr.cpp @@ -290,8 +290,7 @@ void esqmr_state::mr(machine_config &config) ESQPANEL2X40_VFX(config, m_panel); m_panel->write_tx().set(duart, FUNC(mc68340_serial_module_device::rx_b_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); es5506_device &ensoniq(ES5506(config, "ensoniq", XTAL(16'000'000))); ensoniq.set_region0("waverom"); /* Bank 0 */ @@ -301,8 +300,8 @@ void esqmr_state::mr(machine_config &config) ensoniq.set_channels(1); ensoniq.irq_cb().set(FUNC(esqmr_state::esq5506_otto_irq)); /* irq */ ensoniq.read_port_cb().set(FUNC(esqmr_state::esq5506_read_adc)); - ensoniq.add_route(0, "lspeaker", 0.5); - ensoniq.add_route(1, "rspeaker", 0.5); + ensoniq.add_route(0, "speaker", 0.5, 0); + ensoniq.add_route(1, "speaker", 0.5, 1); es5506_device &ensoniq2(ES5506(config, "ensoniq2", XTAL(16'000'000))); ensoniq2.set_region0("waverom"); /* Bank 0 */ @@ -310,8 +309,8 @@ void esqmr_state::mr(machine_config &config) ensoniq2.set_region2("waverom3"); /* Bank 0 */ ensoniq2.set_region3("waverom4"); /* Bank 1 */ ensoniq2.set_channels(1); - ensoniq2.add_route(0, "lspeaker", 0.5); - ensoniq2.add_route(1, "rspeaker", 0.5); + ensoniq2.add_route(0, "speaker", 0.5, 0); + ensoniq2.add_route(1, "speaker", 0.5, 1); } static INPUT_PORTS_START( mr ) diff --git a/src/mame/enterprise/dave.cpp b/src/mame/enterprise/dave.cpp index b84ba6cf8ff..0528f7ecd6e 100644 --- a/src/mame/enterprise/dave.cpp +++ b/src/mame/enterprise/dave.cpp @@ -192,7 +192,7 @@ device_memory_interface::space_config_vector dave_device::memory_space_config() // sound_stream_update - handle a stream update //------------------------------------------------- -void dave_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dave_device::sound_stream_update(sound_stream &stream) { /* 0 = channel 0 left volume, 1 = channel 0 right volume, 2 = channel 1 left volume, 3 = channel 1 right volume, @@ -204,10 +204,7 @@ void dave_device::sound_stream_update(sound_stream &stream, std::vector<read_str //logerror("sound update!\n"); - auto &buffer1 = outputs[0]; - auto &buffer2 = outputs[1]; - - for (int sampindex = 0; sampindex < buffer1.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int vol[4]; @@ -265,8 +262,8 @@ void dave_device::sound_stream_update(sound_stream &stream, std::vector<read_str left_volume = output_volumes[0] + output_volumes[2] + output_volumes[4] + output_volumes[6]; right_volume = output_volumes[1] + output_volumes[3] + output_volumes[5] + output_volumes[7]; - buffer1.put_int(sampindex, left_volume, 32768 * 4); - buffer2.put_int(sampindex, right_volume, 32768 * 4); + stream.put_int(0, sampindex, left_volume, 32768 * 4); + stream.put_int(1, sampindex, right_volume, 32768 * 4); } } diff --git a/src/mame/enterprise/dave.h b/src/mame/enterprise/dave.h index e5f6469da9a..04bd467cc80 100644 --- a/src/mame/enterprise/dave.h +++ b/src/mame/enterprise/dave.h @@ -48,7 +48,7 @@ protected: virtual space_config_vector memory_space_config() const override; // sound stream update implentation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(update_1hz_timer); TIMER_CALLBACK_MEMBER(update_50hz_timer); diff --git a/src/mame/enterprise/ep64.cpp b/src/mame/enterprise/ep64.cpp index e06a3dfff9e..c660a3b2c5e 100644 --- a/src/mame/enterprise/ep64.cpp +++ b/src/mame/enterprise/ep64.cpp @@ -594,15 +594,14 @@ void ep64_state::ep64(machine_config &config) m_nick->virq_wr_callback().set(m_dave, FUNC(dave_device::int1_w)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DAVE(config, m_dave, XTAL(8'000'000)); m_dave->set_addrmap(AS_PROGRAM, &ep64_state::dave_64k_mem); m_dave->set_addrmap(AS_IO, &ep64_state::dave_io); m_dave->irq_wr().set_inputline(Z80_TAG, INPUT_LINE_IRQ0); - m_dave->add_route(0, "lspeaker", 0.25); - m_dave->add_route(1, "rspeaker", 0.25); + m_dave->add_route(0, "speaker", 0.25, 0); + m_dave->add_route(1, "speaker", 0.25, 1); // devices EP64_EXPANSION_BUS_SLOT(config, m_exp, nullptr); @@ -623,12 +622,12 @@ void ep64_state::ep64(machine_config &config) CASSETTE(config, m_cassette1); m_cassette1->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED); m_cassette1->set_interface("ep64_cass"); - m_cassette1->add_route(ALL_OUTPUTS, "lspeaker", 0.05); + m_cassette1->add_route(ALL_OUTPUTS, "speaker", 0.05, 0); CASSETTE(config, m_cassette2); m_cassette2->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED); m_cassette2->set_interface("ep64_cass"); - m_cassette2->add_route(ALL_OUTPUTS, "rspeaker", 0.05); + m_cassette2->add_route(ALL_OUTPUTS, "speaker", 0.05, 1); // internal RAM RAM(config, m_ram).set_default_size("64K"); diff --git a/src/mame/eolith/eolith.cpp b/src/mame/eolith/eolith.cpp index bd190b53000..e3ad5150b1e 100644 --- a/src/mame/eolith/eolith.cpp +++ b/src/mame/eolith/eolith.cpp @@ -723,8 +723,7 @@ void eolith_state::eolith45(machine_config &config) PALETTE(config, m_palette, palette_device::RGB_555); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_soundcpu, MCS51_INT0_LINE); @@ -733,8 +732,8 @@ void eolith_state::eolith45(machine_config &config) m_qs1000->p1_in().set(FUNC(eolith_state::qs1000_p1_r)); m_qs1000->p1_out().set(FUNC(eolith_state::qs1000_p1_w)); m_qs1000->p3_in().set(FUNC(eolith_state::qs1000_p3_r)); - m_qs1000->add_route(0, "lspeaker", 1.0); - m_qs1000->add_route(1, "rspeaker", 1.0); + m_qs1000->add_route(0, "speaker", 1.0, 0); + m_qs1000->add_route(1, "speaker", 1.0, 1); } void eolith_state::eolith50(machine_config &config) diff --git a/src/mame/eolith/eolith16.cpp b/src/mame/eolith/eolith16.cpp index adb080791ad..fd144026520 100644 --- a/src/mame/eolith/eolith16.cpp +++ b/src/mame/eolith/eolith16.cpp @@ -185,12 +185,11 @@ void eolith16_state::eolith16(machine_config &config) PALETTE(config, "palette", FUNC(eolith16_state::eolith16_palette), 256); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", XTAL(1'000'000), okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } /* diff --git a/src/mame/eolith/ghosteo.cpp b/src/mame/eolith/ghosteo.cpp index 3a32bb47822..db8076bba17 100644 --- a/src/mame/eolith/ghosteo.cpp +++ b/src/mame/eolith/ghosteo.cpp @@ -647,8 +647,7 @@ void ghosteo_state::ghosteo(machine_config &config) I2C_24C16(config, "i2cmem", 0); // M24CL16-S /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(m_qs1000, FUNC(qs1000_device::set_irq)); @@ -660,8 +659,8 @@ void ghosteo_state::ghosteo(machine_config &config) m_qs1000->p1_out().set(FUNC(ghosteo_state::qs1000_p1_w)); m_qs1000->p2_out().set(FUNC(ghosteo_state::qs1000_p2_w)); m_qs1000->p3_out().set(FUNC(ghosteo_state::qs1000_p3_w)); - m_qs1000->add_route(0, "lspeaker", 1.0); - m_qs1000->add_route(1, "rspeaker", 1.0); + m_qs1000->add_route(0, "speaker", 1.0, 0); + m_qs1000->add_route(1, "speaker", 1.0, 1); } void ghosteo_state::bballoon(machine_config &config) diff --git a/src/mame/eolith/vegaeo.cpp b/src/mame/eolith/vegaeo.cpp index d916f5f4619..68280ce3498 100644 --- a/src/mame/eolith/vegaeo.cpp +++ b/src/mame/eolith/vegaeo.cpp @@ -203,8 +203,7 @@ void vegaeo_state::vega(machine_config &config) m_palette->set_membits(16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set("qs1000", FUNC(qs1000_device::set_irq)); @@ -216,8 +215,8 @@ void vegaeo_state::vega(machine_config &config) m_qs1000->p1_out().set(FUNC(vegaeo_state::qs1000_p1_w)); m_qs1000->p2_out().set(FUNC(vegaeo_state::qs1000_p2_w)); m_qs1000->p3_out().set(FUNC(vegaeo_state::qs1000_p3_w)); - m_qs1000->add_route(0, "lspeaker", 1.0); - m_qs1000->add_route(1, "rspeaker", 1.0); + m_qs1000->add_route(0, "speaker", 1.0, 0); + m_qs1000->add_route(1, "speaker", 1.0, 1); } /* diff --git a/src/mame/excellent/aquarium.cpp b/src/mame/excellent/aquarium.cpp index b1de277ca88..28c4c80eeb5 100644 --- a/src/mame/excellent/aquarium.cpp +++ b/src/mame/excellent/aquarium.cpp @@ -444,8 +444,7 @@ void aquarium_state::aquarium(machine_config &config) m_sprgen->set_colpri_callback(FUNC(aquarium_state::aquarium_colpri_cb)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -453,12 +452,12 @@ void aquarium_state::aquarium(machine_config &config) ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181) / 4)); // clock not verified on PCB ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.45); - ymsnd.add_route(1, "rspeaker", 0.45); + ymsnd.add_route(0, "speaker", 0.45, 0); + ymsnd.add_route(1, "speaker", 0.45, 1); OKIM6295(config, m_oki, XTAL(1'056'000), okim6295_device::PIN7_HIGH); // pin 7 not verified - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.47); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.47); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } ROM_START( aquarium ) diff --git a/src/mame/excellent/es9501.cpp b/src/mame/excellent/es9501.cpp index 782e4688ab8..627d5675102 100644 --- a/src/mame/excellent/es9501.cpp +++ b/src/mame/excellent/es9501.cpp @@ -166,16 +166,15 @@ void es9501_state::es9501(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_es9501); PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 0x1000 / 2); // TODO - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 28.636363_MHz_XTAL / 2)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); ymz284_device & ymz284(YMZ284(config, "ymz284", 28.636363_MHz_XTAL / 8)); // divider not verified - ymz284.add_route(0, "lspeaker", 1.0); - ymz284.add_route(1, "rspeaker", 1.0); + ymz284.add_route(0, "speaker", 1.0, 0); + ymz284.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/exidy/exidy440.cpp b/src/mame/exidy/exidy440.cpp index 4b7685952e0..f9e75a6ed3a 100644 --- a/src/mame/exidy/exidy440.cpp +++ b/src/mame/exidy/exidy440.cpp @@ -1005,12 +1005,11 @@ void exidy440_state::exidy440(machine_config &config) exidy440_video(config); /* audio hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); EXIDY440(config, m_custom, EXIDY440_MC3418_CLOCK); - m_custom->add_route(0, "lspeaker", 1.0); - m_custom->add_route(1, "rspeaker", 1.0); + m_custom->add_route(0, "speaker", 1.0, 0); + m_custom->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/exidy/exidy440_a.cpp b/src/mame/exidy/exidy440_a.cpp index 0ad11f3cfd5..127e6d49be2 100644 --- a/src/mame/exidy/exidy440_a.cpp +++ b/src/mame/exidy/exidy440_a.cpp @@ -82,10 +82,10 @@ void exidy440_sound_device::device_add_mconfig(machine_config &config) MC6809(config, m_audiocpu, EXIDY440_AUDIO_CLOCK); m_audiocpu->set_addrmap(AS_PROGRAM, &exidy440_sound_device::exidy440_audio_map); -// MC3418(config, "cvsd1", EXIDY440_MC3418_CLOCK).add_route(ALL_OUTPUTS, "lspeaker", 1.0); -// MC3418(config, "cvsd2", EXIDY440_MC3418_CLOCK).add_route(ALL_OUTPUTS, "rspeaker", 1.0); -// MC3417(config, "cvsd3", EXIDY440_MC3417_CLOCK).add_route(ALL_OUTPUTS, "lspeaker", 1.0); -// MC3417(config, "cvsd4", EXIDY440_MC3417_CLOCK).add_route(ALL_OUTPUTS, "rspeaker", 1.0); +// MC3418(config, "cvsd1", EXIDY440_MC3418_CLOCK).add_route(ALL_OUTPUTS, "speaker", 1.0); +// MC3418(config, "cvsd2", EXIDY440_MC3418_CLOCK).add_route(ALL_OUTPUTS, "speaker", 1.0); +// MC3417(config, "cvsd3", EXIDY440_MC3417_CLOCK).add_route(ALL_OUTPUTS, "speaker", 1.0); +// MC3417(config, "cvsd4", EXIDY440_MC3417_CLOCK).add_route(ALL_OUTPUTS, "speaker", 1.0); } //------------------------------------------------- @@ -205,15 +205,15 @@ void exidy440_sound_device::add_and_scale_samples(int ch, int32_t *dest, int sam * *************************************/ -void exidy440_sound_device::mix_to_16(write_stream_view &dest_left, write_stream_view &dest_right) +void exidy440_sound_device::mix_to_16(sound_stream &stream) { int32_t *mixer_left = &m_mixer_buffer_left[0]; int32_t *mixer_right = &m_mixer_buffer_right[0]; - for (int i = 0; i < dest_left.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - dest_left.put_int_clamp(i, *mixer_left++, 32768); - dest_right.put_int_clamp(i, *mixer_right++, 32768); + stream.put_int_clamp(0, i, *mixer_left++, 32768); + stream.put_int_clamp(1, i, *mixer_right++, 32768); } } @@ -789,17 +789,17 @@ void exidy440_sound_device::sound_banks_w(offs_t offset, uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void exidy440_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void exidy440_sound_device::sound_stream_update(sound_stream &stream) { /* reset the mixer buffers */ - std::fill_n(&m_mixer_buffer_left[0], outputs[0].samples(), 0); - std::fill_n(&m_mixer_buffer_right[0], outputs[0].samples(), 0); + std::fill_n(&m_mixer_buffer_left[0], stream.samples(), 0); + std::fill_n(&m_mixer_buffer_right[0], stream.samples(), 0); /* loop over channels */ for (int ch = 0; ch < 4; ch++) { sound_channel_data *channel = &m_sound_channel[ch]; - int length, volume, left = outputs[0].samples(); + int length, volume, left = stream.samples(); int effective_offset; /* if we're not active, bail */ @@ -837,5 +837,5 @@ void exidy440_sound_device::sound_stream_update(sound_stream &stream, std::vecto } /* all done, time to mix it */ - mix_to_16(outputs[0], outputs[1]); + mix_to_16(stream); } diff --git a/src/mame/exidy/exidy440_a.h b/src/mame/exidy/exidy440_a.h index 4a27c9b1ab5..3f25bd7d451 100644 --- a/src/mame/exidy/exidy440_a.h +++ b/src/mame/exidy/exidy440_a.h @@ -29,7 +29,7 @@ protected: virtual void device_stop() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void exidy440_audio_map(address_map &map) ATTR_COLD; @@ -104,7 +104,7 @@ private: void fir_filter(int32_t *input, int16_t *output, int count); void add_and_scale_samples(int ch, int32_t *dest, int samples, int volume); - void mix_to_16(write_stream_view &dest_left, write_stream_view &dest_right); + void mix_to_16(sound_stream &stream); uint8_t sound_command_r(); uint8_t sound_volume_r(offs_t offset); diff --git a/src/mame/exidy/starfire.cpp b/src/mame/exidy/starfire.cpp index a89fd18205c..6b84e897667 100644 --- a/src/mame/exidy/starfire.cpp +++ b/src/mame/exidy/starfire.cpp @@ -419,13 +419,12 @@ void fireone_state::fireone(machine_config &config) m_pit->out_handler<2>().set(FUNC(fireone_state::music_c_out_cb)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); NETLIST_SOUND(config, "sound_nl", 48000) .set_source(NETLIST_NAME(fireone)) - .add_route(0, "lspeaker", 1.0) - .add_route(1, "rspeaker", 1.0); + .add_route(0, "speaker", 1.0, 0) + .add_route(1, "speaker", 1.0, 1); NETLIST_LOGIC_INPUT(config, "sound_nl:ltorp", "LTORP.IN", 0); NETLIST_LOGIC_INPUT(config, "sound_nl:lshpht", "LSHPHT.IN", 0); diff --git a/src/mame/exidy/vertigo.cpp b/src/mame/exidy/vertigo.cpp index 60558f6b0bf..5ebc8d371ac 100644 --- a/src/mame/exidy/vertigo.cpp +++ b/src/mame/exidy/vertigo.cpp @@ -119,12 +119,11 @@ void vertigo_state::vertigo(machine_config &config) m_adc->in_callback<2>().set_ioport("PADDLE"); // IN3-IN7 tied to Vss - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); EXIDY440(config, m_custom, EXIDY440_MC3418_CLOCK); - m_custom->add_route(0, "lspeaker", 1.0); - m_custom->add_route(1, "rspeaker", 1.0); + m_custom->add_route(0, "speaker", 1.0, 0); + m_custom->add_route(1, "speaker", 1.0, 1); pit8254_device &pit(PIT8254(config, "pit", 0)); pit.set_clk<0>(24_MHz_XTAL / 100); diff --git a/src/mame/f32/f-32.cpp b/src/mame/f32/f-32.cpp index 901b6d980d5..4a8d01fd0c2 100644 --- a/src/mame/f32/f-32.cpp +++ b/src/mame/f32/f-32.cpp @@ -262,16 +262,15 @@ void mosaicf2_state::mosaicf2(machine_config &config) PALETTE(config, "palette", palette_device::RGB_555); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181)/4)); /* 3.579545 MHz */ - ymsnd.add_route(0, "lspeaker", 1.0); - ymsnd.add_route(1, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 1.0, 0); + ymsnd.add_route(1, "speaker", 1.0, 1); okim6295_device &oki(OKIM6295(config, "oki", XTAL(14'318'181)/8, okim6295_device::PIN7_HIGH)); /* 1.7897725 MHz */ - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } @@ -484,17 +483,16 @@ void royalpk2_state::royalpk2(machine_config &config) PALETTE(config, "palette", palette_device::RGB_555); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181)/4)); /* 3.579545 MHz */ -// ymsnd.add_route(0, "lspeaker", 1.0); -// ymsnd.add_route(1, "rspeaker", 1.0); +// ymsnd.add_route(0, "speaker", 1.0); +// ymsnd.add_route(1, "speaker", 1.0); okim6295_device &oki(OKIM6295(config, "oki", XTAL(14'318'181)/8, okim6295_device::PIN7_HIGH)); /* 1.7897725 MHz */ oki.set_addrmap(0, &royalpk2_state::oki_map); - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // there is a 16c550 for communication } diff --git a/src/mame/fairchild/channelf_a.cpp b/src/mame/fairchild/channelf_a.cpp index bd1dbe765f1..5ba7aa5c81e 100644 --- a/src/mame/fairchild/channelf_a.cpp +++ b/src/mame/fairchild/channelf_a.cpp @@ -70,15 +70,13 @@ void channelf_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void channelf_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void channelf_sound_device::sound_stream_update(sound_stream &stream) { uint32_t mask = 0, target = 0; - auto &buffer = outputs[0]; switch( m_sound_mode ) { case 0: /* sound off */ - buffer.fill(0); return; case 1: /* high tone (2V) - 1000Hz */ @@ -95,12 +93,12 @@ void channelf_sound_device::sound_stream_update(sound_stream &stream, std::vecto break; } - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if ((m_forced_ontime > 0) || ((m_sample_counter & mask) == target)) // change made for improved sound - buffer.put_int(sampindex, m_envelope, 32768); + stream.put_int(0, sampindex, m_envelope, 32768); else - buffer.put(sampindex, 0); + stream.put(1, sampindex, 0); m_sample_counter += m_incr; m_envelope *= m_decay_mult; if (m_forced_ontime > 0) // added for improved sound diff --git a/src/mame/fairchild/channelf_a.h b/src/mame/fairchild/channelf_a.h index d6784ede335..b74b787bdb5 100644 --- a/src/mame/fairchild/channelf_a.h +++ b/src/mame/fairchild/channelf_a.h @@ -20,7 +20,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state sound_stream *m_channel; diff --git a/src/mame/fairlight/cmi01a.cpp b/src/mame/fairlight/cmi01a.cpp index 59f1663efd4..4754509c5dc 100644 --- a/src/mame/fairlight/cmi01a.cpp +++ b/src/mame/fairlight/cmi01a.cpp @@ -211,13 +211,11 @@ void cmi01a_device::device_reset() update_filters(); } -void cmi01a_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void cmi01a_device::sound_stream_update(sound_stream &stream) { if (m_run) { - auto &buf = outputs[0]; - - for (int sampindex = 0; sampindex < buf.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { double sample = s8(m_current_sample ^ 0x80); // -128..127 double hbn = (sample + 2*m_ha0 + m_ha1 - m_ka1 * m_hb0 - m_ka2 * m_hb1) / m_ka0; @@ -231,7 +229,7 @@ void cmi01a_device::sound_stream_update(sound_stream &stream, std::vector<read_s double env = (m_env == 0) ? 0.0 : hbn * m_env; // -32768..32767 (guard against ∞ × 0 → NaN) double vol = env * m_vol_latch; // -8388608..8388607 - buf.put(sampindex, vol / 8388608); + stream.put(0, sampindex, vol / 8388608); } } else @@ -239,7 +237,6 @@ void cmi01a_device::sound_stream_update(sound_stream &stream, std::vector<read_s m_ha0 = m_ha1 = 0; m_hb0 = m_hb1 = 0; m_hc0 = m_hc1 = 0; - outputs[0].fill(0); } } diff --git a/src/mame/fairlight/cmi01a.h b/src/mame/fairlight/cmi01a.h index 0531b3106d8..8cb5e26819e 100644 --- a/src/mame/fairlight/cmi01a.h +++ b/src/mame/fairlight/cmi01a.h @@ -28,7 +28,7 @@ public: void write(offs_t offset, u8 data); u8 read(offs_t offset); - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void set_master_osc(double mosc) { m_mosc = mosc; } diff --git a/src/mame/fujitsu/fmtowns.cpp b/src/mame/fujitsu/fmtowns.cpp index a6c03eddf5a..84adf9ffd3c 100644 --- a/src/mame/fujitsu/fmtowns.cpp +++ b/src/mame/fujitsu/fmtowns.cpp @@ -2607,34 +2607,33 @@ void towns_state::towns_base(machine_config &config) PALETTE(config, m_palette16[1]).set_entries(16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3438_device &fm(YM3438(config, "fm", 16000000 / 2)); // actual clock speed unknown fm.irq_handler().set(FUNC(towns_state::towns_fm_irq)); - fm.add_route(0, "lspeaker", 1.00); - fm.add_route(1, "rspeaker", 1.00); + fm.add_route(0, "speaker", 1.00, 0); + fm.add_route(1, "speaker", 1.00, 1); /* // Later model uses YMF276 for FM ymf276_device &fm(YMF276(config, "fm", 16000000 / 2)); // actual clock speed unknown fm.irq_handler().set(FUNC(towns_state::towns_fm_irq)); - fm.add_route(0, "lspeaker", 1.00); - fm.add_route(1, "rspeaker", 1.00); + fm.add_route(0, "speaker", 1.00); + fm.add_route(1, "speaker", 1.00); */ rf5c68_device &pcm(RF5C68(config, "pcm", 16000000 / 2)); // actual clock speed unknown pcm.set_end_callback(FUNC(towns_state::towns_pcm_irq)); pcm.set_addrmap(0, &towns_state::pcm_mem); - pcm.add_route(0, "lspeaker", 1.00); - pcm.add_route(1, "rspeaker", 1.00); + pcm.add_route(0, "speaker", 1.00, 0); + pcm.add_route(1, "speaker", 1.00, 1); CDDA(config, m_cdda); - m_cdda->add_route(0, "lspeaker", 0.30); - m_cdda->add_route(1, "rspeaker", 0.30); + m_cdda->add_route(0, "speaker", 0.30, 0); + m_cdda->add_route(1, "speaker", 0.30, 1); SPEAKER_SOUND(config, m_speaker); - m_speaker->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_speaker->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_speaker->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_speaker->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); PIT8253(config, m_pit, 0); m_pit->set_clk<0>(307200); diff --git a/src/mame/funtech/supracan.cpp b/src/mame/funtech/supracan.cpp index 4757c11be54..a9aa0d23c64 100644 --- a/src/mame/funtech/supracan.cpp +++ b/src/mame/funtech/supracan.cpp @@ -2411,16 +2411,15 @@ void supracan_state::supracan(machine_config &config) GFXDECODE(config, m_gfxdecode, "palette", gfx_supracan); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: derive and verify from U13_CLOCK UMC6619_SOUND(config, m_sound, XTAL(3'579'545)); m_sound->ram_read().set(FUNC(supracan_state::sound_ram_read)); m_sound->timer_irq_handler().set(FUNC(supracan_state::sound_timer_irq)); m_sound->dma_irq_handler().set(FUNC(supracan_state::sound_dma_irq)); - m_sound->add_route(0, "lspeaker", 1.0); - m_sound->add_route(1, "rspeaker", 1.0); + m_sound->add_route(0, "speaker", 1.0, 0); + m_sound->add_route(1, "speaker", 1.0, 1); // TODO: clock for cart is (again) unconfirmed SUPERACAN_CART_SLOT(config, m_cart, U13_CLOCK / 6, superacan_cart_types, nullptr).set_must_be_loaded(true); diff --git a/src/mame/funtech/umc6619_sound.cpp b/src/mame/funtech/umc6619_sound.cpp index 4f8c19f3d51..426767489eb 100644 --- a/src/mame/funtech/umc6619_sound.cpp +++ b/src/mame/funtech/umc6619_sound.cpp @@ -132,9 +132,9 @@ std::string umc6619_sound_device::print_audio_state() return outbuffer.str(); } -void umc6619_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void umc6619_sound_device::sound_stream_update(sound_stream &stream) { - std::fill_n(&m_mix[0], outputs[0].samples() * 2, 0); + std::fill_n(&m_mix[0], stream.samples() * 2, 0); if (LIVE_AUDIO_VIEW) popmessage(print_audio_state()); @@ -146,7 +146,7 @@ void umc6619_sound_device::sound_stream_update(sound_stream &stream, std::vector acan_channel &channel = m_channels[i]; int32_t *mixp = &m_mix[0]; - for (int s = 0; s < outputs[0].samples(); s++) + for (int s = 0; s < stream.samples(); s++) { uint8_t data = m_ram_read(channel.curr_addr) + 0x80; int16_t sample = (int16_t)(data << 8); @@ -179,10 +179,10 @@ void umc6619_sound_device::sound_stream_update(sound_stream &stream, std::vector } int32_t *mixp = &m_mix[0]; - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - outputs[0].put_int(i, *mixp++, 32768 << 4); - outputs[1].put_int(i, *mixp++, 32768 << 4); + stream.put_int(0, i, *mixp++, 32768 << 4); + stream.put_int(1, i, *mixp++, 32768 << 4); } } diff --git a/src/mame/funtech/umc6619_sound.h b/src/mame/funtech/umc6619_sound.h index f897a469d97..b4e026bdc62 100644 --- a/src/mame/funtech/umc6619_sound.h +++ b/src/mame/funtech/umc6619_sound.h @@ -29,7 +29,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(channel_irq); diff --git a/src/mame/fuuki/fuukifg3.cpp b/src/mame/fuuki/fuukifg3.cpp index 176c6d06c6a..3a9e68fe3fd 100644 --- a/src/mame/fuuki/fuukifg3.cpp +++ b/src/mame/fuuki/fuukifg3.cpp @@ -652,17 +652,16 @@ void fuuki32_state::fuuki32(machine_config &config) m_fuukitmap->set_yoffs(0x3f6, 0x2c7); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymf278b_device &ymf(YMF278B(config, "ymf", 33.8688_MHz_XTAL)); ymf.irq_handler().set_inputline("soundcpu", 0); - ymf.add_route(0, "lspeaker", 0.50); - ymf.add_route(1, "rspeaker", 0.50); - ymf.add_route(2, "lspeaker", 0.40); - ymf.add_route(3, "rspeaker", 0.40); - ymf.add_route(4, "lspeaker", 0.50); - ymf.add_route(5, "rspeaker", 0.50); + ymf.add_route(0, "speaker", 0.50, 0); + ymf.add_route(1, "speaker", 0.50, 1); + ymf.add_route(2, "speaker", 0.40, 0); + ymf.add_route(3, "speaker", 0.40, 1); + ymf.add_route(4, "speaker", 0.50, 0); + ymf.add_route(5, "speaker", 0.50, 1); } //------------------------------------------------- diff --git a/src/mame/gaelco/gaelco2.cpp b/src/mame/gaelco/gaelco2.cpp index d41b3af3166..06fd46a43b3 100644 --- a/src/mame/gaelco/gaelco2.cpp +++ b/src/mame/gaelco/gaelco2.cpp @@ -200,14 +200,13 @@ void gaelco2_state::maniacsq(machine_config &config) MCFG_VIDEO_START_OVERRIDE(gaelco2_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(30'000'000) / 30)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0080000, 1 * 0x0080000, 0, 0); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } void gaelco2_state::maniacsq_d5002fp(machine_config &config) @@ -484,15 +483,14 @@ void gaelco2_state::saltcrdi(machine_config &config) MCFG_VIDEO_START_OVERRIDE(gaelco2_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // unused? ROMs contain no sound data gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(24'000'000) / 24)); // TODO : Correct OSC? gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0080000, 1 * 0x0080000, 0, 0); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } /*============================================================================ @@ -1038,14 +1036,13 @@ void gaelco2_state::play2000(machine_config &config) MCFG_VIDEO_START_OVERRIDE(gaelco2_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(34'000'000) / 34)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x080000, 0 * 0x080000, 0 * 0x080000, 0 * 0x080000); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } void gaelco2_state::srollnd(machine_config& config) @@ -1077,14 +1074,13 @@ void gaelco2_state::srollnd(machine_config& config) MCFG_VIDEO_START_OVERRIDE(gaelco2_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(34'000'000) / 34)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x080000, 0 * 0x080000, 0 * 0x080000, 0 * 0x080000); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } @@ -1180,14 +1176,13 @@ void bang_state::bang(machine_config &config) MCFG_VIDEO_START_OVERRIDE(bang_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_cg1v_device &gaelco(GAELCO_CG1V(config, "gaelco", XTAL(30'000'000) / 30)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0200000, 1 * 0x0200000, 2 * 0x0200000, 3 * 0x0200000); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } @@ -1425,14 +1420,13 @@ void gaelco2_state::alighunt(machine_config &config) MCFG_VIDEO_START_OVERRIDE(gaelco2_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(30'000'000) / 30)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0400000, 1 * 0x0400000, 2 * 0x0400000, 3 * 0x0400000); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } void gaelco2_state::alighunt_d5002fp(machine_config &config) @@ -1796,14 +1790,13 @@ void gaelco2_state::touchgo(machine_config &config) // sound hardware /* the chip is stereo, but the game sound is mono because the right channel output is for cabinet 1 and the left channel output is for cabinet 2 */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(40'000'000) / 40)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0400000, 1 * 0x0400000, 0, 0); - gaelco.add_route(0, "rspeaker", 1.0); - gaelco.add_route(1, "lspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 1); + gaelco.add_route(1, "speaker", 1.0, 0); } void gaelco2_state::touchgo_d5002fp(machine_config &config) @@ -2095,14 +2088,13 @@ void snowboar_state::snowboar(machine_config &config) MCFG_VIDEO_START_OVERRIDE(snowboar_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_cg1v_device &gaelco(GAELCO_CG1V(config, "gaelco", XTAL(34'000'000) / 34)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0400000, 1 * 0x0400000, 0, 0); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } void snowboar_state::maniacsqs(machine_config &config) @@ -2139,14 +2131,13 @@ void snowboar_state::maniacsqs(machine_config &config) MCFG_VIDEO_START_OVERRIDE(snowboar_state,gaelco2) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(30'000'000) / 30)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0080000, 1 * 0x0080000, 0, 0); - gaelco.add_route(0, "lspeaker", 1.0); - gaelco.add_route(1, "rspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 0); + gaelco.add_route(1, "speaker", 1.0, 1); } @@ -2440,14 +2431,13 @@ void wrally2_state::wrally2(machine_config &config) // sound hardware /* the chip is stereo, but the game sound is mono because the right channel output is for cabinet 1 and the left channel output is for cabinet 2 */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); gaelco_gae1_device &gaelco(GAELCO_GAE1(config, "gaelco", XTAL(34'000'000) / 34)); gaelco.set_device_rom_tag("gfx"); gaelco.set_bank_offsets(0 * 0x0200000, 1 * 0x0200000, 0, 0); - gaelco.add_route(0, "rspeaker", 1.0); - gaelco.add_route(1, "lspeaker", 1.0); + gaelco.add_route(0, "speaker", 1.0, 1); + gaelco.add_route(1, "speaker", 1.0, 0); } /* diff --git a/src/mame/gamepark/gp2x.cpp b/src/mame/gamepark/gp2x.cpp index 2fe2d0095f6..918a825e95d 100644 --- a/src/mame/gamepark/gp2x.cpp +++ b/src/mame/gamepark/gp2x.cpp @@ -377,8 +377,7 @@ void gp2x_state::gp2x(machine_config &config) screen.set_visarea(0, 319, 0, 239); screen.set_screen_update(FUNC(gp2x_state::screen_update_gp2x)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } } // anonymous namespace diff --git a/src/mame/gamepark/gp32.cpp b/src/mame/gamepark/gp32.cpp index 764d66610d5..07d2c780067 100644 --- a/src/mame/gamepark/gp32.cpp +++ b/src/mame/gamepark/gp32.cpp @@ -1696,10 +1696,9 @@ void gp32_state::gp32(machine_config &config) m_screen->set_visarea(0, 239, 0, 319); m_screen->set_screen_update(FUNC(gp32_state::screen_update_gp32)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // unknown DAC - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // unknown DAC + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // unknown DAC NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_1); diff --git a/src/mame/hp/hp16500.cpp b/src/mame/hp/hp16500.cpp index ad1a12c6ada..87474573778 100644 --- a/src/mame/hp/hp16500.cpp +++ b/src/mame/hp/hp16500.cpp @@ -436,8 +436,7 @@ void hp16500_state::hp1650(machine_config &config) SCN2661A(config, "epci", 5000000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void hp16500_state::hp1651(machine_config &config) @@ -459,8 +458,7 @@ void hp16500_state::hp1651(machine_config &config) SCN2661A(config, "epci", 5000000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void hp16500_state::hp16500a(machine_config &config) @@ -480,8 +478,7 @@ void hp16500_state::hp16500a(machine_config &config) crtc.set_update_row_callback(FUNC(hp16500_state::crtc_update_row)); crtc.out_vsync_callback().set(FUNC(hp16500_state::vsync_changed)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void hp16500_state::hp16500b(machine_config &config) @@ -509,8 +506,7 @@ void hp16500_state::hp16500b(machine_config &config) DS1286(config, "rtc", 32768); //WD37C65C(config, "fdc", 16_MHz_XTAL); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } static INPUT_PORTS_START( hp16500 ) diff --git a/src/mame/hp/hp80.cpp b/src/mame/hp/hp80.cpp index 73b33de1caf..36c675941e0 100644 --- a/src/mame/hp/hp80.cpp +++ b/src/mame/hp/hp80.cpp @@ -275,8 +275,8 @@ void hp80_base_state::hp80_base(machine_config &config) // Beeper SPEAKER(config, "mono").front_center(); - DAC_1BIT(config, m_dac , 0).add_route(ALL_OUTPUTS, "mono", 0.5, AUTO_ALLOC_INPUT, 0); - BEEP(config, m_beep, CPU_CLOCK / 512).add_route(ALL_OUTPUTS, "mono", 0.5, AUTO_ALLOC_INPUT, 0); + DAC_1BIT(config, m_dac , 0).add_route(ALL_OUTPUTS, "mono", 0.5, 0); + BEEP(config, m_beep, CPU_CLOCK / 512).add_route(ALL_OUTPUTS, "mono", 0.5, 0); // Optional ROMs for (auto& finder : m_rom_drawers) { diff --git a/src/mame/hp/hp_ipc.cpp b/src/mame/hp/hp_ipc.cpp index 2f7053d6ceb..517009db14b 100644 --- a/src/mame/hp/hp_ipc.cpp +++ b/src/mame/hp/hp_ipc.cpp @@ -797,7 +797,7 @@ void hp_ipc_state::hp_ipc_base(machine_config &config) // Beeper COP452(config , m_spkr , 2_MHz_XTAL); SPEAKER(config, "mono").front_center(); - DAC_1BIT(config, m_dac , 0).add_route(ALL_OUTPUTS, "mono", 0.5, AUTO_ALLOC_INPUT, 0); + DAC_1BIT(config, m_dac , 0).add_route(ALL_OUTPUTS, "mono", 0.5, 0); m_spkr->oa_w().set(m_dac , FUNC(dac_1bit_device::write)); // IO slots diff --git a/src/mame/hp/jornada.cpp b/src/mame/hp/jornada.cpp index 3e7b6486cb8..844ec57a639 100644 --- a/src/mame/hp/jornada.cpp +++ b/src/mame/hp/jornada.cpp @@ -624,11 +624,10 @@ void jornada_state::jornada720(machine_config &config) UDA1344(config, m_codec); m_codec->l3_ack_out().set(m_companion, FUNC(sa1111_device::l3wd_in)); - m_codec->add_route(0, "lspeaker", 0.5); - m_codec->add_route(1, "rspeaker", 0.5); + m_codec->add_route(0, "speaker", 0.5, 0); + m_codec->add_route(1, "speaker", 0.5, 1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SED1356(config, m_epson); m_epson->set_screen("screen"); diff --git a/src/mame/ibm/thinkpad8xx.cpp b/src/mame/ibm/thinkpad8xx.cpp index 2a290b4ba7b..bfbbc6a7020 100644 --- a/src/mame/ibm/thinkpad8xx.cpp +++ b/src/mame/ibm/thinkpad8xx.cpp @@ -79,8 +79,7 @@ void thinkpad8xx_state::thinkpad850(machine_config &config) H8325(config, "mcu", XTAL(10'000'000)); // Actually an H8/338 (HD6473388: 48k-byte ROM; 2k-byte RAM), unknown clock - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SOFTWARE_LIST(config, "thinkpad8xx").set_original("thinkpad8xx"); } diff --git a/src/mame/igs/pgm2.cpp b/src/mame/igs/pgm2.cpp index f7ef1c85c21..80e95719d93 100644 --- a/src/mame/igs/pgm2.cpp +++ b/src/mame/igs/pgm2.cpp @@ -776,12 +776,11 @@ void pgm2_state::pgm2(machine_config &config) NVRAM(config, "sram", nvram_device::DEFAULT_ALL_0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz774_device &ymz774(YMZ774(config, "ymz774", 16384000)); // is clock correct ? - ymz774.add_route(0, "lspeaker", 1.0); - ymz774.add_route(1, "rspeaker", 1.0); + ymz774.add_route(0, "speaker", 1.0, 0); + ymz774.add_route(1, "speaker", 1.0, 1); PGM2_MEMCARD(config, m_memcard[0], 0); PGM2_MEMCARD(config, m_memcard[1], 0); diff --git a/src/mame/interton/vc4000_a.cpp b/src/mame/interton/vc4000_a.cpp index 9004d256635..418ec6ee8c5 100644 --- a/src/mame/interton/vc4000_a.cpp +++ b/src/mame/interton/vc4000_a.cpp @@ -39,14 +39,11 @@ void vc4000_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void vc4000_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vc4000_sound_device::sound_stream_update(sound_stream &stream) { - int i; - auto &buffer = outputs[0]; - - for (i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - buffer.put(i, (m_reg[0] && m_pos <= m_size / 2) ? 1.0 : 0.0); + stream.put(0, i, (m_reg[0] && m_pos <= m_size / 2) ? 1.0 : 0.0); if (m_pos <= m_size) m_pos++; if (m_pos > m_size) diff --git a/src/mame/interton/vc4000_a.h b/src/mame/interton/vc4000_a.h index 5012f56e1ed..34138b2151d 100644 --- a/src/mame/interton/vc4000_a.h +++ b/src/mame/interton/vc4000_a.h @@ -28,7 +28,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: void soundport_w(int mode, int data); diff --git a/src/mame/irem/m107.cpp b/src/mame/irem/m107.cpp index 8245455858e..e035d2b7064 100644 --- a/src/mame/irem/m107.cpp +++ b/src/mame/irem/m107.cpp @@ -1227,8 +1227,7 @@ void m107_state::firebarr(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 2048); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set_inputline(m_soundcpu, NEC_INPUT_LINE_INTP1); @@ -1238,12 +1237,12 @@ void m107_state::firebarr(machine_config &config) ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181) / 4)); ymsnd.irq_handler().set_inputline(m_soundcpu, NEC_INPUT_LINE_INTP0); - ymsnd.add_route(0, "lspeaker", 0.40); - ymsnd.add_route(1, "rspeaker", 0.40); + ymsnd.add_route(0, "speaker", 0.40, 0); + ymsnd.add_route(1, "speaker", 0.40, 1); iremga20_device &ga20(IREMGA20(config, "irem", XTAL(14'318'181) / 4)); - ga20.add_route(0, "lspeaker", 1.0); - ga20.add_route(1, "rspeaker", 1.0); + ga20.add_route(0, "speaker", 1.0, 0); + ga20.add_route(1, "speaker", 1.0, 1); } void m107_state::dsoccr94(machine_config &config) diff --git a/src/mame/irem/m119.cpp b/src/mame/irem/m119.cpp index 79c55325bc2..75e0040751e 100644 --- a/src/mame/irem/m119.cpp +++ b/src/mame/irem/m119.cpp @@ -114,12 +114,11 @@ void m119_state::m119(machine_config &config) // TODO: UPD94244-210 VDP // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16'934'400)); // internal? - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/irem/m78.cpp b/src/mame/irem/m78.cpp index ce8581663f4..689d42c99ba 100644 --- a/src/mame/irem/m78.cpp +++ b/src/mame/irem/m78.cpp @@ -343,18 +343,17 @@ void m78_state::bj92(machine_config &config) RST_NEG_BUFFER(config, "soundirq").int_callback().set_inputline("audiocpu", 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); m72_audio_device &m72_audio(IREM_M72_AUDIO(config, "m72_audio")); m72_audio.set_dac_tag("dac"); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3.579545_MHz_XTAL )); // Verified on PCB ymsnd.irq_handler().set("soundirq", FUNC(rst_neg_buffer_device::rst28_w)); - ymsnd.add_route(0, "lspeaker", 0.5); - ymsnd.add_route(1, "rspeaker", 0.5); + ymsnd.add_route(0, "speaker", 0.5, 0); + ymsnd.add_route(1, "speaker", 0.5, 1); - DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC } diff --git a/src/mame/irem/m80.cpp b/src/mame/irem/m80.cpp index dc7a047fcce..149b91a69d5 100644 --- a/src/mame/irem/m80.cpp +++ b/src/mame/irem/m80.cpp @@ -390,8 +390,7 @@ void shisen_state::shisen(machine_config &config) PALETTE(config, m_palette).set_entries(256); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set("soundirq", FUNC(rst_neg_buffer_device::rst18_w)); @@ -404,10 +403,10 @@ void shisen_state::shisen(machine_config &config) ym2151_device &ymsnd(YM2151(config, "ymsnd", 3.579545_MHz_XTAL )); // Verified on PCB ymsnd.irq_handler().set("soundirq", FUNC(rst_neg_buffer_device::rst28_w)); - ymsnd.add_route(0, "lspeaker", 0.5); - ymsnd.add_route(1, "rspeaker", 0.5); + ymsnd.add_route(0, "speaker", 0.5, 0); + ymsnd.add_route(1, "speaker", 0.5, 1); - DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // Y3014B DAC + DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // Y3014B DAC } diff --git a/src/mame/irem/vigilant.cpp b/src/mame/irem/vigilant.cpp index 83909ececa2..b157e896ee6 100644 --- a/src/mame/irem/vigilant.cpp +++ b/src/mame/irem/vigilant.cpp @@ -1281,8 +1281,7 @@ void vigilant_state::vigilant(machine_config &config) PALETTE(config, m_palette).set_entries(512+32); // 512 real palette, 32 virtual palette // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set("soundirq", FUNC(rst_neg_buffer_device::rst18_w)); @@ -1295,12 +1294,12 @@ void vigilant_state::vigilant(machine_config &config) ym2151_device &ymsnd(YM2151(config, "ymsnd", 3.579545_MHz_XTAL)); ymsnd.irq_handler().set("soundirq", FUNC(rst_neg_buffer_device::rst28_w)); - ymsnd.add_route(0, "lspeaker", 0.28); - ymsnd.add_route(1, "rspeaker", 0.28); + ymsnd.add_route(0, "speaker", 0.28, 0); + ymsnd.add_route(1, "speaker", 0.28, 1); dac_8bit_r2r_device &dac(DAC_8BIT_R2R(config, "dac", 0)); // unknown DAC - dac.add_route(ALL_OUTPUTS, "lspeaker", 0.5); - dac.add_route(ALL_OUTPUTS, "rspeaker", 0.5); + dac.add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + dac.add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } void vigilant_state::buccanrs(machine_config &config) @@ -1329,8 +1328,7 @@ void vigilant_state::buccanrs(machine_config &config) PALETTE(config, m_palette).set_entries(512+32); // 512 real palette, 32 virtual palette // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set("soundirq", FUNC(rst_neg_buffer_device::rst18_w)); @@ -1343,28 +1341,28 @@ void vigilant_state::buccanrs(machine_config &config) ym2203_device &ym1(YM2203(config, "ym1", 18.432_MHz_XTAL / 6)); ym1.irq_handler().set("soundirq", FUNC(rst_neg_buffer_device::rst28_w)); - ym1.add_route(0, "lspeaker", 0.35); - ym1.add_route(0, "rspeaker", 0.35); - ym1.add_route(1, "lspeaker", 0.35); - ym1.add_route(1, "rspeaker", 0.35); - ym1.add_route(2, "lspeaker", 0.35); - ym1.add_route(2, "rspeaker", 0.35); - ym1.add_route(3, "lspeaker", 0.50); - ym1.add_route(3, "rspeaker", 0.50); + ym1.add_route(0, "speaker", 0.35, 0); + ym1.add_route(0, "speaker", 0.35, 1); + ym1.add_route(1, "speaker", 0.35, 0); + ym1.add_route(1, "speaker", 0.35, 1); + ym1.add_route(2, "speaker", 0.35, 0); + ym1.add_route(2, "speaker", 0.35, 1); + ym1.add_route(3, "speaker", 0.50, 0); + ym1.add_route(3, "speaker", 0.50, 1); ym2203_device &ym2(YM2203(config, "ym2", 18.432_MHz_XTAL / 6)); - ym2.add_route(0, "lspeaker", 0.35); - ym2.add_route(0, "rspeaker", 0.35); - ym2.add_route(1, "lspeaker", 0.35); - ym2.add_route(1, "rspeaker", 0.35); - ym2.add_route(2, "lspeaker", 0.35); - ym2.add_route(2, "rspeaker", 0.35); - ym2.add_route(3, "lspeaker", 0.50); - ym2.add_route(3, "rspeaker", 0.50); + ym2.add_route(0, "speaker", 0.35, 0); + ym2.add_route(0, "speaker", 0.35, 1); + ym2.add_route(1, "speaker", 0.35, 0); + ym2.add_route(1, "speaker", 0.35, 1); + ym2.add_route(2, "speaker", 0.35, 0); + ym2.add_route(2, "speaker", 0.35, 1); + ym2.add_route(3, "speaker", 0.50, 0); + ym2.add_route(3, "speaker", 0.50, 1); dac_8bit_r2r_device &dac(DAC_8BIT_R2R(config, "dac", 0)); // unknown DAC - dac.add_route(ALL_OUTPUTS, "lspeaker", 0.35); - dac.add_route(ALL_OUTPUTS, "rspeaker", 0.35); + dac.add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + dac.add_route(ALL_OUTPUTS, "speaker", 0.35, 1); } void captainx_state::captainx(machine_config &config) @@ -1406,8 +1404,7 @@ void vigilant_state::kikcubic(machine_config &config) PALETTE(config, m_palette).set_entries(256); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set("soundirq", FUNC(rst_neg_buffer_device::rst18_w)); @@ -1420,12 +1417,12 @@ void vigilant_state::kikcubic(machine_config &config) ym2151_device &ymsnd(YM2151(config, "ymsnd", 3.579545_MHz_XTAL)); ymsnd.irq_handler().set("soundirq", FUNC(rst_neg_buffer_device::rst28_w)); - ymsnd.add_route(0, "lspeaker", 0.28); - ymsnd.add_route(1, "rspeaker", 0.28); + ymsnd.add_route(0, "speaker", 0.28, 0); + ymsnd.add_route(1, "speaker", 0.28, 1); dac_8bit_r2r_device &dac(DAC_8BIT_R2R(config, "dac", 0)); // unknown DAC - dac.add_route(ALL_OUTPUTS, "lspeaker", 0.5); - dac.add_route(ALL_OUTPUTS, "rspeaker", 0.5); + dac.add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + dac.add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } @@ -1455,8 +1452,7 @@ void vigilant_state::bowmen(machine_config &config) PALETTE(config, m_palette).set_entries(512 + 32); // 512 real palette, 32 virtual palette // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set("soundirq", FUNC(rst_neg_buffer_device::rst18_w)); @@ -1469,28 +1465,28 @@ void vigilant_state::bowmen(machine_config &config) ym2203_device &ym1(YM2203(config, "ym1", 18_MHz_XTAL / 6)); ym1.irq_handler().set("soundirq", FUNC(rst_neg_buffer_device::rst28_w)); - ym1.add_route(0, "lspeaker", 0.35); - ym1.add_route(0, "rspeaker", 0.35); - ym1.add_route(1, "lspeaker", 0.35); - ym1.add_route(1, "rspeaker", 0.35); - ym1.add_route(2, "lspeaker", 0.35); - ym1.add_route(2, "rspeaker", 0.35); - ym1.add_route(3, "lspeaker", 0.50); - ym1.add_route(3, "rspeaker", 0.50); + ym1.add_route(0, "speaker", 0.35, 0); + ym1.add_route(0, "speaker", 0.35, 1); + ym1.add_route(1, "speaker", 0.35, 0); + ym1.add_route(1, "speaker", 0.35, 1); + ym1.add_route(2, "speaker", 0.35, 0); + ym1.add_route(2, "speaker", 0.35, 1); + ym1.add_route(3, "speaker", 0.50, 0); + ym1.add_route(3, "speaker", 0.50, 1); ym2203_device &ym2(YM2203(config, "ym2", 18_MHz_XTAL / 6)); - ym2.add_route(0, "lspeaker", 0.35); - ym2.add_route(0, "rspeaker", 0.35); - ym2.add_route(1, "lspeaker", 0.35); - ym2.add_route(1, "rspeaker", 0.35); - ym2.add_route(2, "lspeaker", 0.35); - ym2.add_route(2, "rspeaker", 0.35); - ym2.add_route(3, "lspeaker", 0.50); - ym2.add_route(3, "rspeaker", 0.50); + ym2.add_route(0, "speaker", 0.35, 0); + ym2.add_route(0, "speaker", 0.35, 1); + ym2.add_route(1, "speaker", 0.35, 0); + ym2.add_route(1, "speaker", 0.35, 1); + ym2.add_route(2, "speaker", 0.35, 0); + ym2.add_route(2, "speaker", 0.35, 1); + ym2.add_route(3, "speaker", 0.50, 0); + ym2.add_route(3, "speaker", 0.50, 1); dac_8bit_r2r_device &dac(DAC_8BIT_R2R(config, "dac", 0)); // unknown DAC - dac.add_route(ALL_OUTPUTS, "lspeaker", 0.35); - dac.add_route(ALL_OUTPUTS, "rspeaker", 0.35); + dac.add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + dac.add_route(ALL_OUTPUTS, "speaker", 0.35, 1); } diff --git a/src/mame/itech/iteagle.cpp b/src/mame/itech/iteagle.cpp index ad9723f58c3..bb8469cf702 100644 --- a/src/mame/itech/iteagle.cpp +++ b/src/mame/itech/iteagle.cpp @@ -195,7 +195,7 @@ void iteagle_state::iteagle(machine_config &config) m_fpga->guny_callback().set_ioport("GUNY1"); es1373_device &pci_sound(ES1373(config, PCI_ID_SOUND, 0)); - pci_sound.add_route(0, PCI_ID_SOUND":lspeaker", 1.0).add_route(1, PCI_ID_SOUND":rspeaker", 1.0); + pci_sound.add_route(0, PCI_ID_SOUND":speaker", 1.0, 0).add_route(1, PCI_ID_SOUND":speaker", 1.0, 1); pci_sound.irq_handler().set_inputline(m_maincpu, MIPS3_IRQ3); voodoo_3_pci_device &voodoo(VOODOO_3_PCI(config, PCI_ID_VIDEO, 0, m_maincpu, "screen")); diff --git a/src/mame/itech/itech32.cpp b/src/mame/itech/itech32.cpp index 7d63beab6e1..ceb01d738a1 100644 --- a/src/mame/itech/itech32.cpp +++ b/src/mame/itech/itech32.cpp @@ -1789,8 +1789,7 @@ void itech32_state::base_devices(machine_config &config) m_screen->set_palette(m_palette); m_screen->screen_vblank().set(FUNC(itech32_state::generate_int1)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ES5506(config, m_ensoniq, SOUND_CLOCK); m_ensoniq->set_region0("ensoniq.0"); @@ -1798,8 +1797,8 @@ void itech32_state::base_devices(machine_config &config) m_ensoniq->set_region2("ensoniq.2"); m_ensoniq->set_region3("ensoniq.3"); m_ensoniq->set_channels(1); // channels - m_ensoniq->add_route(0, "rspeaker", 0.1); // swapped stereo - m_ensoniq->add_route(1, "lspeaker", 0.1); + m_ensoniq->add_route(0, "speaker", 0.1, 1); // swapped stereo + m_ensoniq->add_route(1, "speaker", 0.1, 0); } void itech32_state::via(machine_config &config) diff --git a/src/mame/jaleco/acommand.cpp b/src/mame/jaleco/acommand.cpp index ec06efcb249..1c6648d4a90 100644 --- a/src/mame/jaleco/acommand.cpp +++ b/src/mame/jaleco/acommand.cpp @@ -509,16 +509,15 @@ void acommand_state::acommand(machine_config &config) MEGASYS1_TILEMAP(config, m_txtmap, m_palette, 0x2700); // assume amplified stereo - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki[0], 2112000, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); OKIM6295(config, m_oki[1], 2112000, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } /*************************************************************************** diff --git a/src/mame/jaleco/bestleag.cpp b/src/mame/jaleco/bestleag.cpp index c5dfa30f802..7be2d355891 100644 --- a/src/mame/jaleco/bestleag.cpp +++ b/src/mame/jaleco/bestleag.cpp @@ -388,12 +388,11 @@ void bestleag_state::bestleag(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_bestleag); PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 0x800); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, 1000000, okim6295_device::PIN7_HIGH); /* Hand-tuned */ - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 1.00); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 1.00); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.00, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.00, 1); } diff --git a/src/mame/jaleco/bigstrkb.cpp b/src/mame/jaleco/bigstrkb.cpp index d2ee33df87e..b45e3b03c30 100644 --- a/src/mame/jaleco/bigstrkb.cpp +++ b/src/mame/jaleco/bigstrkb.cpp @@ -396,17 +396,16 @@ void bigstrkb_state::bigstrkb(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 0x400); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // YM2151(config, "ymsnd", 4'000'000); okim6295_device &oki1(OKIM6295(config, "oki1", 4'000'000, okim6295_device::PIN7_HIGH)); - oki1.add_route(ALL_OUTPUTS, "lspeaker", 0.30); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 0.30); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.30, 1); okim6295_device &oki2(OKIM6295(config, "oki2", 4'000'000, okim6295_device::PIN7_HIGH)); - oki2.add_route(ALL_OUTPUTS, "lspeaker", 0.30); - oki2.add_route(ALL_OUTPUTS, "rspeaker", 0.30); + oki2.add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + oki2.add_route(ALL_OUTPUTS, "speaker", 0.30, 1); } // Rom Loading diff --git a/src/mame/jaleco/bnstars.cpp b/src/mame/jaleco/bnstars.cpp index 1f56327d649..60e9b1e6801 100644 --- a/src/mame/jaleco/bnstars.cpp +++ b/src/mame/jaleco/bnstars.cpp @@ -707,25 +707,24 @@ void ms32_bnstars_state::bnstars(machine_config &config) // m_sysctrl->set_invert_vblank_lines(true); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); YMF271(config, m_ymf[0], XTAL(16'934'400)); // 16.9344MHz - m_ymf[0]->add_route(0, "lspeaker", 1.0); - m_ymf[0]->add_route(1, "rspeaker", 1.0); + m_ymf[0]->add_route(0, "speaker", 1.0, 0); + m_ymf[0]->add_route(1, "speaker", 1.0, 1); // Output 2/3 not used? -// m_ymf[0]->add_route(2, "lspeaker", 1.0); -// m_ymf[0]->add_route(3, "rspeaker", 1.0); +// m_ymf[0]->add_route(2, "speaker", 1.0); +// m_ymf[0]->add_route(3, "speaker", 1.0); YMF271(config, m_ymf[1], XTAL(16'934'400)); // 16.9344MHz - m_ymf[1]->add_route(0, "lspeaker", 1.0); - m_ymf[1]->add_route(1, "rspeaker", 1.0); + m_ymf[1]->add_route(0, "speaker", 1.0, 0); + m_ymf[1]->add_route(1, "speaker", 1.0, 1); // Output 2/3 not used? -// m_ymf[1]->add_route(2, "lspeaker", 1.0); -// m_ymf[1]->add_route(3, "rspeaker", 1.0); +// m_ymf[1]->add_route(2, "speaker", 1.0); +// m_ymf[1]->add_route(3, "speaker", 1.0); } diff --git a/src/mame/jaleco/cischeat.cpp b/src/mame/jaleco/cischeat.cpp index 340dfcdfaad..b75de642569 100644 --- a/src/mame/jaleco/cischeat.cpp +++ b/src/mame/jaleco/cischeat.cpp @@ -2116,8 +2116,7 @@ void cischeat_state::bigrun(machine_config &config) MEGASYS1_TILEMAP(config, m_tmap[2], m_palette, 0x3600/2); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_16(config, m_soundlatch); GENERIC_LATCH_16(config, m_soundlatch2); @@ -2125,16 +2124,16 @@ void cischeat_state::bigrun(machine_config &config) // TODO: all sound frequencies unverified (assume same as Mega System 1) ym2151_device &ymsnd(YM2151(config, "ymsnd", 7000000/2)); ymsnd.irq_handler().set(FUNC(cischeat_state::sound_irq)); - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); OKIM6295(config, m_oki1, 4000000, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki1->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_oki1->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_oki1->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + m_oki1->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); OKIM6295(config, m_oki2, 4000000, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki2->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_oki2->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } void cischeat_state::bigrun_d65006(machine_config &config) @@ -2295,16 +2294,15 @@ void cischeat_state::scudhamm(machine_config &config) MEGASYS1_TILEMAP(config, m_tmap[2], m_palette, 0x4e00/2); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki1, 4000000/2, okim6295_device::PIN7_HIGH); // pin 7 not verified - m_oki1->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_oki1->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_oki1->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_oki1->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); OKIM6295(config, m_oki2, 4000000/2, okim6295_device::PIN7_HIGH); // pin 7 not verified - m_oki2->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_oki2->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } @@ -2399,18 +2397,17 @@ void captflag_state::captflag(machine_config &config) config.set_default_layout(layout_captflag); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki1, 4000000/2, okim6295_device::PIN7_HIGH); // pin 7 not verified m_oki1->set_addrmap(0, &captflag_state::oki1_map); - m_oki1->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_oki1->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_oki1->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_oki1->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); OKIM6295(config, m_oki2, 4000000/2, okim6295_device::PIN7_HIGH); // pin 7 not verified m_oki2->set_addrmap(0, &captflag_state::oki2_map); - m_oki2->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_oki2->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_oki2->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } diff --git a/src/mame/jaleco/jaleco_vj_pc.cpp b/src/mame/jaleco/jaleco_vj_pc.cpp index 234fce72cd5..48482772194 100644 --- a/src/mame/jaleco/jaleco_vj_pc.cpp +++ b/src/mame/jaleco/jaleco_vj_pc.cpp @@ -46,7 +46,7 @@ when actually playing the games because otherwise you'll be sending inputs to th jaleco_vj_pc_device::jaleco_vj_pc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, JALECO_VJ_PC, tag, owner, clock), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_maincpu(*this, "maincpu"), m_king_qtaro(*this, "pci:08.0"), m_sound(*this, "isa1:vj_sound"), @@ -95,8 +95,8 @@ void jaleco_vj_pc_device::sound_config(device_t &device) { jaleco_vj_isa16_sound_device &sound = downcast<jaleco_vj_isa16_sound_device &>(device); sound.set_steppingstage_mode(m_is_steppingstage); - sound.add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - sound.add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + sound.add_route(0, *this, 1.0, 0); + sound.add_route(1, *this, 1.0, 1); } void jaleco_vj_pc_device::boot_state_w(uint8_t data) diff --git a/src/mame/jaleco/jaleco_vj_sound.cpp b/src/mame/jaleco/jaleco_vj_sound.cpp index da22c550fb8..171ef907b7d 100644 --- a/src/mame/jaleco/jaleco_vj_sound.cpp +++ b/src/mame/jaleco/jaleco_vj_sound.cpp @@ -239,7 +239,7 @@ void jaleco_vj_isa16_sound_device::comm_w(offs_t offset, uint16_t data, uint16_t jaleco_vj_isa16_sound_device::jaleco_vj_isa16_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, JALECO_VJ_ISA16_SOUND, tag, owner, clock), device_isa16_card_interface(mconfig, *this), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_ymz(*this, "ymz%u", 1), m_ymzram(*this, "ymz_ram"), m_ymzram2(*this, "ymz_ram2"), @@ -260,12 +260,12 @@ void jaleco_vj_isa16_sound_device::device_add_mconfig(machine_config &config) // BGM normal YMZ280B(config, m_ymz[0], 16.9344_MHz_XTAL); m_ymz[0]->set_addrmap(0, &jaleco_vj_isa16_sound_device::ymz280b_map); - m_ymz[0]->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 0); + m_ymz[0]->add_route(1, *this, 1.0, 0); // BGM subwoofer YMZ280B(config, m_ymz[1], 16.9344_MHz_XTAL); m_ymz[1]->set_addrmap(0, &jaleco_vj_isa16_sound_device::ymz280b_map2); - m_ymz[1]->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_ymz[1]->add_route(1, *this, 1.0, 1); } void jaleco_vj_isa16_sound_device::device_start() diff --git a/src/mame/jaleco/megasys1.cpp b/src/mame/jaleco/megasys1.cpp index 057a0fc40ef..91d8ba85820 100644 --- a/src/mame/jaleco/megasys1.cpp +++ b/src/mame/jaleco/megasys1.cpp @@ -1917,24 +1917,23 @@ void megasys1_state::system_base(machine_config &config) m_tmap[2]->set_screen_tag(m_screen); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_16(config, m_soundlatch[0]); GENERIC_LATCH_16(config, m_soundlatch[1]); ym2151_device &ymsnd(YM2151(config, "ymsnd", SOUND_CPU_CLOCK/2)); /* 3.5MHz (7MHz / 2) verified */ ymsnd.irq_handler().set(FUNC(megasys1_state::sound_irq)); - ymsnd.add_route(0, "lspeaker", 0.80); - ymsnd.add_route(1, "rspeaker", 0.80); + ymsnd.add_route(0, "speaker", 0.80, 0); + ymsnd.add_route(1, "speaker", 0.80, 1); OKIM6295(config, m_oki[0], OKI4_SOUND_CLOCK, okim6295_device::PIN7_HIGH); /* 4MHz verified */ - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.30); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); OKIM6295(config, m_oki[1], OKI4_SOUND_CLOCK, okim6295_device::PIN7_HIGH); /* 4MHz verified */ - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.30); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); } void megasys1_typea_state::system_A(machine_config &config) @@ -2002,8 +2001,8 @@ void megasys1_typea_state::system_A_kickoffb(machine_config &config) ym2203_device &ymsnd(YM2203(config.replace(), "ymsnd", SOUND_CPU_CLOCK / 2)); ymsnd.irq_handler().set(FUNC(megasys1_typea_state::sound_irq)); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.80); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.80); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } void megasys1_typea_state::system_A_p47bl(machine_config &config) @@ -2027,13 +2026,13 @@ void megasys1_typea_state::system_A_p47bl(machine_config &config) // OKI M5205 MSM5205(config, m_p47bl_adpcm[0], 384000); m_p47bl_adpcm[0]->set_prescaler_selector(msm5205_device::SEX_4B); - m_p47bl_adpcm[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_p47bl_adpcm[0]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_p47bl_adpcm[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_p47bl_adpcm[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); MSM5205(config, m_p47bl_adpcm[1], 384000); m_p47bl_adpcm[1]->set_prescaler_selector(msm5205_device::SEX_4B); - m_p47bl_adpcm[1]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_p47bl_adpcm[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_p47bl_adpcm[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_p47bl_adpcm[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void megasys1_state::system_B(machine_config &config) @@ -2115,13 +2114,12 @@ void megasys1_state::system_Bbl(machine_config &config) m_tmap[2]->set_screen_tag(m_screen); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* just the one OKI, used for sound and music */ OKIM6295(config, m_oki[0], OKI4_SOUND_CLOCK, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.30); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); } void megasys1_bc_iosim_state::system_B_hayaosi1(machine_config &config) @@ -2131,12 +2129,12 @@ void megasys1_bc_iosim_state::system_B_hayaosi1(machine_config &config) /* basic machine hardware */ OKIM6295(config.replace(), m_oki[0], 2000000, okim6295_device::PIN7_HIGH); /* correct speed, but unknown OSC + divider combo */ - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.30); - m_oki[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); OKIM6295(config.replace(), m_oki[1], 2000000, okim6295_device::PIN7_HIGH); /* correct speed, but unknown OSC + divider combo */ - m_oki[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.30); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.30); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.30, 0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.30, 1); } void megasys1_state::system_C(machine_config &config) diff --git a/src/mame/jaleco/ms32.cpp b/src/mame/jaleco/ms32.cpp index c6d91b712c8..30d8452cb2f 100644 --- a/src/mame/jaleco/ms32.cpp +++ b/src/mame/jaleco/ms32.cpp @@ -1749,18 +1749,17 @@ void ms32_state::ms32(machine_config &config) m_sprite->set_color_entries(16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); YMF271(config, m_ymf, XTAL(16'934'400)); // 16.9344MHz - m_ymf->add_route(0, "lspeaker", 1.0); - m_ymf->add_route(1, "rspeaker", 1.0); + m_ymf->add_route(0, "speaker", 1.0, 0); + m_ymf->add_route(1, "speaker", 1.0, 1); // Output 2/3 not used? -// m_ymf->add_route(2, "lspeaker", 1.0); -// m_ymf->add_route(3, "rspeaker", 1.0); +// m_ymf->add_route(2, "speaker", 1.0); +// m_ymf->add_route(3, "speaker", 1.0); } void ms32_state::ms32_invert_lines(machine_config &config) diff --git a/src/mame/jaleco/tetrisp2.cpp b/src/mame/jaleco/tetrisp2.cpp index 5c47ea3a236..896601620c4 100644 --- a/src/mame/jaleco/tetrisp2.cpp +++ b/src/mame/jaleco/tetrisp2.cpp @@ -1819,12 +1819,11 @@ void tetrisp2_state::tetrisp2(machine_config &config) setup_main_sysctrl(config, XTAL(48'000'000)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); // 16.9344MHz - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } @@ -1886,13 +1885,12 @@ void rockn_state::rockn(machine_config &config) setup_main_sysctrl(config, XTAL(48'000'000)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); // 16.9344MHz ymz.set_addrmap(0, &rockn_state::rockn1_ymz_map); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } @@ -1920,13 +1918,12 @@ void rockn_state::rockn2(machine_config &config) setup_main_sysctrl(config, XTAL(48'000'000)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); // 16.9344MHz ymz.set_addrmap(0, &rockn_state::rockn2_ymz_map); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } void rocknms_state::sub_field_irq_w(int state) @@ -2001,13 +1998,12 @@ void rocknms_state::rocknms(machine_config &config) m_sub_sysctrl->sound_reset_cb().set(FUNC(rocknms_state::sub_sound_reset_line_w)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); // 16.9344MHz ymz.set_addrmap(0, &rocknms_state::rockn1_ymz_map); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } void stepstag_state::field_cb(int state) @@ -2114,15 +2110,14 @@ void stepstag_state::stepstag(machine_config &config) config.set_default_layout(layout_stepstag); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_16(config, m_soundlatch); JALECO_VJ_PC(config, m_jaleco_vj_pc, 0); m_jaleco_vj_pc->set_steppingstage_mode(true); - m_jaleco_vj_pc->add_route(0, "lspeaker", 1.0); - m_jaleco_vj_pc->add_route(1, "rspeaker", 1.0); + m_jaleco_vj_pc->add_route(0, "speaker", 1.0, 0); + m_jaleco_vj_pc->add_route(1, "speaker", 1.0, 1); } void stepstag_state::vjdash(machine_config &config) // 4 Screens @@ -2202,15 +2197,14 @@ void stepstag_state::vjdash(machine_config &config) // 4 Screens config.set_default_layout(layout_vjdash); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_16(config, m_soundlatch); JALECO_VJ_PC(config, m_jaleco_vj_pc, 0); m_jaleco_vj_pc->set_steppingstage_mode(false); - m_jaleco_vj_pc->add_route(0, "lspeaker", 1.0); - m_jaleco_vj_pc->add_route(1, "rspeaker", 1.0); + m_jaleco_vj_pc->add_route(0, "speaker", 1.0, 0); + m_jaleco_vj_pc->add_route(1, "speaker", 1.0, 1); } void stepstag_state::machine_start() diff --git a/src/mame/jpm/jpmsys7.cpp b/src/mame/jpm/jpmsys7.cpp index dd04774c81d..bf9707ff323 100644 --- a/src/mame/jpm/jpmsys7.cpp +++ b/src/mame/jpm/jpmsys7.cpp @@ -64,8 +64,7 @@ void jpmsys7_state::jpmsys7(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &jpmsys7_state::jpmsys7_map); MCF5206E_PERIPHERAL(config, "maincpu_onboard", 0, m_maincpu); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* unknown sound (probably DMA driven DAC) */ } diff --git a/src/mame/jpm/pluto5.cpp b/src/mame/jpm/pluto5.cpp index 5895840d254..7087e948d80 100644 --- a/src/mame/jpm/pluto5.cpp +++ b/src/mame/jpm/pluto5.cpp @@ -272,8 +272,7 @@ void pluto5_state::pluto5(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &pluto5_state::pluto5_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // unknown sound } diff --git a/src/mame/jpm/pluto6.cpp b/src/mame/jpm/pluto6.cpp index f2c00addb74..cf1f01cd54c 100644 --- a/src/mame/jpm/pluto6.cpp +++ b/src/mame/jpm/pluto6.cpp @@ -79,8 +79,7 @@ void pluto6_state::pluto6(machine_config &config) MCF5206E_PERIPHERAL(config, "maincpu_onboard", 0, m_maincpu); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/kaneko/djboy.cpp b/src/mame/kaneko/djboy.cpp index bf7dcedc52f..734d6c6472a 100644 --- a/src/mame/kaneko/djboy.cpp +++ b/src/mame/kaneko/djboy.cpp @@ -689,24 +689,23 @@ void djboy_state::djboy(machine_config &config) KANEKO_PANDORA(config, m_pandora, 0, m_palette, gfx_djboy_spr); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_soundcpu, INPUT_LINE_NMI); ym2203_device &ymsnd(YM2203(config, "ymsnd", 12_MHz_XTAL / 4)); // 3.000MHz, verified ymsnd.irq_handler().set_inputline(m_soundcpu, INPUT_LINE_IRQ0); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.40); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.40); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.40, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.40, 1); okim6295_device &oki_l(OKIM6295(config, "oki_l", 12_MHz_XTAL / 8, okim6295_device::PIN7_LOW)); // 1.500MHz, verified oki_l.set_device_rom_tag("oki"); - oki_l.add_route(ALL_OUTPUTS, "lspeaker", 0.50); + oki_l.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); okim6295_device &oki_r(OKIM6295(config, "oki_r", 12_MHz_XTAL / 8, okim6295_device::PIN7_LOW)); // 1.500MHz, verified oki_r.set_device_rom_tag("oki"); - oki_r.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki_r.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } diff --git a/src/mame/kaneko/galpani2.cpp b/src/mame/kaneko/galpani2.cpp index 7359370c020..0f2bd10eca8 100644 --- a/src/mame/kaneko/galpani2.cpp +++ b/src/mame/kaneko/galpani2.cpp @@ -669,12 +669,11 @@ void galpani2_state::galpani2(machine_config &config) m_kaneko_spr->set_color_base(0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - OKIM6295(config, "oki1", XTAL(20'000'000)/10, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "lspeaker", 1.0); /* Confirmed on galpani2i PCB */ + OKIM6295(config, "oki1", XTAL(20'000'000)/10, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); /* Confirmed on galpani2i PCB */ - OKIM6295(config, m_oki2, XTAL(20'000'000)/10, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "rspeaker", 1.0); /* Confirmed on galpani2i PCB */ + OKIM6295(config, m_oki2, XTAL(20'000'000)/10, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); /* Confirmed on galpani2i PCB */ } diff --git a/src/mame/kaneko/jchan.cpp b/src/mame/kaneko/jchan.cpp index f663c29314e..8a21934ffe2 100644 --- a/src/mame/kaneko/jchan.cpp +++ b/src/mame/kaneko/jchan.cpp @@ -618,12 +618,11 @@ void jchan_state::jchan(machine_config &config) EEPROM_93C46_16BIT(config, "eeprom"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16000000)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } /* ROM loading */ diff --git a/src/mame/kaneko/kaneko16.cpp b/src/mame/kaneko/kaneko16.cpp index 2b30c396dab..cf295592542 100644 --- a/src/mame/kaneko/kaneko16.cpp +++ b/src/mame/kaneko/kaneko16.cpp @@ -1857,15 +1857,14 @@ void kaneko16_blazeon_state::blazeon(machine_config &config) // there is actually a 2nd sprite chip! looks like our device emulation handles both at once /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); YM2151(config, m_ymsnd, 4000000); - m_ymsnd->add_route(0, "lspeaker", 1.0); - m_ymsnd->add_route(1, "rspeaker", 1.0); + m_ymsnd->add_route(0, "speaker", 1.0, 0); + m_ymsnd->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/kaneko/suprnova.cpp b/src/mame/kaneko/suprnova.cpp index dfbc068bae2..113540986c3 100644 --- a/src/mame/kaneko/suprnova.cpp +++ b/src/mame/kaneko/suprnova.cpp @@ -797,12 +797,11 @@ void skns_state::skns(machine_config &config) SKNS_SPRITE(config, m_spritegen, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(33'333'333) / 2)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } MACHINE_RESET_MEMBER(skns_state,sknsa) diff --git a/src/mame/konami/ajax.cpp b/src/mame/konami/ajax.cpp index aefcaaa7590..5ab9f99ffcd 100644 --- a/src/mame/konami/ajax.cpp +++ b/src/mame/konami/ajax.cpp @@ -592,24 +592,23 @@ void ajax_state::ajax(machine_config &config) m_k051316->set_zoom_callback(FUNC(ajax_state::zoom_callback)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); - YM2151(config, "ymsnd", 3579545).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", 3579545).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); K007232(config, m_k007232[0], 3579545); m_k007232[0]->port_write().set(FUNC(ajax_state::volume_callback0)); - m_k007232[0]->add_route(0, "lspeaker", 0.20); - m_k007232[0]->add_route(0, "rspeaker", 0.20); - m_k007232[0]->add_route(1, "lspeaker", 0.20); - m_k007232[0]->add_route(1, "rspeaker", 0.20); + m_k007232[0]->add_route(0, "speaker", 0.20, 0); + m_k007232[0]->add_route(0, "speaker", 0.20, 1); + m_k007232[0]->add_route(1, "speaker", 0.20, 0); + m_k007232[0]->add_route(1, "speaker", 0.20, 1); K007232(config, m_k007232[1], 3579545); m_k007232[1]->port_write().set(FUNC(ajax_state::volume_callback1)); - m_k007232[1]->add_route(0, "lspeaker", 0.50); - m_k007232[1]->add_route(1, "rspeaker", 0.50); + m_k007232[1]->add_route(0, "speaker", 0.50, 0); + m_k007232[1]->add_route(1, "speaker", 0.50, 1); } diff --git a/src/mame/konami/asterix.cpp b/src/mame/konami/asterix.cpp index 6fc09dec553..6ce294f6f4d 100644 --- a/src/mame/konami/asterix.cpp +++ b/src/mame/konami/asterix.cpp @@ -417,14 +417,13 @@ void asterix_state::asterix(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(32'000'000)/8).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); // 4MHz + YM2151(config, "ymsnd", XTAL(32'000'000)/8).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); // 4MHz k053260_device &k053260(K053260(config, "k053260", XTAL(32'000'000)/8)); // 4MHz - k053260.add_route(0, "lspeaker", 0.75); - k053260.add_route(1, "rspeaker", 0.75); + k053260.add_route(0, "speaker", 0.75, 0); + k053260.add_route(1, "speaker", 0.75, 1); k053260.sh1_cb().set(FUNC(asterix_state::z80_nmi_w)); } diff --git a/src/mame/konami/bishi.cpp b/src/mame/konami/bishi.cpp index 9f19aac2fe1..088ad995072 100644 --- a/src/mame/konami/bishi.cpp +++ b/src/mame/konami/bishi.cpp @@ -523,13 +523,12 @@ void bishi_state::bishi(machine_config &config) K055555(config, m_k055555, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", SOUND_CLOCK)); /* 16.9344MHz */ ymz.irq_handler().set_inputline("maincpu", M68K_IRQ_1); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } // ROM definitions diff --git a/src/mame/konami/chqflag.cpp b/src/mame/konami/chqflag.cpp index 6bec9b16311..a1a154b9ad0 100644 --- a/src/mame/konami/chqflag.cpp +++ b/src/mame/konami/chqflag.cpp @@ -477,28 +477,27 @@ void chqflag_state::chqflag(machine_config &config) K051733(config, "k051733", 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); GENERIC_LATCH_8(config, "soundlatch2").data_pending_callback().set_inputline(m_audiocpu, 0); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); /* verified on pcb */ ymsnd.irq_handler().set_inputline(m_audiocpu, INPUT_LINE_NMI); - ymsnd.add_route(0, "lspeaker", 1.00); - ymsnd.add_route(1, "rspeaker", 1.00); + ymsnd.add_route(0, "speaker", 1.00, 0); + ymsnd.add_route(1, "speaker", 1.00, 1); K007232(config, m_k007232[0], XTAL(3'579'545)); /* verified on pcb */ m_k007232[0]->port_write().set(FUNC(chqflag_state::volume_callback0)); - m_k007232[0]->add_route(0, "lspeaker", 0.20); - m_k007232[0]->add_route(1, "rspeaker", 0.20); + m_k007232[0]->add_route(0, "speaker", 0.20, 0); + m_k007232[0]->add_route(1, "speaker", 0.20, 1); K007232(config, m_k007232[1], XTAL(3'579'545)); /* verified on pcb */ m_k007232[1]->port_write().set(FUNC(chqflag_state::volume_callback1)); - m_k007232[1]->add_route(0, "lspeaker", 0.20); - m_k007232[1]->add_route(0, "rspeaker", 0.20); - m_k007232[1]->add_route(1, "lspeaker", 0.20); - m_k007232[1]->add_route(1, "rspeaker", 0.20); + m_k007232[1]->add_route(0, "speaker", 0.20, 0); + m_k007232[1]->add_route(0, "speaker", 0.20, 1); + m_k007232[1]->add_route(1, "speaker", 0.20, 0); + m_k007232[1]->add_route(1, "speaker", 0.20, 1); } ROM_START( chqflag ) diff --git a/src/mame/konami/cobra.cpp b/src/mame/konami/cobra.cpp index a440873d415..aa278bb71ec 100644 --- a/src/mame/konami/cobra.cpp +++ b/src/mame/konami/cobra.cpp @@ -2978,17 +2978,16 @@ void cobra_state::cobra(machine_config &config) m_screen->set_screen_update(FUNC(cobra_state::screen_update_cobra)); PALETTE(config, m_palette).set_entries(65536); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); rf5c400_device &rfsnd(RF5C400(config, "rfsnd", XTAL(16'934'400))); rfsnd.set_addrmap(0, &cobra_state::rf5c400_map); - rfsnd.add_route(0, "lspeaker", 1.0); - rfsnd.add_route(1, "rspeaker", 1.0); + rfsnd.add_route(0, "speaker", 1.0, 0); + rfsnd.add_route(1, "speaker", 1.0, 1); - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "lspeaker", 1.0); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); M48T58(config, "m48t58", 0); diff --git a/src/mame/konami/contra.cpp b/src/mame/konami/contra.cpp index 9ca3ad4ebee..8c97abd57de 100644 --- a/src/mame/konami/contra.cpp +++ b/src/mame/konami/contra.cpp @@ -626,12 +626,11 @@ void contra_state::contra(machine_config &config) K007121(config, m_k007121[1], 0, m_palette, gfx_contra_2); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 0.60).add_route(1, "rspeaker", 0.60); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 0.60, 0).add_route(1, "speaker", 0.60, 1); } diff --git a/src/mame/konami/cougar.cpp b/src/mame/konami/cougar.cpp index 3841c8f6abf..ca11002f89c 100644 --- a/src/mame/konami/cougar.cpp +++ b/src/mame/konami/cougar.cpp @@ -75,12 +75,11 @@ void cougar_state::cougar(machine_config &config) //SCREEN(config, "screen", SCREEN_TYPE_RASTER); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16.9344_MHz_XTAL)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } /*************************************************************************** diff --git a/src/mame/konami/crimfght.cpp b/src/mame/konami/crimfght.cpp index 8d7acd02d4b..b0d335efd76 100644 --- a/src/mame/konami/crimfght.cpp +++ b/src/mame/konami/crimfght.cpp @@ -465,22 +465,21 @@ void crimfght_state::crimfght(machine_config &config) m_k051960->irq_handler().set_inputline(m_maincpu, KONAMI_IRQ_LINE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); // verified on pcb ymsnd.port_write_handler().set(FUNC(crimfght_state::ym2151_ct_w)); - ymsnd.add_route(0, "lspeaker", 1.0); - ymsnd.add_route(1, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 1.0, 0); + ymsnd.add_route(1, "speaker", 1.0, 1); K007232(config, m_k007232, XTAL(3'579'545)); // verified on pcb m_k007232->port_write().set(FUNC(crimfght_state::volume_callback)); - m_k007232->add_route(0, "lspeaker", 0.20); - m_k007232->add_route(0, "rspeaker", 0.20); - m_k007232->add_route(1, "lspeaker", 0.20); - m_k007232->add_route(1, "rspeaker", 0.20); + m_k007232->add_route(0, "speaker", 0.20, 0); + m_k007232->add_route(0, "speaker", 0.20, 1); + m_k007232->add_route(1, "speaker", 0.20, 0); + m_k007232->add_route(1, "speaker", 0.20, 1); } /*************************************************************************** diff --git a/src/mame/konami/dbz.cpp b/src/mame/konami/dbz.cpp index d349bb6d9aa..777d2f2ee04 100644 --- a/src/mame/konami/dbz.cpp +++ b/src/mame/konami/dbz.cpp @@ -600,19 +600,18 @@ void dbz_state::dbz(machine_config &config) m_k053252->int1_ack().set(FUNC(dbz_state::dbz_irq2_ack_w)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); ym2151_device &ymsnd(YM2151(config, "ymsnd", 4000000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 1.0); - ymsnd.add_route(1, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 1.0, 0); + ymsnd.add_route(1, "speaker", 1.0, 1); okim6295_device &oki(OKIM6295(config, "oki", 1056000, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void dbz_state::dbz2bl(machine_config &config) diff --git a/src/mame/konami/djmain.cpp b/src/mame/konami/djmain.cpp index 0bffa60dce7..af740e3bc99 100644 --- a/src/mame/konami/djmain.cpp +++ b/src/mame/konami/djmain.cpp @@ -1700,18 +1700,17 @@ void djmain_state::djmainj(machine_config &config) K055555(config, m_k055555, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); k054539_device &k054539_1(K054539(config, "k054539_1", XTAL(18'432'000))); k054539_1.set_addrmap(0, &djmain_state::k054539_map); - k054539_1.add_route(0, "lspeaker", 1.0); - k054539_1.add_route(1, "rspeaker", 1.0); + k054539_1.add_route(0, "speaker", 1.0, 0); + k054539_1.add_route(1, "speaker", 1.0, 1); k054539_device &k054539_2(K054539(config, "k054539_2", XTAL(18'432'000))); k054539_2.set_addrmap(0, &djmain_state::k054539_map); - k054539_2.add_route(0, "lspeaker", 1.0); - k054539_2.add_route(1, "rspeaker", 1.0); + k054539_2.add_route(0, "speaker", 1.0, 0); + k054539_2.add_route(1, "speaker", 1.0, 1); } void djmain_state::djmainu(machine_config &config) diff --git a/src/mame/konami/firebeat.cpp b/src/mame/konami/firebeat.cpp index 3930b129640..1d73afb5f59 100644 --- a/src/mame/konami/firebeat.cpp +++ b/src/mame/konami/firebeat.cpp @@ -196,7 +196,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface-level overrides - void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: enum { @@ -220,7 +220,7 @@ private: firebeat_extend_spectrum_analyzer_device::firebeat_extend_spectrum_analyzer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, KONAMI_FIREBEAT_EXTEND_SPECTRUM_ANALYZER, tag, owner, clock), - device_mixer_interface(mconfig, *this, 2) + device_mixer_interface(mconfig, *this) { } @@ -245,15 +245,15 @@ void firebeat_extend_spectrum_analyzer_device::device_reset() m_audio_fill_index = 0; } -void firebeat_extend_spectrum_analyzer_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void firebeat_extend_spectrum_analyzer_device::sound_stream_update(sound_stream &stream) { - device_mixer_interface::sound_stream_update(stream, inputs, outputs); + device_mixer_interface::sound_stream_update(stream); - for (int pos = 0; pos < outputs[0].samples(); pos++) + for (int pos = 0; pos < stream.samples(); pos++) { - for (int ch = 0; ch < outputs.size(); ch++) + for (int ch = 0; ch < stream.output_count(); ch++) { - const float sample = outputs[ch].get(pos); + const float sample = stream.get(ch, pos); m_audio_buf[m_audio_fill_index][ch][m_audio_count[m_audio_fill_index]] = sample; } @@ -389,8 +389,8 @@ static void firebeat_ata_devices(device_slot_interface &device) static void cdrom_config(device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 0.5); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 0.5); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 0.5, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 0.5, 1); } static void dvdrom_config(device_t *device) @@ -762,14 +762,13 @@ void firebeat_state::firebeat(machine_config &config) m_gcu->irq_callback().set(FUNC(firebeat_state::gcu_interrupt)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16934400)); ymz.irq_handler().set(FUNC(firebeat_state::sound_irq_callback)); ymz.set_addrmap(0, &firebeat_state::ymz280b_map); - ymz.add_route(1, "lspeaker", 1.0); - ymz.add_route(0, "rspeaker", 1.0); + ymz.add_route(1, "speaker", 1.0, 0); + ymz.add_route(0, "speaker", 1.0, 1); PC16552D(config, "duart_com", 0); NS16550(config, "duart_com:chan0", XTAL(19'660'800)); @@ -1213,8 +1212,8 @@ void firebeat_spu_state::firebeat_spu_base(machine_config &config) m_rf5c400->set_addrmap(0, &firebeat_spu_state::rf5c400_map); // Clean channel audio - m_rf5c400->add_route(0, "lspeaker", 0.5); - m_rf5c400->add_route(1, "rspeaker", 0.5); + m_rf5c400->add_route(0, "speaker", 0.5, 0); + m_rf5c400->add_route(1, "speaker", 0.5, 1); } void firebeat_spu_state::firebeat_spu_map(address_map &map) @@ -1452,14 +1451,14 @@ void firebeat_bm3_state::firebeat_bm3(machine_config &config) NS16550(config, "duart_midi:chan1", XTAL(24'000'000)).out_int_callback().set(FUNC(firebeat_bm3_state::midi_st224_irq_callback)); // Effects audio channel, routed to ST-224's audio input - m_rf5c400->add_route(2, "lspeaker", 0.5); - m_rf5c400->add_route(3, "rspeaker", 0.5); + m_rf5c400->add_route(2, "speaker", 0.5, 0); + m_rf5c400->add_route(3, "speaker", 0.5, 1); KONAMI_FIREBEAT_EXTEND_SPECTRUM_ANALYZER(config, m_spectrum_analyzer, 0); - m_rf5c400->add_route(0, m_spectrum_analyzer, 0.5, AUTO_ALLOC_INPUT, 0); - m_rf5c400->add_route(1, m_spectrum_analyzer, 0.5, AUTO_ALLOC_INPUT, 1); - m_rf5c400->add_route(2, m_spectrum_analyzer, 0.5, AUTO_ALLOC_INPUT, 0); - m_rf5c400->add_route(3, m_spectrum_analyzer, 0.5, AUTO_ALLOC_INPUT, 1); + m_rf5c400->add_route(0, m_spectrum_analyzer, 0.5, 0); + m_rf5c400->add_route(1, m_spectrum_analyzer, 0.5, 1); + m_rf5c400->add_route(2, m_spectrum_analyzer, 0.5, 0); + m_rf5c400->add_route(3, m_spectrum_analyzer, 0.5, 1); } void firebeat_bm3_state::init_bm3() @@ -1548,8 +1547,8 @@ void firebeat_popn_state::firebeat_popn(machine_config &config) TIMER(config, "spu_timer").configure_periodic(FUNC(firebeat_popn_state::spu_timer_callback), attotime::from_hz(500)); // Effects audio channel, routed back to main (no external processing) - m_rf5c400->add_route(2, "lspeaker", 0.5); - m_rf5c400->add_route(3, "rspeaker", 0.5); + m_rf5c400->add_route(2, "speaker", 0.5, 0); + m_rf5c400->add_route(3, "speaker", 0.5, 1); } void firebeat_popn_state::init_popn_base() @@ -1817,14 +1816,13 @@ void firebeat_kbm_state::firebeat_kbm(machine_config &config) m_gcu_sub->irq_callback().set(FUNC(firebeat_kbm_state::gcu_interrupt)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16934400)); ymz.irq_handler().set(FUNC(firebeat_kbm_state::sound_irq_callback)); ymz.set_addrmap(0, &firebeat_kbm_state::ymz280b_map); - ymz.add_route(1, "lspeaker", 1.0); - ymz.add_route(0, "rspeaker", 1.0); + ymz.add_route(1, "speaker", 1.0, 0); + ymz.add_route(0, "speaker", 1.0, 1); // On the main PCB PC16552D(config, "duart_com", 0); @@ -1844,8 +1842,8 @@ void firebeat_kbm_state::firebeat_kbm(machine_config &config) // Synth card auto &xt446(XT446(config, "xt446")); midi_chan1.out_tx_callback().set(xt446, FUNC(xt446_device::midi_w)); - xt446.add_route(0, "lspeaker", 1.0); - xt446.add_route(1, "rspeaker", 1.0); + xt446.add_route(0, "speaker", 1.0, 0); + xt446.add_route(1, "speaker", 1.0, 1); } void firebeat_kbm_state::firebeat_kbm_map(address_map &map) diff --git a/src/mame/konami/flkatck.cpp b/src/mame/konami/flkatck.cpp index 7e178728681..8b4b33b408a 100644 --- a/src/mame/konami/flkatck.cpp +++ b/src/mame/konami/flkatck.cpp @@ -437,19 +437,18 @@ void flkatck_state::flkatck(machine_config &config) K007121(config, m_k007121, 0, "palette", gfx_flkatck); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 1.0).add_route(0, "rspeaker", 1.0); + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 1.0, 0).add_route(0, "speaker", 1.0, 1); K007232(config, m_k007232, 3.579545_MHz_XTAL); m_k007232->port_write().set(FUNC(flkatck_state::volume_callback)); - m_k007232->add_route(0, "lspeaker", 0.50); - m_k007232->add_route(0, "rspeaker", 0.50); - m_k007232->add_route(1, "lspeaker", 0.50); - m_k007232->add_route(1, "rspeaker", 0.50); + m_k007232->add_route(0, "speaker", 0.50, 0); + m_k007232->add_route(0, "speaker", 0.50, 1); + m_k007232->add_route(1, "speaker", 0.50, 0); + m_k007232->add_route(1, "speaker", 0.50, 1); } diff --git a/src/mame/konami/gijoe.cpp b/src/mame/konami/gijoe.cpp index d0ce2c62963..df8f67a4f91 100644 --- a/src/mame/konami/gijoe.cpp +++ b/src/mame/konami/gijoe.cpp @@ -542,15 +542,14 @@ void gijoe_state::gijoe(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); k054539_device &k054539(K054539(config, "k054539", XTAL(18'432'000))); k054539.timer_handler().set_inputline("audiocpu", INPUT_LINE_NMI); - k054539.add_route(0, "rspeaker", 1.0); - k054539.add_route(1, "lspeaker", 1.0); + k054539.add_route(0, "speaker", 1.0, 1); + k054539.add_route(1, "speaker", 1.0, 0); } diff --git a/src/mame/konami/goldenregion.cpp b/src/mame/konami/goldenregion.cpp index 42dfa1e3090..af05001d2c3 100644 --- a/src/mame/konami/goldenregion.cpp +++ b/src/mame/konami/goldenregion.cpp @@ -306,12 +306,11 @@ void gs761_state::gs761(machine_config &config) K055555(config, m_k055555, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, XTAL(33'868'800)/2); // 33.8688 MHz xtal verified on PCB - m_ymz->add_route(0, "lspeaker", 0.75); - m_ymz->add_route(1, "rspeaker", 0.75); + m_ymz->add_route(0, "speaker", 0.75, 0); + m_ymz->add_route(1, "speaker", 0.75, 1); } ROM_START( glregion ) diff --git a/src/mame/konami/gradius3.cpp b/src/mame/konami/gradius3.cpp index 722420f507b..0f4aac5bd92 100644 --- a/src/mame/konami/gradius3.cpp +++ b/src/mame/konami/gradius3.cpp @@ -501,19 +501,18 @@ void gradius3_state::gradius3(machine_config &config) m_k051960->set_plane_order(K051960_PLANEORDER_GRADIUS3); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); - YM2151(config, "ymsnd", 3579545).add_route(0, "lspeaker", 1.0).add_route(0, "rspeaker", 1.0); + YM2151(config, "ymsnd", 3579545).add_route(0, "speaker", 1.0, 0).add_route(0, "speaker", 1.0, 1); K007232(config, m_k007232, 3579545); m_k007232->port_write().set(FUNC(gradius3_state::volume_callback)); - m_k007232->add_route(0, "lspeaker", 0.20); - m_k007232->add_route(0, "rspeaker", 0.20); - m_k007232->add_route(1, "lspeaker", 0.20); - m_k007232->add_route(1, "rspeaker", 0.20); + m_k007232->add_route(0, "speaker", 0.20, 0); + m_k007232->add_route(0, "speaker", 0.20, 1); + m_k007232->add_route(1, "speaker", 0.20, 0); + m_k007232->add_route(1, "speaker", 0.20, 1); } diff --git a/src/mame/konami/gticlub.cpp b/src/mame/konami/gticlub.cpp index 81bbd0c30d8..fa6db848efd 100644 --- a/src/mame/konami/gticlub.cpp +++ b/src/mame/konami/gticlub.cpp @@ -930,12 +930,11 @@ void gticlub_state::gticlub(machine_config &config) K056800(config, m_k056800, XTAL(33'868'800)/2); m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_2); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); rf5c400_device &rfsnd(RF5C400(config, "rfsnd", XTAL(33'868'800)/2)); - rfsnd.add_route(0, "lspeaker", 1.0); - rfsnd.add_route(1, "rspeaker", 1.0); + rfsnd.add_route(0, "speaker", 1.0, 0); + rfsnd.add_route(1, "speaker", 1.0, 1); KONPPC(config, m_konppc, 0); m_konppc->set_dsp_tag(0, m_dsp[0]); @@ -1035,12 +1034,11 @@ void hangplt_state::hangplt(machine_config &config) K056800(config, m_k056800, XTAL(33'868'800)/2); m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_2); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); rf5c400_device &rfsnd(RF5C400(config, "rfsnd", XTAL(33'868'800)/2)); - rfsnd.add_route(0, "lspeaker", 1.0); - rfsnd.add_route(1, "rspeaker", 1.0); + rfsnd.add_route(0, "speaker", 1.0, 0); + rfsnd.add_route(1, "speaker", 1.0, 1); KONPPC(config, m_konppc, 0); m_konppc->set_dsp_tag(0, m_dsp[0]); diff --git a/src/mame/konami/gyruss.cpp b/src/mame/konami/gyruss.cpp index eb4a3a5e1e1..d08de6f1c3a 100644 --- a/src/mame/konami/gyruss.cpp +++ b/src/mame/konami/gyruss.cpp @@ -743,8 +743,7 @@ void gyruss_state::gyruss(machine_config &config) PALETTE(config, m_palette, FUNC(gyruss_state::palette), 16*4+16*16, 32); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); GENERIC_LATCH_8(config, "soundlatch2"); @@ -788,8 +787,8 @@ void gyruss_state::gyruss(machine_config &config) ay5.add_route(2, "discrete", 1.0, 14); DISCRETE(config, m_discrete, sound_discrete); - m_discrete->add_route(0, "rspeaker", 1.0); - m_discrete->add_route(1, "lspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 1); + m_discrete->add_route(1, "speaker", 1.0, 0); } diff --git a/src/mame/konami/hornet.cpp b/src/mame/konami/hornet.cpp index bda20bc23d0..5ba2910f4cb 100644 --- a/src/mame/konami/hornet.cpp +++ b/src/mame/konami/hornet.cpp @@ -1383,12 +1383,11 @@ void hornet_state::hornet(machine_config &config) K056800(config, m_k056800, XTAL(16'934'400)); m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_2); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); RF5C400(config, "rfsnd", XTAL(16'934'400)) // value from Guru readme, gives 44100 Hz sample rate - .add_route(0, "lspeaker", 1.0) - .add_route(1, "rspeaker", 1.0); + .add_route(0, "speaker", 1.0, 0) + .add_route(1, "speaker", 1.0, 1); M48T58(config, "m48t58", 0); diff --git a/src/mame/konami/jackal.cpp b/src/mame/konami/jackal.cpp index 8217171bb02..21e5525dcd9 100644 --- a/src/mame/konami/jackal.cpp +++ b/src/mame/konami/jackal.cpp @@ -599,10 +599,9 @@ void jackal_state::jackal(machine_config &config) m_palette->set_endianness(ENDIANNESS_LITTLE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 0.50).add_route(1, "rspeaker", 0.50); // verified on PCB + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 0.50, 0).add_route(1, "speaker", 0.50, 1); // verified on PCB } /************************************* diff --git a/src/mame/konami/k573dio.cpp b/src/mame/konami/k573dio.cpp index 175e2455bdd..8258a54fe03 100644 --- a/src/mame/konami/k573dio.cpp +++ b/src/mame/konami/k573dio.cpp @@ -176,8 +176,8 @@ void k573dio_device::device_add_mconfig(machine_config &config) { KONAMI_573_DIGITAL_FPGA(config, k573fpga); k573fpga->set_ram(ram); - k573fpga->add_route(0, ":lspeaker", 1.0); - k573fpga->add_route(1, ":rspeaker", 1.0); + k573fpga->add_route(0, ":speaker", 1.0, 0); + k573fpga->add_route(1, ":speaker", 1.0, 1); DS2401(config, digital_id); } diff --git a/src/mame/konami/konamigq.cpp b/src/mame/konami/konamigq.cpp index c0a52010886..b7540e8c3a9 100644 --- a/src/mame/konami/konamigq.cpp +++ b/src/mame/konami/konamigq.cpp @@ -378,8 +378,7 @@ void konamigq_state::konamigq(machine_config &config) SCREEN(config, "screen", SCREEN_TYPE_RASTER); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); K056800(config, m_k056800, XTAL(18'432'000)); m_k056800->int_callback().set_inputline(m_soundcpu, M68K_IRQ_1); @@ -387,13 +386,13 @@ void konamigq_state::konamigq(machine_config &config) k054539_device &k054539_1(K054539(config, "k054539_1", XTAL(18'432'000))); k054539_1.set_addrmap(0, &konamigq_state::konamigq_k054539_map); k054539_1.timer_handler().set(FUNC(konamigq_state::k054539_irq_gen)); - k054539_1.add_route(0, "lspeaker", 1.0); - k054539_1.add_route(1, "rspeaker", 1.0); + k054539_1.add_route(0, "speaker", 1.0, 0); + k054539_1.add_route(1, "speaker", 1.0, 1); k054539_device &k054539_2(K054539(config, "k054539_2", XTAL(18'432'000))); k054539_2.set_addrmap(0, &konamigq_state::konamigq_k054539_map); - k054539_2.add_route(0, "lspeaker", 1.0); - k054539_2.add_route(1, "rspeaker", 1.0); + k054539_2.add_route(0, "speaker", 1.0, 0); + k054539_2.add_route(1, "speaker", 1.0, 1); } static INPUT_PORTS_START( konamigq ) diff --git a/src/mame/konami/konamigv.cpp b/src/mame/konami/konamigv.cpp index 6d9a997b21a..4b3b2ae77c0 100644 --- a/src/mame/konami/konamigv.cpp +++ b/src/mame/konami/konamigv.cpp @@ -580,8 +580,8 @@ void konamigv_state::konamigv(machine_config &config) NSCSI_CONNECTOR(config, "scsi:4").option_set("cdrom", NSCSI_XM5401).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:7").option_set("ncr53cf96", NCR53CF96).clock(32_MHz_XTAL/2).machine_config( [this](device_t *device) @@ -597,12 +597,11 @@ void konamigv_state::konamigv(machine_config &config) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); spu_device &spu(SPU(config, "spu", XTAL(67'737'600)/2, subdevice<psxcpu_device>("maincpu"))); - spu.add_route(1, "lspeaker", 0.75); // to verify the channels, btchamp's "game sound test" in the sound test menu speaks the words left, right, center - spu.add_route(0, "rspeaker", 0.75); + spu.add_route(1, "speaker", 0.75, 0); // to verify the channels, btchamp's "game sound test" in the sound test menu speaks the words left, right, center + spu.add_route(0, "speaker", 0.75, 1); } diff --git a/src/mame/konami/konamigx.cpp b/src/mame/konami/konamigx.cpp index 817b228c5d3..bb099011451 100644 --- a/src/mame/konami/konamigx.cpp +++ b/src/mame/konami/konamigx.cpp @@ -1776,13 +1776,12 @@ void konamigx_state::konamigx(machine_config &config) MCFG_VIDEO_START_OVERRIDE(konamigx_state, konamigx_5bpp) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_dasp->add_route(0, "lspeaker", 0.3); // Connected to the aux input of respective 54539. - m_dasp->add_route(1, "rspeaker", 0.3); - m_dasp->add_route(2, "lspeaker", 0.3); - m_dasp->add_route(3, "rspeaker", 0.3); + m_dasp->add_route(0, "speaker", 0.3, 0); // Connected to the aux input of respective 54539. + m_dasp->add_route(1, "speaker", 0.3, 1); + m_dasp->add_route(2, "speaker", 0.3, 0); + m_dasp->add_route(3, "speaker", 0.3, 1); K056800(config, m_k056800, XTAL(18'432'000)); m_k056800->int_callback().set_inputline(m_soundcpu, M68K_IRQ_1); @@ -1792,15 +1791,15 @@ void konamigx_state::konamigx(machine_config &config) m_k054539_1->timer_handler().set(FUNC(konamigx_state::k054539_irq_gen)); m_k054539_1->add_route(0, "dasp", 0.5, 0); m_k054539_1->add_route(1, "dasp", 0.5, 1); - m_k054539_1->add_route(0, "lspeaker", 1.0); - m_k054539_1->add_route(1, "rspeaker", 1.0); + m_k054539_1->add_route(0, "speaker", 1.0, 0); + m_k054539_1->add_route(1, "speaker", 1.0, 1); K054539(config, m_k054539_2, XTAL(18'432'000)); m_k054539_2->set_device_rom_tag("k054539"); m_k054539_2->add_route(0, "dasp", 0.5, 2); m_k054539_2->add_route(1, "dasp", 0.5, 3); - m_k054539_2->add_route(0, "lspeaker", 1.0); - m_k054539_2->add_route(1, "rspeaker", 1.0); + m_k054539_2->add_route(0, "speaker", 1.0, 0); + m_k054539_2->add_route(1, "speaker", 1.0, 1); } void konamigx_state::konamigx_bios(machine_config &config) diff --git a/src/mame/konami/konamim2.cpp b/src/mame/konami/konamim2.cpp index 6cfb2cd5c5d..72958b5ea6d 100644 --- a/src/mame/konami/konamim2.cpp +++ b/src/mame/konami/konamim2.cpp @@ -1124,8 +1124,8 @@ INPUT_PORTS_END void konamim2_state::cr589_config(device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, ":lspeaker", 0.5); - device->subdevice<cdda_device>("cdda")->add_route(1, ":rspeaker", 0.5); + device->subdevice<cdda_device>("cdda")->add_route(0, ":speaker", 0.5, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, ":speaker", 0.5, 1); device = device->subdevice("cdda"); } @@ -1170,12 +1170,11 @@ void konamim2_state::konamim2(machine_config &config) m_screen->set_screen_update("bda:vdu", FUNC(m2_vdu_device::screen_update)); // Sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO! - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } @@ -1211,8 +1210,8 @@ void konamim2_state::add_ymz280b(machine_config &config) { // TODO: The YMZ280B outputs are actually routed to a speaker in each gun YMZ280B(config, m_ymz280b, XTAL(16'934'400)); - m_ymz280b->add_route(0, "lspeaker", 0.5); - m_ymz280b->add_route(1, "rspeaker", 0.5); + m_ymz280b->add_route(0, "speaker", 0.5, 0); + m_ymz280b->add_route(1, "speaker", 0.5, 1); } void konamim2_state::add_mt48t58(machine_config &config) diff --git a/src/mame/konami/konendev.cpp b/src/mame/konami/konendev.cpp index f58c99b5d81..494fa82c882 100644 --- a/src/mame/konami/konendev.cpp +++ b/src/mame/konami/konendev.cpp @@ -403,13 +403,12 @@ void konendev_state::konendev(machine_config &config) EEPROM_93C56_16BIT(config, "eeprom"); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16'934'400)); // Clock unknown ymz.set_addrmap(0, &konendev_state::ymz280b_map); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/konami/kongs470.cpp b/src/mame/konami/kongs470.cpp index a05e223a374..655e2f88e30 100644 --- a/src/mame/konami/kongs470.cpp +++ b/src/mame/konami/kongs470.cpp @@ -76,12 +76,11 @@ void kongs470_state::kongs470(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &kongs470_state::main_map); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); k054539_device &k054539(K054539(config, "k054539", 18'432'000)); // clock unverified - k054539.add_route(0, "rspeaker", 0.75); - k054539.add_route(1, "lspeaker", 0.75); + k054539.add_route(0, "speaker", 0.75, 1); + k054539.add_route(1, "speaker", 0.75, 0); } diff --git a/src/mame/konami/konmedal.cpp b/src/mame/konami/konmedal.cpp index f69c04f59ca..c39f4894703 100644 --- a/src/mame/konami/konmedal.cpp +++ b/src/mame/konami/konmedal.cpp @@ -967,12 +967,11 @@ void konmedal_state::tsukande(machine_config &config) m_k056832->set_palette(m_palette); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, XTAL(16'934'400)); // 16.9344MHz xtal verified on PCB - m_ymz->add_route(0, "lspeaker", 1.0); - m_ymz->add_route(1, "rspeaker", 1.0); + m_ymz->add_route(0, "speaker", 1.0, 0); + m_ymz->add_route(1, "speaker", 1.0, 1); } void konmedal_state::ddboy(machine_config &config) diff --git a/src/mame/konami/konmedal020.cpp b/src/mame/konami/konmedal020.cpp index ae38dd6c822..4915185038b 100644 --- a/src/mame/konami/konmedal020.cpp +++ b/src/mame/konami/konmedal020.cpp @@ -107,12 +107,11 @@ void konmedal020_state::gs471(machine_config &config) m_vga->set_vram_size(0x100000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, XTAL(16'934'400)); // 16.9344 MHz xtal verified on PCB - m_ymz->add_route(0, "lspeaker", 0.75); - m_ymz->add_route(1, "rspeaker", 0.75); + m_ymz->add_route(0, "speaker", 0.75, 0); + m_ymz->add_route(1, "speaker", 0.75, 1); } ROM_START( gs471 ) diff --git a/src/mame/konami/konmedal68k.cpp b/src/mame/konami/konmedal68k.cpp index a52f8601105..29d4ded4c47 100644 --- a/src/mame/konami/konmedal68k.cpp +++ b/src/mame/konami/konmedal68k.cpp @@ -662,12 +662,11 @@ void konmedal68k_state::kzaurus(machine_config &config) K055555(config, m_k055555, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, XTAL(33'868'800)/2); // 33.8688 MHz xtal verified on PCB - m_ymz->add_route(0, "lspeaker", 0.75); - m_ymz->add_route(1, "rspeaker", 0.75); + m_ymz->add_route(0, "speaker", 0.75, 0); + m_ymz->add_route(1, "speaker", 0.75, 1); } void konmedal68k_state::koropens(machine_config &config) diff --git a/src/mame/konami/konmedalppc.cpp b/src/mame/konami/konmedalppc.cpp index baf95a7f6e8..38effb41a89 100644 --- a/src/mame/konami/konmedalppc.cpp +++ b/src/mame/konami/konmedalppc.cpp @@ -148,13 +148,12 @@ void konmedalppc_state::konmedalppc(machine_config &config) K057714(config, m_gcu, 0).set_screen("screen"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16934400)); ymz.set_addrmap(0, &konmedalppc_state::ymz280b_map); - ymz.add_route(1, "lspeaker", 1.0); - ymz.add_route(0, "rspeaker", 1.0); + ymz.add_route(1, "speaker", 1.0, 0); + ymz.add_route(0, "speaker", 1.0, 1); } ROM_START( turfwld3 ) diff --git a/src/mame/konami/kontest.cpp b/src/mame/konami/kontest.cpp index fc8651afdf8..abf9f749b40 100644 --- a/src/mame/konami/kontest.cpp +++ b/src/mame/konami/kontest.cpp @@ -267,12 +267,11 @@ void kontest_state::kontest(machine_config &config) PALETTE(config, m_palette, FUNC(kontest_state::kontest_palette), 32); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - SN76489A(config, "sn1", MAIN_CLOCK/16).add_route(ALL_OUTPUTS, "rspeaker", 0.50); + SN76489A(config, "sn1", MAIN_CLOCK/16).add_route(ALL_OUTPUTS, "speaker", 0.50, 1); - SN76489A(config, "sn2", MAIN_CLOCK/16).add_route(ALL_OUTPUTS, "lspeaker", 0.50); + SN76489A(config, "sn2", MAIN_CLOCK/16).add_route(ALL_OUTPUTS, "speaker", 0.50, 0); } diff --git a/src/mame/konami/kpontoon.cpp b/src/mame/konami/kpontoon.cpp index 7d60e96fffa..72910a34eee 100644 --- a/src/mame/konami/kpontoon.cpp +++ b/src/mame/konami/kpontoon.cpp @@ -387,8 +387,7 @@ void kpontoon_state::kpontoon(machine_config &config) GFXDECODE(config, m_gfxdecode, "palette", gfx_pontoon); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); K053246(config, m_k053246, 0); //m_k053246.set_sprite_callback(FUNC(kpontoon_state::sprite_callback)); @@ -398,8 +397,8 @@ void kpontoon_state::kpontoon(machine_config &config) K054539(config, m_k054539, 18.432_MHz_XTAL); m_k054539->set_device_rom_tag("k054539"); m_k054539->timer_handler().set(FUNC(kpontoon_state::k054539_nmi_gen)); - m_k054539->add_route(0, "rspeaker", 0.75); - m_k054539->add_route(1, "lspeaker", 0.75); + m_k054539->add_route(0, "speaker", 0.75, 1); + m_k054539->add_route(1, "speaker", 0.75, 0); } diff --git a/src/mame/konami/ksys573.cpp b/src/mame/konami/ksys573.cpp index 757574802aa..dc75cf57679 100644 --- a/src/mame/konami/ksys573.cpp +++ b/src/mame/konami/ksys573.cpp @@ -2395,8 +2395,8 @@ double ksys573_state::analogue_inputs_callback(uint8_t input) void ksys573_state::cr589_config(device_t *device) { auto cdda = device->subdevice<cdda_device>("cdda"); - cdda->add_route(0, "^^lspeaker", 1.0); - cdda->add_route(1, "^^rspeaker", 1.0); + cdda->add_route(0, "^^speaker", 1.0, 0); + cdda->add_route(1, "^^speaker", 1.0, 1); auto cdrom = device->subdevice<cdrom_image_device>("image"); cdrom->add_region("install"); @@ -2450,12 +2450,11 @@ void ksys573_state::konami573(machine_config &config, bool no_cdrom) SCREEN(config, "screen", SCREEN_TYPE_RASTER); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); spu_device &spu(SPU(config, "spu", XTAL(67'737'600)/2, m_maincpu.target())); - spu.add_route(0, "lspeaker", 1.0); - spu.add_route(1, "rspeaker", 1.0); + spu.add_route(0, "speaker", 1.0, 0); + spu.add_route(1, "speaker", 1.0, 1); M48T58(config, "m48t58", 0); diff --git a/src/mame/konami/lethal.cpp b/src/mame/konami/lethal.cpp index 1c01036769f..6687f069c64 100644 --- a/src/mame/konami/lethal.cpp +++ b/src/mame/konami/lethal.cpp @@ -691,15 +691,14 @@ void lethal_state::lethalen(machine_config &config) K054000(config, "k054000", 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); k054539_device &k054539(K054539(config, "k054539", SOUND_CLOCK)); k054539.timer_handler().set_inputline("soundcpu", INPUT_LINE_NMI); - k054539.add_route(0, "rspeaker", 1.0); - k054539.add_route(1, "lspeaker", 1.0); + k054539.add_route(0, "speaker", 1.0, 0); + k054539.add_route(1, "speaker", 1.0, 1); } void lethal_state::lethalej(machine_config &config) diff --git a/src/mame/konami/mogura.cpp b/src/mame/konami/mogura.cpp index 07efc4a0cef..28677631c9a 100644 --- a/src/mame/konami/mogura.cpp +++ b/src/mame/konami/mogura.cpp @@ -294,10 +294,9 @@ void mogura_state::mogura(machine_config &config) PALETTE(config, "palette", FUNC(mogura_state::palette), 32); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_4BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); - DAC_4BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); + SPEAKER(config, "speaker", 2).front(); + DAC_4BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + DAC_4BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } diff --git a/src/mame/konami/moo.cpp b/src/mame/konami/moo.cpp index 5c3a0b45fb5..b86e998682e 100644 --- a/src/mame/konami/moo.cpp +++ b/src/mame/konami/moo.cpp @@ -754,16 +754,15 @@ void moo_state::moo(machine_config &config) K054338(config, m_k054338, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); - YM2151(config, "ymsnd", XTAL(32'000'000)/8).add_route(0, "lspeaker", 0.50).add_route(1, "rspeaker", 0.50); // 4MHz verified + YM2151(config, "ymsnd", XTAL(32'000'000)/8).add_route(0, "speaker", 0.50, 0).add_route(1, "speaker", 0.50, 1); // 4MHz verified K054539(config, m_k054539, XTAL(18'432'000)); - m_k054539->add_route(0, "rspeaker", 0.75); - m_k054539->add_route(1, "lspeaker", 0.75); + m_k054539->add_route(0, "speaker", 0.75, 0); + m_k054539->add_route(1, "speaker", 0.75, 1); } void moo_state::moobl(machine_config &config) @@ -805,12 +804,11 @@ void moo_state::moobl(machine_config &config) K054338(config, m_k054338, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, 1056000, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void moo_state::bucky(machine_config &config) diff --git a/src/mame/konami/mystwarr.cpp b/src/mame/konami/mystwarr.cpp index 22818d9233b..96a51473a0f 100644 --- a/src/mame/konami/mystwarr.cpp +++ b/src/mame/konami/mystwarr.cpp @@ -996,21 +996,20 @@ void mystwarr_state::mystwarr(machine_config &config) MCFG_VIDEO_START_OVERRIDE(mystwarr_state, mystwarr) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); K054539(config, m_k054539_1, XTAL(18'432'000)); m_k054539_1->set_device_rom_tag("k054539"); m_k054539_1->timer_handler().set(FUNC(mystwarr_state::k054539_nmi_gen)); - m_k054539_1->add_route(0, "rspeaker", 1.0); /* stereo channels are inverted */ - m_k054539_1->add_route(1, "lspeaker", 1.0); + m_k054539_1->add_route(0, "speaker", 1.0, 1); /* stereo channels are inverted */ + m_k054539_1->add_route(1, "speaker", 1.0, 0); K054539(config, m_k054539_2, XTAL(18'432'000)); m_k054539_2->set_device_rom_tag("k054539"); - m_k054539_2->add_route(0, "rspeaker", 1.0); /* stereo channels are inverted */ - m_k054539_2->add_route(1, "lspeaker", 1.0); + m_k054539_2->add_route(0, "speaker", 1.0, 1); /* stereo channels are inverted */ + m_k054539_2->add_route(1, "speaker", 1.0, 0); } void mystwarr_state::viostorm(machine_config &config) @@ -1057,8 +1056,8 @@ void mystwarr_state::viostormbl(machine_config &config) okim6295_device &oki(OKIM6295(config, "oki", 1'056'000, okim6295_device::PIN7_HIGH)); // frequency and pin 7 unverified oki.set_addrmap(0, &mystwarr_state::oki_map); - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void mystwarr_state::metamrph(machine_config &config) diff --git a/src/mame/konami/nemesis.cpp b/src/mame/konami/nemesis.cpp index 05052a13e57..167a3707581 100644 --- a/src/mame/konami/nemesis.cpp +++ b/src/mame/konami/nemesis.cpp @@ -2115,25 +2115,24 @@ void salamand_state::salamand(machine_config &config) m_palette->set_membits(8); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); VLM5030(config, m_vlm, 3'579'545); m_vlm->set_addrmap(0, &salamand_state::salamand_vlm_map); - m_vlm->add_route(ALL_OUTPUTS, "lspeaker", 2.50); - m_vlm->add_route(ALL_OUTPUTS, "rspeaker", 2.50); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 2.50, 0); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 2.50, 1); K007232(config, m_k007232, 3'579'545); m_k007232->port_write().set(FUNC(salamand_state::volume_callback)); - m_k007232->add_route(ALL_OUTPUTS, "lspeaker", 0.08); - m_k007232->add_route(ALL_OUTPUTS, "rspeaker", 0.08); + m_k007232->add_route(ALL_OUTPUTS, "speaker", 0.08, 0); + m_k007232->add_route(ALL_OUTPUTS, "speaker", 0.08, 1); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3'579'545)); // ymsnd.irq_handler().set_inputline(m_audiocpu, 0); ... Interrupts _are_ generated, I wonder where they go - ymsnd.add_route(0, "rspeaker", 1.2); // reversed according to MT #4565 - ymsnd.add_route(1, "lspeaker", 1.2); + ymsnd.add_route(0, "speaker", 1.2, 1); // reversed according to MT #4565 + ymsnd.add_route(1, "speaker", 1.2, 0); } void salamand_state::blkpnthr(machine_config &config) @@ -2159,20 +2158,19 @@ void salamand_state::blkpnthr(machine_config &config) m_palette->set_membits(8); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); K007232(config, m_k007232, 3'579'545); m_k007232->port_write().set(FUNC(salamand_state::volume_callback)); - m_k007232->add_route(ALL_OUTPUTS, "lspeaker", 0.10); - m_k007232->add_route(ALL_OUTPUTS, "rspeaker", 0.10); + m_k007232->add_route(ALL_OUTPUTS, "speaker", 0.10, 0); + m_k007232->add_route(ALL_OUTPUTS, "speaker", 0.10, 1); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3'579'545)); // ymsnd.irq_handler().set_inputline(m_audiocpu, 0); ... Interrupts _are_ generated, I wonder where they go - ymsnd.add_route(0, "lspeaker", 1.0); - ymsnd.add_route(1, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 1.0, 0); + ymsnd.add_route(1, "speaker", 1.0, 1); } void hcrash_state::citybomb(machine_config &config) @@ -2287,25 +2285,24 @@ void hcrash_state::hcrash(machine_config &config) m_palette->set_membits(8); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); VLM5030(config, m_vlm, 3'579'545); m_vlm->set_addrmap(0, &hcrash_state::salamand_vlm_map); - m_vlm->add_route(ALL_OUTPUTS, "lspeaker", 2.00); - m_vlm->add_route(ALL_OUTPUTS, "rspeaker", 2.00); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 2.00, 0); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 2.00, 1); K007232(config, m_k007232, 3'579'545); m_k007232->port_write().set(FUNC(hcrash_state::volume_callback)); - m_k007232->add_route(ALL_OUTPUTS, "lspeaker", 0.10); - m_k007232->add_route(ALL_OUTPUTS, "rspeaker", 0.10); + m_k007232->add_route(ALL_OUTPUTS, "speaker", 0.10, 0); + m_k007232->add_route(ALL_OUTPUTS, "speaker", 0.10, 1); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3'579'545)); // ymsnd.irq_handler().set_inputline(m_audiocpu, 0); ... Interrupts _are_ generated, I wonder where they go - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); } /*************************************************************************** diff --git a/src/mame/konami/nwk-tr.cpp b/src/mame/konami/nwk-tr.cpp index 8aae7dab21c..2003745d253 100644 --- a/src/mame/konami/nwk-tr.cpp +++ b/src/mame/konami/nwk-tr.cpp @@ -700,15 +700,14 @@ void nwktr_state::nwktr(machine_config &config) K001604(config, m_k001604[1], 0); m_k001604[1]->set_palette(m_palette[1]); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); K056800(config, m_k056800, XTAL(16'934'400)); m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_2); rf5c400_device &rfsnd(RF5C400(config, "rfsnd", XTAL(16'934'400))); // as per Guru readme above - rfsnd.add_route(0, "lspeaker", 1.0); - rfsnd.add_route(1, "rspeaker", 1.0); + rfsnd.add_route(0, "speaker", 1.0, 0); + rfsnd.add_route(1, "speaker", 1.0, 1); KONPPC(config, m_konppc, 0); m_konppc->set_dsp_tag(0, m_dsp[0]); diff --git a/src/mame/konami/overdriv.cpp b/src/mame/konami/overdriv.cpp index 6c8f5e196a3..d694b817e50 100644 --- a/src/mame/konami/overdriv.cpp +++ b/src/mame/konami/overdriv.cpp @@ -496,20 +496,19 @@ void overdriv_state::overdriv(machine_config &config) m_k053252->set_offsets(13*8, 2*8); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 0.5).add_route(1, "rspeaker", 0.5); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 0.5, 0).add_route(1, "speaker", 0.5, 1); k053260_device &k053260_1(K053260(config, "k053260_1", XTAL(3'579'545))); k053260_1.set_device_rom_tag("k053260"); - k053260_1.add_route(0, "lspeaker", 0.35); - k053260_1.add_route(1, "rspeaker", 0.35); + k053260_1.add_route(0, "speaker", 0.35, 0); + k053260_1.add_route(1, "speaker", 0.35, 1); k053260_device &k053260_2(K053260(config, "k053260_2", XTAL(3'579'545))); k053260_2.set_device_rom_tag("k053260"); - k053260_2.add_route(0, "lspeaker", 0.35); - k053260_2.add_route(1, "rspeaker", 0.35); + k053260_2.add_route(0, "speaker", 0.35, 0); + k053260_2.add_route(1, "speaker", 0.35, 1); } diff --git a/src/mame/konami/parodius.cpp b/src/mame/konami/parodius.cpp index 7d5b578eca8..4603b976a3c 100644 --- a/src/mame/konami/parodius.cpp +++ b/src/mame/konami/parodius.cpp @@ -393,14 +393,13 @@ void parodius_state::parodius(machine_config &config) K053251(config, m_k053251, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 3579545).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", 3579545).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); k053260_device &k053260(K053260(config, "k053260", 3579545)); - k053260.add_route(0, "lspeaker", 0.70); - k053260.add_route(1, "rspeaker", 0.70); + k053260.add_route(0, "speaker", 0.70, 0); + k053260.add_route(1, "speaker", 0.70, 1); k053260.sh1_cb().set(FUNC(parodius_state::z80_nmi_w)); } diff --git a/src/mame/konami/piratesh.cpp b/src/mame/konami/piratesh.cpp index 9301ca59757..161feb11cdd 100644 --- a/src/mame/konami/piratesh.cpp +++ b/src/mame/konami/piratesh.cpp @@ -648,13 +648,12 @@ void piratesh_state::piratesh(machine_config &config) K054338(config, "k054338", 0, m_k055555).set_alpha_invert(1); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); K054539(config, m_k054539, XTAL(18'432'000)); m_k054539->timer_handler().set(FUNC(piratesh_state::k054539_nmi_gen)); - m_k054539->add_route(0, "lspeaker", 0.2); - m_k054539->add_route(1, "rspeaker", 0.2); + m_k054539->add_route(0, "speaker", 0.2, 0); + m_k054539->add_route(1, "speaker", 0.2, 1); } diff --git a/src/mame/konami/plygonet.cpp b/src/mame/konami/plygonet.cpp index 8bfb552f4ce..8f7940e213a 100644 --- a/src/mame/konami/plygonet.cpp +++ b/src/mame/konami/plygonet.cpp @@ -1077,15 +1077,14 @@ void polygonet_state::plygonet(machine_config &config) m_k053936->set_wrap(true); // Sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); k054539_device &k054539(K054539(config, "k054539", XTAL(18'432'000))); k054539.timer_handler().set(FUNC(polygonet_state::k054539_nmi_gen)); - k054539.add_route(0, "lspeaker", 0.75); - k054539.add_route(1, "rspeaker", 0.75); + k054539.add_route(0, "speaker", 0.75, 0); + k054539.add_route(1, "speaker", 0.75, 1); } diff --git a/src/mame/konami/qdrmfgp.cpp b/src/mame/konami/qdrmfgp.cpp index 6fc5c89842a..87708c311f3 100644 --- a/src/mame/konami/qdrmfgp.cpp +++ b/src/mame/konami/qdrmfgp.cpp @@ -697,14 +697,13 @@ void qdrmfgp_state::qdrmfgp(machine_config &config) m_k053252->set_offsets(40, 16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); k054539_device &k054539(K054539(config, m_k054539, XTAL(18'432'000))); k054539.set_addrmap(0, &qdrmfgp_state::qdrmfgp_k054539_map); k054539.timer_handler().set(FUNC(qdrmfgp_state::k054539_irq1_gen)); - k054539.add_route(0, "lspeaker", 1.0); - k054539.add_route(1, "rspeaker", 1.0); + k054539.add_route(0, "speaker", 1.0, 0); + k054539.add_route(1, "speaker", 1.0, 1); } void qdrmfgp_state::qdrmfgp2(machine_config &config) @@ -742,13 +741,12 @@ void qdrmfgp_state::qdrmfgp2(machine_config &config) m_k053252->set_offsets(40, 16); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); k054539_device &k054539(K054539(config, "k054539", XTAL(18'432'000))); k054539.set_addrmap(0, &qdrmfgp_state::qdrmfgp_k054539_map); - k054539.add_route(0, "lspeaker", 1.0); - k054539.add_route(1, "rspeaker", 1.0); + k054539.add_route(0, "speaker", 1.0, 0); + k054539.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/konami/rockrage.cpp b/src/mame/konami/rockrage.cpp index 19d273666c4..64f18790f2d 100644 --- a/src/mame/konami/rockrage.cpp +++ b/src/mame/konami/rockrage.cpp @@ -400,17 +400,16 @@ void rockrage_state::rockrage(machine_config &config) m_palette->set_endianness(ENDIANNESS_LITTLE); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, M6809_IRQ_LINE); - YM2151(config, "ymsnd", 3'579'545).add_route(0, "lspeaker", 0.30).add_route(1, "rspeaker", 0.30); + YM2151(config, "ymsnd", 3'579'545).add_route(0, "speaker", 0.30, 0).add_route(1, "speaker", 0.30, 1); VLM5030(config, m_vlm, 3'579'545); m_vlm->set_addrmap(0, &rockrage_state::vlm_map); - m_vlm->add_route(ALL_OUTPUTS, "lspeaker", 0.60); - m_vlm->add_route(ALL_OUTPUTS, "rspeaker", 0.60); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 0.60, 0); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 0.60, 1); } diff --git a/src/mame/konami/rungun.cpp b/src/mame/konami/rungun.cpp index e19321b7d31..7f3ed148e61 100644 --- a/src/mame/konami/rungun.cpp +++ b/src/mame/konami/rungun.cpp @@ -685,23 +685,22 @@ void rungun_state::rng(machine_config &config) m_palette2->enable_hilights(); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); // SFX K054539(config, m_k054539[0], 18.432_MHz_XTAL); m_k054539[0]->set_device_rom_tag("k054539"); m_k054539[0]->timer_handler().set(FUNC(rungun_state::k054539_nmi_gen)); - m_k054539[0]->add_route(0, "rspeaker", 1.0); - m_k054539[0]->add_route(1, "lspeaker", 1.0); + m_k054539[0]->add_route(0, "speaker", 1.0, 1); + m_k054539[0]->add_route(1, "speaker", 1.0, 0); // BGM, volumes handtuned to make SFXs audible (still not 100% right tho) K054539(config, m_k054539[1], 18.432_MHz_XTAL); m_k054539[1]->set_device_rom_tag("k054539"); - m_k054539[1]->add_route(0, "rspeaker", 0.6); - m_k054539[1]->add_route(1, "lspeaker", 0.6); + m_k054539[1]->add_route(0, "speaker", 0.6, 0); + m_k054539[1]->add_route(1, "speaker", 0.6, 1); } // for dual-screen output Run and Gun requires the video de-multiplexer board connected to the Jamma output, this gives you 2 Jamma connectors, one for each screen. diff --git a/src/mame/konami/simpsons.cpp b/src/mame/konami/simpsons.cpp index 423525feebe..a0aabd3170d 100644 --- a/src/mame/konami/simpsons.cpp +++ b/src/mame/konami/simpsons.cpp @@ -677,18 +677,17 @@ void simpsons_state::simpsons(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); /* verified on pcb */ - ymsnd.add_route(0, "lspeaker", 0.5); /* only left channel is connected */ - ymsnd.add_route(0, "rspeaker", 0.5); - ymsnd.add_route(1, "lspeaker", 0.0); - ymsnd.add_route(1, "rspeaker", 0.0); + ymsnd.add_route(0, "speaker", 0.5, 0); /* only left channel is connected */ + ymsnd.add_route(0, "speaker", 0.5, 1); + ymsnd.add_route(1, "speaker", 0.0, 0); + ymsnd.add_route(1, "speaker", 0.0, 1); k053260_device &k053260(K053260(config, "k053260", XTAL(3'579'545))); /* verified on pcb */ - k053260.add_route(0, "lspeaker", 0.5); - k053260.add_route(1, "rspeaker", 0.5); + k053260.add_route(0, "speaker", 0.5, 0); + k053260.add_route(1, "speaker", 0.5, 1); k053260.sh1_cb().set(FUNC(simpsons_state::z80_nmi_w)); } diff --git a/src/mame/konami/stingnet.cpp b/src/mame/konami/stingnet.cpp index 37ed17f5ebc..610660a77a4 100644 --- a/src/mame/konami/stingnet.cpp +++ b/src/mame/konami/stingnet.cpp @@ -344,13 +344,12 @@ void stingnet_state::stingnet(machine_config &config) NS16550(config, "duart:chan0", XTAL(19'660'800)); NS16550(config, "duart:chan1", XTAL(19'660'800)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, m_ymz, 16934400)); ymz.set_addrmap(0, &stingnet_state::ymz280b_map); - ymz.add_route(1, "lspeaker", 1.0); - ymz.add_route(0, "rspeaker", 1.0); + ymz.add_route(1, "speaker", 1.0, 0); + ymz.add_route(0, "speaker", 1.0, 1); } ROM_START( tropchnc ) diff --git a/src/mame/konami/surpratk.cpp b/src/mame/konami/surpratk.cpp index f0b4fbd32c0..65710c25172 100644 --- a/src/mame/konami/surpratk.cpp +++ b/src/mame/konami/surpratk.cpp @@ -336,13 +336,12 @@ void surpratk_state::surpratk(machine_config &config) K053251(config, m_k053251, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); ymsnd.irq_handler().set_inputline(m_maincpu, KONAMI_FIRQ_LINE); - ymsnd.add_route(0, "lspeaker", 1.0); - ymsnd.add_route(1, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 1.0, 0); + ymsnd.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/konami/tasman.cpp b/src/mame/konami/tasman.cpp index 16b798f0c7d..29867e2a48a 100644 --- a/src/mame/konami/tasman.cpp +++ b/src/mame/konami/tasman.cpp @@ -690,8 +690,7 @@ void kongambl_state::kongambl(machine_config &config) m_k056832->set_config(K056832_BPP_8TASMAN, 0, 0); m_k056832->set_palette(m_palette); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/konami/tmnt2.cpp b/src/mame/konami/tmnt2.cpp index 5ac99b03e27..21fdb8c477b 100644 --- a/src/mame/konami/tmnt2.cpp +++ b/src/mame/konami/tmnt2.cpp @@ -2461,14 +2461,13 @@ void tmnt2_state::lgtnfght(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); K053260(config, m_k053260, XTAL(3'579'545)); - m_k053260->add_route(0, "lspeaker", 0.70); - m_k053260->add_route(1, "rspeaker", 0.70); + m_k053260->add_route(0, "speaker", 0.70, 0); + m_k053260->add_route(1, "speaker", 0.70, 1); m_k053260->sh1_cb().set(FUNC(tmnt2_state::z80_nmi_w)); } @@ -2517,14 +2516,13 @@ void tmnt2_state::blswhstl(machine_config &config) K054000(config, m_k054000, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 0.70).add_route(1, "rspeaker", 0.70); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 0.70, 0).add_route(1, "speaker", 0.70, 1); K053260(config, m_k053260, XTAL(3'579'545)); - m_k053260->add_route(0, "rspeaker", 0.50); /* fixed inverted stereo channels */ - m_k053260->add_route(1, "lspeaker", 0.50); + m_k053260->add_route(0, "speaker", 0.50, 1); /* fixed inverted stereo channels */ + m_k053260->add_route(1, "speaker", 0.50, 0); m_k053260->sh1_cb().set(FUNC(tmnt2_state::z80_nmi_w)); } @@ -2584,12 +2582,11 @@ void glfgreat_state::glfgreat(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); K053260(config, m_k053260, XTAL(3'579'545)); - m_k053260->add_route(0, "lspeaker", 1.0); - m_k053260->add_route(1, "rspeaker", 1.0); + m_k053260->add_route(0, "speaker", 1.0, 1); + m_k053260->add_route(1, "speaker", 1.0, 0); m_k053260->sh1_cb().set(FUNC(glfgreat_state::z80_nmi_w)); } @@ -2648,15 +2645,14 @@ void prmrsocr_state::prmrsocr(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, "k054321", "lspeaker", "rspeaker"); + K054321(config, "k054321", "speaker"); K054539(config, m_k054539, XTAL(18'432'000)); m_k054539->timer_handler().set_inputline("audiocpu", INPUT_LINE_NMI); - m_k054539->add_route(0, "lspeaker", 1.0); - m_k054539->add_route(1, "rspeaker", 1.0); + m_k054539->add_route(0, "speaker", 1.0, 0); + m_k054539->add_route(1, "speaker", 1.0, 1); } void tmnt2_state::tmnt2(machine_config &config) @@ -2705,14 +2701,13 @@ void tmnt2_state::tmnt2(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); K053260(config, m_k053260, XTAL(3'579'545)); - m_k053260->add_route(0, "lspeaker", 0.75); - m_k053260->add_route(1, "rspeaker", 0.75); + m_k053260->add_route(0, "speaker", 0.75, 0); + m_k053260->add_route(1, "speaker", 0.75, 1); m_k053260->sh1_cb().set(FUNC(tmnt2_state::z80_nmi_w)); } @@ -2759,14 +2754,13 @@ void tmnt2_state::ssriders(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); K053260(config, m_k053260, XTAL(3'579'545)); - m_k053260->add_route(0, "lspeaker", 0.70); - m_k053260->add_route(1, "rspeaker", 0.70); + m_k053260->add_route(0, "speaker", 0.70, 0); + m_k053260->add_route(1, "speaker", 0.70, 1); m_k053260->sh1_cb().set(FUNC(tmnt2_state::z80_nmi_w)); } @@ -2820,12 +2814,11 @@ void sunsetbl_state::sunsetbl(machine_config &config) K053251(config, m_k053251, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", 1056000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void tmnt2_state::thndrx2(machine_config &config) @@ -2869,14 +2862,13 @@ void tmnt2_state::thndrx2(machine_config &config) /* sound hardware */ // NB: game defaults in mono - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 0.25).add_route(1, "rspeaker", 0.25); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 0.25, 0).add_route(1, "speaker", 0.25, 1); K053260(config, m_k053260, XTAL(3'579'545)); - m_k053260->add_route(0, "lspeaker", 0.50); - m_k053260->add_route(1, "rspeaker", 0.50); + m_k053260->add_route(0, "speaker", 0.50, 0); + m_k053260->add_route(1, "speaker", 0.50, 1); m_k053260->sh1_cb().set(FUNC(tmnt2_state::z80_nmi_w)); } diff --git a/src/mame/konami/twin16.cpp b/src/mame/konami/twin16.cpp index 0756ce2e20c..db317971e11 100644 --- a/src/mame/konami/twin16.cpp +++ b/src/mame/konami/twin16.cpp @@ -677,23 +677,22 @@ void twin16_state::twin16(machine_config &config) m_palette->enable_shadows(); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); K007232(config, m_k007232, XTAL(3'579'545)); m_k007232->port_write().set(FUNC(twin16_state::volume_callback)); - m_k007232->add_route(0, "lspeaker", 0.12); // estimated with gradius2 OST - m_k007232->add_route(0, "rspeaker", 0.12); - m_k007232->add_route(1, "lspeaker", 0.12); - m_k007232->add_route(1, "rspeaker", 0.12); + m_k007232->add_route(0, "speaker", 0.12, 0); // estimated with gradius2 OST + m_k007232->add_route(0, "speaker", 0.12, 1); + m_k007232->add_route(1, "speaker", 0.12, 0); + m_k007232->add_route(1, "speaker", 0.12, 1); UPD7759(config, m_upd7759); - m_upd7759->add_route(ALL_OUTPUTS, "lspeaker", 0.20); - m_upd7759->add_route(ALL_OUTPUTS, "rspeaker", 0.20); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.20, 0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.20, 1); } void twin16_state::devilw(machine_config &config) @@ -731,23 +730,22 @@ void fround_state::fround(machine_config &config) m_palette->enable_shadows(); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); K007232(config, m_k007232, XTAL(3'579'545)); m_k007232->port_write().set(FUNC(twin16_state::volume_callback)); - m_k007232->add_route(0, "lspeaker", 0.12); - m_k007232->add_route(0, "rspeaker", 0.12); - m_k007232->add_route(1, "lspeaker", 0.12); - m_k007232->add_route(1, "rspeaker", 0.12); + m_k007232->add_route(0, "speaker", 0.12, 0); + m_k007232->add_route(0, "speaker", 0.12, 1); + m_k007232->add_route(1, "speaker", 0.12, 0); + m_k007232->add_route(1, "speaker", 0.12, 1); UPD7759(config, m_upd7759); - m_upd7759->add_route(ALL_OUTPUTS, "lspeaker", 0.20); - m_upd7759->add_route(ALL_OUTPUTS, "rspeaker", 0.20); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.20, 0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.20, 1); } void twin16_state::miaj(machine_config &config) diff --git a/src/mame/konami/ultraman.cpp b/src/mame/konami/ultraman.cpp index 66bc40385e6..9fc4174400e 100644 --- a/src/mame/konami/ultraman.cpp +++ b/src/mame/konami/ultraman.cpp @@ -393,16 +393,15 @@ void ultraman_state::ultraman(machine_config &config) m_k051316[2]->set_zoom_callback(FUNC(ultraman_state::zoom_callback<2>)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); - YM2151(config, "ymsnd", 24'000'000 / 6).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", 24'000'000 / 6).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); okim6295_device &oki(OKIM6295(config, "oki", 1'056'000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } diff --git a/src/mame/konami/ultrsprt.cpp b/src/mame/konami/ultrsprt.cpp index b83edaaac31..28cc580ef34 100644 --- a/src/mame/konami/ultrsprt.cpp +++ b/src/mame/konami/ultrsprt.cpp @@ -277,13 +277,12 @@ void ultrsprt_state::ultrsprt(machine_config &config) K056800(config, m_k056800, XTAL(18'432'000)); m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_6); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); k054539_device &k054539(K054539(config, "k054539", XTAL(18'432'000))); k054539.timer_handler().set_inputline("audiocpu", M68K_IRQ_5); - k054539.add_route(0, "lspeaker", 1.0); - k054539.add_route(1, "rspeaker", 1.0); + k054539.add_route(0, "speaker", 1.0, 0); + k054539.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/konami/vendetta.cpp b/src/mame/konami/vendetta.cpp index fe1c6a3a42d..b6604e7d20e 100644 --- a/src/mame/konami/vendetta.cpp +++ b/src/mame/konami/vendetta.cpp @@ -646,14 +646,13 @@ void vendetta_state::vendetta(machine_config &config) K054000(config, m_k054000, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 0.5).add_route(1, "rspeaker", 0.5); // verified with PCB + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 0.5, 0).add_route(1, "speaker", 0.5, 1); // verified with PCB k053260_device &k053260(K053260(config, "k053260", XTAL(3'579'545))); // verified with PCB - k053260.add_route(0, "lspeaker", 0.75); - k053260.add_route(1, "rspeaker", 0.75); + k053260.add_route(0, "speaker", 0.75, 0); + k053260.add_route(1, "speaker", 0.75, 1); k053260.sh1_cb().set(FUNC(vendetta_state::z80_nmi_w)); } diff --git a/src/mame/konami/viper.cpp b/src/mame/konami/viper.cpp index fdb1feaaf06..f2dee32f546 100644 --- a/src/mame/konami/viper.cpp +++ b/src/mame/konami/viper.cpp @@ -2605,10 +2605,9 @@ void viper_state::viper(machine_config &config) PALETTE(config, "palette").set_entries(65536); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DMADAC(config, "dacl").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DMADAC(config, "dacr").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + DMADAC(config, "dacl").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config, "dacr").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); M48T58(config, "m48t58", 0); @@ -2629,12 +2628,10 @@ void viper_state::viper_ppp(machine_config &config) void viper_state::viper_fullbody(machine_config &config) { viper(config); - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); - SPEAKER(config, "front").front_center(); - SPEAKER(config, "rear").rear_center(); - DMADAC(config.replace(), "dacl").add_route(ALL_OUTPUTS, "front", 1.0); - DMADAC(config.replace(), "dacr").add_route(ALL_OUTPUTS, "rear", 1.0); + config.device_remove("speaker"); + SPEAKER(config, "speaker").front_center(0).rear_center(1); + DMADAC(config.replace(), "dacl").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config.replace(), "dacr").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void viper_state::viper_fbdongle(machine_config &config) diff --git a/src/mame/konami/wecleman.cpp b/src/mame/konami/wecleman.cpp index d9b16ff3798..1a58eb657bb 100644 --- a/src/mame/konami/wecleman.cpp +++ b/src/mame/konami/wecleman.cpp @@ -1073,17 +1073,16 @@ void wecleman_state::wecleman(machine_config &config) PALETTE(config, m_palette).set_entries(2048); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); - YM2151(config, "ymsnd", 3579545).add_route(0, "lspeaker", 0.85).add_route(1, "rspeaker", 0.85); + YM2151(config, "ymsnd", 3579545).add_route(0, "speaker", 0.85, 0).add_route(1, "speaker", 0.85, 1); K007232(config, m_k007232[0], 3579545); m_k007232[0]->port_write().set(FUNC(wecleman_state::wecleman_volume_callback)); - m_k007232[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.20); - m_k007232[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.20); + m_k007232[0]->add_route(ALL_OUTPUTS, "speaker", 0.20, 0); + m_k007232[0]->add_route(ALL_OUTPUTS, "speaker", 0.20, 1); } @@ -1153,25 +1152,24 @@ void hotchase_state::hotchase(machine_config &config) m_k051316[1]->set_zoom_callback(FUNC(hotchase_state::hotchase_zoom_callback_2)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); K007232(config, m_k007232[0], 3579545); // SLEV not used, volume control is elsewhere - m_k007232[0]->add_route(0, "lspeaker", 0.20); - m_k007232[0]->add_route(1, "rspeaker", 0.20); + m_k007232[0]->add_route(0, "speaker", 0.20, 0); + m_k007232[0]->add_route(1, "speaker", 0.20, 1); K007232(config, m_k007232[1], 3579545); // SLEV not used, volume control is elsewhere - m_k007232[1]->add_route(0, "lspeaker", 0.20); - m_k007232[1]->add_route(1, "rspeaker", 0.20); + m_k007232[1]->add_route(0, "speaker", 0.20, 0); + m_k007232[1]->add_route(1, "speaker", 0.20, 1); K007232(config, m_k007232[2], 3579545); // SLEV not used, volume control is elsewhere - m_k007232[2]->add_route(0, "lspeaker", 0.20); - m_k007232[2]->add_route(1, "rspeaker", 0.20); + m_k007232[2]->add_route(0, "speaker", 0.20, 0); + m_k007232[2]->add_route(1, "speaker", 0.20, 1); } diff --git a/src/mame/konami/xexex.cpp b/src/mame/konami/xexex.cpp index af99cbd1421..09288378674 100644 --- a/src/mame/konami/xexex.cpp +++ b/src/mame/konami/xexex.cpp @@ -733,10 +733,9 @@ void xexex_state::xexex(machine_config &config) K054338(config, m_k054338, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, m_k054321, "lspeaker", "rspeaker"); + K054321(config, m_k054321, "speaker"); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(32'000'000)/8)); // 4MHz ymsnd.add_route(0, "filter1_l", 0.2); @@ -746,15 +745,15 @@ void xexex_state::xexex(machine_config &config) K054539(config, m_k054539, XTAL(18'432'000)); m_k054539->set_analog_callback(FUNC(xexex_state::ym_set_mixing)); - m_k054539->add_route(0, "lspeaker", 0.4); - m_k054539->add_route(0, "rspeaker", 0.4); - m_k054539->add_route(1, "lspeaker", 0.4); - m_k054539->add_route(1, "rspeaker", 0.4); - - FILTER_VOLUME(config, "filter1_l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "filter1_r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "filter2_l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "filter2_r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_k054539->add_route(0, "speaker", 0.4, 0); + m_k054539->add_route(0, "speaker", 0.4, 1); + m_k054539->add_route(1, "speaker", 0.4, 0); + m_k054539->add_route(1, "speaker", 0.4, 1); + + FILTER_VOLUME(config, "filter1_l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "filter1_r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "filter2_l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "filter2_r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/konami/xmen.cpp b/src/mame/konami/xmen.cpp index 7a09275d6cc..ea03294fd77 100644 --- a/src/mame/konami/xmen.cpp +++ b/src/mame/konami/xmen.cpp @@ -662,16 +662,15 @@ void xmen_state::sound_hardware(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &xmen_state::sound_map); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - K054321(config, "k054321", "lspeaker", "rspeaker"); + K054321(config, "k054321", "speaker"); - YM2151(config, "ymsnd", XTAL(16'000'000) / 4).add_route(0, "lspeaker", 0.20).add_route(1, "rspeaker", 0.20); // verified on PCB + YM2151(config, "ymsnd", XTAL(16'000'000) / 4).add_route(0, "speaker", 0.20, 1).add_route(1, "speaker", 0.20, 0); // verified on PCB k054539_device &k054539(K054539(config, "k054539", XTAL(18'432'000))); - k054539.add_route(0, "rspeaker", 1.00); - k054539.add_route(1, "lspeaker", 1.00); + k054539.add_route(0, "speaker", 1.00, 1); + k054539.add_route(1, "speaker", 1.00, 0); } void xmen_state::bootleg_sound_hardware(machine_config &config) diff --git a/src/mame/konami/zr107.cpp b/src/mame/konami/zr107.cpp index 3df56517c8f..8d3eb6486eb 100644 --- a/src/mame/konami/zr107.cpp +++ b/src/mame/konami/zr107.cpp @@ -780,19 +780,18 @@ void zr107_state::zr107(machine_config &config) K056800(config, m_k056800, XTAL(18'432'000)); m_k056800->int_callback().set_inputline(m_audiocpu, M68K_IRQ_1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); k054539_device &k054539_1(K054539(config, "k054539_1", XTAL(18'432'000))); k054539_1.set_device_rom_tag("k054539"); k054539_1.timer_handler().set(FUNC(zr107_state::k054539_irq_gen)); - k054539_1.add_route(0, "lspeaker", 0.75); - k054539_1.add_route(1, "rspeaker", 0.75); + k054539_1.add_route(0, "speaker", 0.75, 0); + k054539_1.add_route(1, "speaker", 0.75, 1); k054539_device &k054539_2(K054539(config, "k054539_2", XTAL(18'432'000))); k054539_2.set_device_rom_tag("k054539"); - k054539_2.add_route(0, "lspeaker", 0.75); - k054539_2.add_route(1, "rspeaker", 0.75); + k054539_2.add_route(0, "speaker", 0.75, 0); + k054539_2.add_route(1, "speaker", 0.75, 1); adc0838_device &adc(ADC0838(config, "adc0838")); adc.set_input_callback(FUNC(zr107_state::adc0838_callback)); diff --git a/src/mame/korg/korgds8.cpp b/src/mame/korg/korgds8.cpp index 412c259fe5e..d93c5347aba 100644 --- a/src/mame/korg/korgds8.cpp +++ b/src/mame/korg/korgds8.cpp @@ -233,12 +233,11 @@ void korg_ds8_state::ds8(machine_config &config) lcdc.set_lcd_size(2, 40); lcdc.set_pixel_update_cb(FUNC(korg_ds8_state::lcd_pixel_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2164_device &fm(YM2164(config, "fm", 3.579545_MHz_XTAL)); // YM2164 + YM3012 - fm.add_route(0, "lspeaker", 1.00); - fm.add_route(1, "rspeaker", 1.00); + fm.add_route(0, "speaker", 1.00, 0); + fm.add_route(1, "speaker", 1.00, 1); } void korg_ds8_state::korg707(machine_config &config) diff --git a/src/mame/korg/korgz3.cpp b/src/mame/korg/korgz3.cpp index 812e1ade33d..18aea46b973 100644 --- a/src/mame/korg/korgz3.cpp +++ b/src/mame/korg/korgz3.cpp @@ -128,12 +128,11 @@ void korgz3_state::korgz3(machine_config &config) M58990(config, m_adc, 1'000'000); // M58990P-1 - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2414_device &ymsnd(YM2414(config, "ymsnd", 3'579'545)); // YM2414B - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); } ROM_START(korgz3) diff --git a/src/mame/korg/polysix.cpp b/src/mame/korg/polysix.cpp index bb2475eb4ad..a20e73843d2 100644 --- a/src/mame/korg/polysix.cpp +++ b/src/mame/korg/polysix.cpp @@ -40,7 +40,7 @@ public: u8 get_control_low(); - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual void device_start() override; virtual void device_reset() override; @@ -358,9 +358,9 @@ u8 polysix_sound_block::get_control_low() } // #*#*#*#*#*#*#*# -void polysix_sound_block::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void polysix_sound_block::sound_stream_update(sound_stream &stream) { - for(int sample=0; sample != outputs[0].samples(); sample++) { + for(int sample=0; sample != stream.samples(); sample++) { // u8 trigger = m_gates & ~m_current_gates; float out = 0; @@ -416,7 +416,7 @@ void polysix_sound_block::sound_stream_update(sound_stream &stream, std::vector< } m_current_gates = m_gates; - outputs[0].put_clamp(sample, out/2); + stream.put(0, sample, out/2); } } diff --git a/src/mame/kurzweil/krz2000.cpp b/src/mame/kurzweil/krz2000.cpp index 9b445d59678..0f5c2422c21 100644 --- a/src/mame/kurzweil/krz2000.cpp +++ b/src/mame/kurzweil/krz2000.cpp @@ -368,8 +368,7 @@ void k2000_state::k2000(machine_config &config) LM24014H(config, "lcd"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void k2000_state::k2000_palette(palette_device &palette) const diff --git a/src/mame/leapfrog/leapster_explorer.cpp b/src/mame/leapfrog/leapster_explorer.cpp index ab4fd6f484c..564a74a918d 100644 --- a/src/mame/leapfrog/leapster_explorer.cpp +++ b/src/mame/leapfrog/leapster_explorer.cpp @@ -91,8 +91,7 @@ void leapfrog_leapster_explorer_state::leapfrog_leapster_explorer(machine_config m_screen->set_visarea(0, 320 - 1, 0, 240 - 1); m_screen->set_screen_update(FUNC(leapfrog_leapster_explorer_state::screen_update_innotab)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "leapfrog_leapster_explorer_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/linn/linndrum.cpp b/src/mame/linn/linndrum.cpp index e4385a820e5..1f2b1c6c0da 100644 --- a/src/mame/linn/linndrum.cpp +++ b/src/mame/linn/linndrum.cpp @@ -270,8 +270,7 @@ private: required_device_array<filter_rc_device, NUM_MIXER_CHANNELS> m_voice_hpf; required_device<mixer_device> m_left_mixer; // 4558 op-amp (U1A). required_device<mixer_device> m_right_mixer; // 4558 op-amp (U1B). - required_device<speaker_device> m_left_out; // 4558 op-amp (U2A). - required_device<speaker_device> m_right_out; // 4558 op-amp (U2B). + required_device<speaker_device> m_out; // 4558 op-amp (U2A, U2B). static constexpr const float MIXER_R_PRE_FADER[NUM_MIXER_CHANNELS] = { @@ -379,8 +378,7 @@ linndrum_audio_device::linndrum_audio_device(const machine_config &mconfig, cons , m_voice_hpf(*this, "voice_hpf_%u", 1) , m_left_mixer(*this, "lmixer") , m_right_mixer(*this, "rmixer") - , m_left_out(*this, "lspeaker") - , m_right_out(*this, "rspeaker") + , m_out(*this, "speaker") { } @@ -669,11 +667,10 @@ void linndrum_audio_device::device_add_mconfig(machine_config &config) m_left_mixer->add_route(0, left_rc, 1.0); m_right_mixer->add_route(0, right_rc, 1.0); - SPEAKER(config, m_left_out).front_left(); - SPEAKER(config, m_right_out).front_right(); + SPEAKER(config, m_out, 2).front(); // Gain will be set in update_master_volume(). - left_rc.add_route(0, m_left_out, 1.0); - right_rc.add_route(0, m_right_out, 1.0); + left_rc.add_route(0, m_out, 1.0, 0); + right_rc.add_route(0, m_out, 1.0, 1); } void linndrum_audio_device::device_start() @@ -911,8 +908,8 @@ void linndrum_audio_device::update_master_volume() const float final_gain = gain * VOLTAGE_TO_SOUND_SCALER; // Using -final_gain, because the output opamps (U2A, U2B) are inverting. - m_left_out->set_input_gain(0, -final_gain); - m_right_out->set_input_gain(0, -final_gain); + m_out->set_input_gain(0, -final_gain); + m_out->set_input_gain(1, -final_gain); LOGMASKED(LOG_MIX, "Master volume updated. Gain: %f, final gain: %f\n", gain, final_gain); } diff --git a/src/mame/maygay/maygay1b.cpp b/src/mame/maygay/maygay1b.cpp index 3f327e3c321..31162e624a5 100644 --- a/src/mame/maygay/maygay1b.cpp +++ b/src/mame/maygay/maygay1b.cpp @@ -743,21 +743,20 @@ void maygay1b_state::maygay_m1(machine_config &config) mainlatch.q_out_cb<6>().set(FUNC(maygay1b_state::srsel_w)); // Srsel S16LF01(config, m_vfd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2149(config, m_ay, M1_MASTER_CLOCK); m_ay->port_a_write_callback().set(FUNC(maygay1b_state::m1_meter_w)); m_ay->port_b_write_callback().set(FUNC(maygay1b_state::m1_lockout_w)); - m_ay->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_ay->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_ay->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_ay->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); ym2413_device &ymsnd(YM2413(config, "ymsnd", M1_MASTER_CLOCK/4)); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); OKIM6376(config, m_msm6376, 102400); //? Seems to work well with samples, but unconfirmed - m_msm6376->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_msm6376->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_msm6376->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_msm6376->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); TIMER(config, "nmitimer").configure_periodic(FUNC(maygay1b_state::maygay1b_nmitimer_callback), attotime::from_hz(75)); // freq? @@ -807,8 +806,8 @@ void maygay1b_state::maygay_m1_nec(machine_config &config) config.device_remove("msm6376"); UPD7759(config, m_upd7759); - m_upd7759->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_upd7759->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void maygay1b_state::m1ab_no_oki_w(uint8_t data) diff --git a/src/mame/metro/metro.cpp b/src/mame/metro/metro.cpp index 60f94cfdf70..d20cba7d9f8 100644 --- a/src/mame/metro/metro.cpp +++ b/src/mame/metro/metro.cpp @@ -3478,18 +3478,17 @@ void blzntrnd_state::blzntrnd(machine_config &config) // sound hardware // HUM-002 PCB Configuration : Stereo output with second speaker connector - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2610_device &ymsnd(YM2610(config, m_ymsnd, 16_MHz_XTAL/2)); ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void blzntrnd_state::gstrik2(machine_config &config) @@ -3504,8 +3503,7 @@ void blzntrnd_state::gstrik2(machine_config &config) m_vdp2->set_tmap_xoffsets(0,8,0); // HUM-003 PCB Configuration : Mono output only - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); SPEAKER(config, "mono").front_center(); ym2610_device &ymsnd(YM2610(config.replace(), m_ymsnd, 16_MHz_XTAL/2)); diff --git a/src/mame/metro/rabbit.cpp b/src/mame/metro/rabbit.cpp index 6df9428a83f..911cfe7e19b 100644 --- a/src/mame/metro/rabbit.cpp +++ b/src/mame/metro/rabbit.cpp @@ -900,12 +900,11 @@ void rabbit_state::rabbit(machine_config &config) PALETTE(config, m_palette, palette_device::BLACK).set_format(palette_device::xGRB_888, 0x4000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); i5000snd_device &i5000snd(I5000_SND(config, "i5000snd", XTAL(40'000'000))); - i5000snd.add_route(0, "rspeaker", 1.0); - i5000snd.add_route(1, "lspeaker", 1.0); + i5000snd.add_route(0, "speaker", 1.0, 1); + i5000snd.add_route(1, "speaker", 1.0, 0); } diff --git a/src/mame/metro/tmmjprd.cpp b/src/mame/metro/tmmjprd.cpp index 53a8426102b..e132d98afc3 100644 --- a/src/mame/metro/tmmjprd.cpp +++ b/src/mame/metro/tmmjprd.cpp @@ -757,12 +757,11 @@ void tmmjprd_state::tmpdoki(machine_config &config) lscreen.set_palette(m_palette); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); i5000snd_device &i5000snd(I5000_SND(config, "i5000snd", XTAL(40'000'000))); - i5000snd.add_route(0, "rspeaker", 1.0); - i5000snd.add_route(1, "lspeaker", 1.0); + i5000snd.add_route(0, "speaker", 1.0, 1); + i5000snd.add_route(1, "speaker", 1.0, 0); } void tmmjprd_state::tmmjprd(machine_config &config) diff --git a/src/mame/midw8080/mw8080bw_a.cpp b/src/mame/midw8080/mw8080bw_a.cpp index 6c5bdac4f45..7cae8111fdf 100644 --- a/src/mame/midw8080/mw8080bw_a.cpp +++ b/src/mame/midw8080/mw8080bw_a.cpp @@ -775,14 +775,13 @@ void gunfight_audio_device::write(u8 data) void gunfight_audio_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); netlist_mame_sound_device &nl_sound = NETLIST_SOUND(config, "sound_nl", 48000) .set_source(NETLIST_NAME(gunfight)); - nl_sound.add_route(0, "lspeaker", 0.5); - nl_sound.add_route(1, "rspeaker", 0.5); + nl_sound.add_route(0, "speaker", 0.5, 0); + nl_sound.add_route(1, "speaker", 0.5, 1); NETLIST_LOGIC_INPUT(config, "sound_nl:left_shot", "I_LEFT_SHOT.IN", 0); NETLIST_LOGIC_INPUT(config, "sound_nl:right_shot", "I_RIGHT_SHOT.IN", 0); @@ -1060,12 +1059,11 @@ void boothill_audio_device::write(u8 data) void boothill_audio_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DISCRETE(config, m_discrete, boothill_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } ioport_constructor boothill_audio_device::device_input_ports() const @@ -1659,18 +1657,17 @@ void gmissile_audio_device::device_add_mconfig(machine_config &config) "2", // explosion nullptr }; - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAMPLES(config, m_samples[0]); m_samples[0]->set_channels(1); m_samples[0]->set_samples_names(sample_names); - m_samples[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + m_samples[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); SAMPLES(config, m_samples[1]); m_samples[1]->set_channels(1); m_samples[1]->set_samples_names(sample_names); - m_samples[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_samples[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void gmissile_audio_device::device_start() @@ -1745,18 +1742,17 @@ void m4_audio_device::device_add_mconfig(machine_config &config) "2", // explosion nullptr }; - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAMPLES(config, m_samples[0]); m_samples[0]->set_channels(2); m_samples[0]->set_samples_names(sample_names); - m_samples[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + m_samples[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); SAMPLES(config, m_samples[1]); m_samples[1]->set_channels(2); m_samples[1]->set_samples_names(sample_names); - m_samples[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_samples[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void m4_audio_device::device_start() @@ -2557,12 +2553,11 @@ void dogpatch_audio_device::write(u8 data) void dogpatch_audio_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DISCRETE(config, m_discrete, dogpatch_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } void dogpatch_audio_device::device_start() diff --git a/src/mame/midway/astrocde.cpp b/src/mame/midway/astrocde.cpp index 2eb4fabfa81..551d14f46db 100644 --- a/src/mame/midway/astrocde.cpp +++ b/src/mame/midway/astrocde.cpp @@ -1257,15 +1257,14 @@ void astrocde_state::astrocade_mono_sound(machine_config &config) void astrocde_state::astrocade_stereo_sound(machine_config &config) { /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ASTROCADE_IO(config, m_astrocade_sound[0], ASTROCADE_CLOCK/4); m_astrocade_sound[0]->si_cb().set(FUNC(astrocde_state::input_mux_r)); m_astrocade_sound[0]->so_cb<0>().set("watchdog", FUNC(watchdog_timer_device::reset_w)); - m_astrocade_sound[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.35); + m_astrocade_sound[0]->add_route(ALL_OUTPUTS, "speaker", 0.35, 0); - ASTROCADE_IO(config, m_astrocade_sound[1], ASTROCADE_CLOCK/4).add_route(ALL_OUTPUTS, "rspeaker", 0.35); + ASTROCADE_IO(config, m_astrocade_sound[1], ASTROCADE_CLOCK/4).add_route(ALL_OUTPUTS, "speaker", 0.35, 1); WATCHDOG_TIMER(config, "watchdog").set_vblank_count("screen", 128); // MC14024B on CPU board at U18, CLK = VERTDR, Q7 used for RESET } @@ -1305,22 +1304,21 @@ void seawolf2_state::seawolf2(machine_config &config) lamplatch1.bit_handler<5>().set_output("lamp7"); // left player explosion (hit) /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAMPLES(config, m_samples); m_samples->set_channels(10); /* 5*2 channels */ m_samples->set_samples_names(seawolf_sample_names); - m_samples->add_route(0, "lspeaker", 0.25); - m_samples->add_route(1, "lspeaker", 0.25); - m_samples->add_route(2, "lspeaker", 0.25); - m_samples->add_route(3, "lspeaker", 0.25); - m_samples->add_route(4, "lspeaker", 0.25); - m_samples->add_route(5, "rspeaker", 0.25); - m_samples->add_route(6, "rspeaker", 0.25); - m_samples->add_route(7, "rspeaker", 0.25); - m_samples->add_route(8, "rspeaker", 0.25); - m_samples->add_route(9, "rspeaker", 0.25); + m_samples->add_route(0, "speaker", 0.25, 0); + m_samples->add_route(1, "speaker", 0.25, 0); + m_samples->add_route(2, "speaker", 0.25, 0); + m_samples->add_route(3, "speaker", 0.25, 0); + m_samples->add_route(4, "speaker", 0.25, 0); + m_samples->add_route(5, "speaker", 0.25, 1); + m_samples->add_route(6, "speaker", 0.25, 1); + m_samples->add_route(7, "speaker", 0.25, 1); + m_samples->add_route(8, "speaker", 0.25, 1); + m_samples->add_route(9, "speaker", 0.25, 1); } void ebases_state::ebases(machine_config &config) diff --git a/src/mame/midway/atlantis.cpp b/src/mame/midway/atlantis.cpp index 446da68446c..6f0770f5ce8 100644 --- a/src/mame/midway/atlantis.cpp +++ b/src/mame/midway/atlantis.cpp @@ -839,15 +839,14 @@ void atlantis_state::mwskins(machine_config &config) m_screen->set_screen_update("zeus2", FUNC(zeus2_device::screen_update)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_DENVER_2CH(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0xe33); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); diff --git a/src/mame/midway/gridlee.h b/src/mame/midway/gridlee.h index 24c4c788d2a..cd6bc26c14c 100644 --- a/src/mame/midway/gridlee.h +++ b/src/mame/midway/gridlee.h @@ -101,7 +101,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: void gridlee_sound_w(offs_t offset, uint8_t data); diff --git a/src/mame/midway/gridlee_a.cpp b/src/mame/midway/gridlee_a.cpp index e9f38afd7d4..438e4f71153 100644 --- a/src/mame/midway/gridlee_a.cpp +++ b/src/mame/midway/gridlee_a.cpp @@ -53,16 +53,14 @@ void gridlee_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void gridlee_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gridlee_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - /* loop over samples */ - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /* tone channel */ m_tone_fraction += m_tone_step; - buffer.put_int(sampindex, (m_tone_fraction & 0x0800000) ? m_tone_volume : 0, 32768 >> 6); + stream.put_int(0, sampindex, (m_tone_fraction & 0x0800000) ? m_tone_volume : 0, 32768 >> 6); } } diff --git a/src/mame/midway/mcr.cpp b/src/mame/midway/mcr.cpp index d32228a9d9b..4e5c457b474 100644 --- a/src/mame/midway/mcr.cpp +++ b/src/mame/midway/mcr.cpp @@ -1801,11 +1801,10 @@ void mcr_state::mcr_90009(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRBG_444, 32); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MIDWAY_SSIO(config, m_ssio); - m_ssio->add_route(0, "lspeaker", 1.0); - m_ssio->add_route(1, "rspeaker", 1.0); + m_ssio->add_route(0, "speaker", 1.0, 0); + m_ssio->add_route(1, "speaker", 1.0, 1); } /* as above, but in a casino cabinet */ @@ -1843,8 +1842,8 @@ void mcr_state::mcr_90010_tt(machine_config &config) SAMPLES(config, m_samples); m_samples->set_channels(2); m_samples->set_samples_names(twotiger_sample_names); - m_samples->add_route(0, "lspeaker", 0.25); - m_samples->add_route(1, "rspeaker", 0.25); + m_samples->add_route(0, "speaker", 0.25, 0); + m_samples->add_route(1, "speaker", 0.25, 1); } /* 91475 CPU board plus 90908/90913/91483 sound board plus cassette interface */ @@ -1859,8 +1858,8 @@ void mcr_state::mcr_91475(machine_config &config) SAMPLES(config, m_samples); m_samples->set_channels(1); m_samples->set_samples_names(journey_sample_names); - m_samples->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_samples->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_samples->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + m_samples->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } @@ -1885,8 +1884,8 @@ void mcr_state::mcr_91490_snt(machine_config &config) /* basic machine hardware */ BALLY_SQUAWK_N_TALK(config, m_squawk_n_talk); - m_squawk_n_talk->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_squawk_n_talk->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_squawk_n_talk->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_squawk_n_talk->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } @@ -1926,8 +1925,8 @@ void mcr_state::mcr_91490_tcs(machine_config &config) /* basic machine hardware */ MIDWAY_TURBO_CHEAP_SQUEAK(config, m_turbo_cheap_squeak); - m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/midway/mcr3.cpp b/src/mame/midway/mcr3.cpp index 4bc017a6ff5..f0a9cdc44c3 100644 --- a/src/mame/midway/mcr3.cpp +++ b/src/mame/midway/mcr3.cpp @@ -1099,8 +1099,7 @@ void mcr3_state::mcrmono(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); @@ -1127,8 +1126,8 @@ void mcr3_state::mono_tcs(machine_config &config) /* basic machine hardware */ MIDWAY_TURBO_CHEAP_SQUEAK(config, m_turbo_cheap_squeak); - m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "lspeaker", 0.8); - m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "rspeaker", 0.8); + m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "speaker", 0.8, 0); + m_turbo_cheap_squeak->add_route(ALL_OUTPUTS, "speaker", 0.8, 1); } void maxrpm_state::maxrpm(machine_config &config) @@ -1150,8 +1149,8 @@ void mcr3_state::mono_sg(machine_config &config) /* basic machine hardware */ MIDWAY_SOUNDS_GOOD(config, m_sounds_good); - m_sounds_good->add_route(ALL_OUTPUTS, "lspeaker", 0.75); - m_sounds_good->add_route(ALL_OUTPUTS, "rspeaker", 0.75); + m_sounds_good->add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + m_sounds_good->add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } @@ -1165,8 +1164,8 @@ void mcr3_state::mcrscroll(machine_config &config) /* basic machine hardware */ MIDWAY_SSIO(config, m_ssio); - m_ssio->add_route(0, "lspeaker", 1.0); - m_ssio->add_route(1, "rspeaker", 1.0); + m_ssio->add_route(0, "speaker", 1.0, 0); + m_ssio->add_route(1, "speaker", 1.0, 1); m_maincpu->set_addrmap(AS_PROGRAM, &mcr3_state::spyhunt_map); m_maincpu->set_addrmap(AS_IO, &mcr3_state::spyhunt_portmap); @@ -1189,8 +1188,8 @@ void mcrsc_csd_state::mcrsc_csd(machine_config &config) /* basic machine hardware */ MIDWAY_CHEAP_SQUEAK_DELUXE(config, m_cheap_squeak_deluxe); - m_cheap_squeak_deluxe->add_route(ALL_OUTPUTS, "lspeaker", 0.8); - m_cheap_squeak_deluxe->add_route(ALL_OUTPUTS, "rspeaker", 0.8); + m_cheap_squeak_deluxe->add_route(ALL_OUTPUTS, "speaker", 0.8, 0); + m_cheap_squeak_deluxe->add_route(ALL_OUTPUTS, "speaker", 0.8, 1); CD4099(config, m_lamplatch); // U1 on Lamp Driver Board m_lamplatch->q_out_cb<0>().set_output("lamp0"); diff --git a/src/mame/midway/midvunit.cpp b/src/mame/midway/midvunit.cpp index e084befb51e..1c14a96d257 100644 --- a/src/mame/midway/midvunit.cpp +++ b/src/mame/midway/midvunit.cpp @@ -1231,15 +1231,14 @@ void midvplus_state::midvplus(machine_config &config) m_midway_ioasic->set_yearoffs(94); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x3839); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); } diff --git a/src/mame/midway/midway.cpp b/src/mame/midway/midway.cpp index c32a0ea9c36..1ef870501ef 100644 --- a/src/mame/midway/midway.cpp +++ b/src/mame/midway/midway.cpp @@ -45,7 +45,7 @@ DEFINE_DEVICE_TYPE(MIDWAY_TURBO_CHEAP_SQUEAK, midway_turbo_cheap_squeak_device, midway_ssio_device::midway_ssio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, MIDWAY_SSIO, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_cpu(*this, "cpu") , m_ay0(*this, "ay0") , m_ay1(*this, "ay1") @@ -410,12 +410,12 @@ void midway_ssio_device::device_add_mconfig(machine_config &config) AY8910(config, m_ay0, DERIVED_CLOCK(1, 2*4)); m_ay0->port_a_write_callback().set(FUNC(midway_ssio_device::porta0_w)); m_ay0->port_b_write_callback().set(FUNC(midway_ssio_device::portb0_w)); - m_ay0->add_route(ALL_OUTPUTS, *this, 0.33, AUTO_ALLOC_INPUT, 0); + m_ay0->add_route(ALL_OUTPUTS, *this, 0.33, 0); AY8910(config, m_ay1, DERIVED_CLOCK(1, 2*4)); m_ay1->port_a_write_callback().set(FUNC(midway_ssio_device::porta1_w)); m_ay1->port_b_write_callback().set(FUNC(midway_ssio_device::portb1_w)); - m_ay1->add_route(ALL_OUTPUTS, *this, 0.33, AUTO_ALLOC_INPUT, 1); + m_ay1->add_route(ALL_OUTPUTS, *this, 0.33, 1); } diff --git a/src/mame/midway/midyunit.cpp b/src/mame/midway/midyunit.cpp index fdc5988c1d2..7b762670f2f 100644 --- a/src/mame/midway/midyunit.cpp +++ b/src/mame/midway/midyunit.cpp @@ -1110,11 +1110,10 @@ void midzunit_state::zunit(machine_config &config) screen.set_palette(m_palette); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); WILLIAMS_NARC_SOUND(config, m_narc_sound); - m_narc_sound->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_narc_sound->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_narc_sound->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_narc_sound->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/midway/midzeus.cpp b/src/mame/midway/midzeus.cpp index a990ca74790..fa7e05ec7aa 100644 --- a/src/mame/midway/midzeus.cpp +++ b/src/mame/midway/midzeus.cpp @@ -1385,13 +1385,12 @@ void midzeus_state::midzeus(machine_config &config) m_screen->set_palette(m_palette); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); dcs2_audio_2104_device &dcs(DCS2_AUDIO_2104(config, "dcs", 0)); dcs.set_maincpu_tag(m_maincpu); - dcs.add_route(0, "rspeaker", 1.0); - dcs.add_route(1, "lspeaker", 1.0); + dcs.add_route(0, "speaker", 1.0, 1); + dcs.add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -1437,13 +1436,12 @@ void midzeus2_state::midzeus2(machine_config &config) m_zeus->irq_callback().set(FUNC(midzeus2_state::zeus_irq)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); dcs2_audio_2104_device &dcs(DCS2_AUDIO_2104(config, "dcs", 0)); dcs.set_maincpu_tag(m_maincpu); - dcs.add_route(0, "rspeaker", 1.0); - dcs.add_route(1, "lspeaker", 1.0); + dcs.add_route(0, "speaker", 1.0, 1); + dcs.add_route(1, "speaker", 1.0, 0); M48T35(config, m_m48t35, 0); diff --git a/src/mame/midway/pinball2k.cpp b/src/mame/midway/pinball2k.cpp index 4da67aac7a2..2f883a80747 100644 --- a/src/mame/midway/pinball2k.cpp +++ b/src/mame/midway/pinball2k.cpp @@ -653,8 +653,7 @@ void pinball2k_state::mediagx(machine_config &config) PALETTE(config, m_palette).set_entries(256); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/midway/seattle.cpp b/src/mame/midway/seattle.cpp index 8d40b30c7fa..09aa71fb2d1 100644 --- a/src/mame/midway/seattle.cpp +++ b/src/mame/midway/seattle.cpp @@ -2119,15 +2119,14 @@ void seattle_state::wg3dh(machine_config &config) { phoenix(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x3839); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2145,15 +2144,14 @@ void seattle_state::mace(machine_config &config) { seattle150(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x3839); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2172,20 +2170,17 @@ void seattle_state::sfrush(machine_config &config) flagstaff(config); // 5 Channel output (4 Channel input connected to Quad Amp PCB) - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); + SPEAKER(config, "speaker", 4).corners(); //SPEAKER(config, "subwoofer").seat(); Not implemented, Quad Amp PCB output; ATARI_CAGE_SEATTLE(config, m_cage, 0); m_cage->set_speedup(0x5236); m_cage->irq_handler().set(m_ioasic, FUNC(midway_ioasic_device::cage_irq_handler)); // TODO: copied from atarigt.cpp; Same configurations as T-Mek? - m_cage->add_route(0, "frspeaker", 1.0); // Foward Right - m_cage->add_route(1, "rlspeaker", 1.0); // Back Left - m_cage->add_route(2, "flspeaker", 1.0); // Foward Left - m_cage->add_route(3, "rrspeaker", 1.0); // Back Right + m_cage->add_route(0, "speaker", 1.0, 1); // Forward Right + m_cage->add_route(1, "speaker", 1.0, 2); // Back Left + m_cage->add_route(2, "speaker", 1.0, 0); // Forward Left + m_cage->add_route(3, "speaker", 1.0, 3); // Back Right MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2205,20 +2200,17 @@ void seattle_state::sfrushrk(machine_config &config) flagstaff(config); // 5 Channel output (4 Channel input connected to Quad Amp PCB) - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); + SPEAKER(config, "speaker", 4).corners(); //SPEAKER(config, "subwoofer").seat(); Not implemented, Quad Amp PCB output; ATARI_CAGE_SEATTLE(config, m_cage, 0); m_cage->set_speedup(0x5329); m_cage->irq_handler().set(m_ioasic, FUNC(midway_ioasic_device::cage_irq_handler)); // TODO: copied from atarigt.cpp; Same configurations as T-Mek? - m_cage->add_route(0, "frspeaker", 1.0); // Foward Right - m_cage->add_route(1, "rlspeaker", 1.0); // Back Left - m_cage->add_route(2, "flspeaker", 1.0); // Foward Left - m_cage->add_route(3, "rrspeaker", 1.0); // Back Right + m_cage->add_route(0, "speaker", 1.0, 1); // Forward Right + m_cage->add_route(1, "speaker", 1.0, 2); // Back Left + m_cage->add_route(2, "speaker", 1.0, 0); // Forward Left + m_cage->add_route(3, "speaker", 1.0, 3); // Back Right MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2243,15 +2235,14 @@ void seattle_state::calspeed(machine_config &config) { seattle150_widget(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x39c0); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2270,15 +2261,14 @@ void seattle_state::vaportrx(machine_config &config) { seattle200_widget(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x39c2); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2296,15 +2286,14 @@ void seattle_state::biofreak(machine_config &config) { seattle150(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x3835); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2322,15 +2311,14 @@ void seattle_state::blitz(machine_config &config) { seattle150(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x39c2); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2349,15 +2337,14 @@ void seattle_state::blitz99(machine_config &config) { seattle150(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x0afb); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2376,15 +2363,14 @@ void seattle_state::blitz2k(machine_config &config) { seattle150(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2404,15 +2390,14 @@ void seattle_state::carnevil(machine_config &config) seattle150(config); m_galileo->set_map(3, address_map_constructor(&seattle_state::carnevil_cs3_map, "carnevil_cs3_map", this), this); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x0af7); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2430,15 +2415,14 @@ void seattle_state::hyprdriv(machine_config &config) { seattle200_widget(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(2); m_dcs->set_polling_offset(0x0af7); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); diff --git a/src/mame/midway/vegas.cpp b/src/mame/midway/vegas.cpp index 0870ed2cdbc..603f8e4b946 100644 --- a/src/mame/midway/vegas.cpp +++ b/src/mame/midway/vegas.cpp @@ -2021,15 +2021,14 @@ void vegas_state::gauntleg(machine_config &config) // Firmware frequency detection seems to have a bug, console reports 220MHz for a 200MHz cpu and 260MHz for a 250MHz cpu vegas250(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2049,15 +2048,14 @@ void vegas_state::gauntdl(machine_config &config) // Needs 250MHz MIPS or screen tearing occurs (See MT8064) vegas250(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2076,15 +2074,14 @@ void vegas_state::warfa(machine_config &config) { vegas250(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2103,15 +2100,14 @@ void vegas_state::tenthdeg(machine_config &config) { vegas(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2115(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0afb); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2130,15 +2126,14 @@ void vegas_state::roadburn(machine_config &config) { vegas32m(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_DSIO(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0ddd); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2157,15 +2152,14 @@ void vegas_state::nbashowt(machine_config &config) { vegasban(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2186,15 +2180,14 @@ void vegas_state::nbanfl(machine_config &config) { vegasban(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2220,15 +2213,14 @@ void vegas_state::nbagold(machine_config &config) m_maincpu->set_system_clock(vegas_state::SYSTEM_CLOCK); m_nile->set_sdram_size(0, 0x00800000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2248,21 +2240,17 @@ void vegas_state::sf2049(machine_config &config) { denver(config); - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); - SPEAKER(config, "subwoofer").backrest(); + SPEAKER(config, "speaker", 5).front().headrest_left(2).headrest_right(3).backrest(4); DCS2_AUDIO_DENVER_5CH(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(8); m_dcs->set_polling_offset(0x872); - m_dcs->add_route(0, "flspeaker", 1.0); - m_dcs->add_route(1, "frspeaker", 1.0); - m_dcs->add_route(2, "rlspeaker", 1.0); - m_dcs->add_route(3, "rrspeaker", 1.0); - m_dcs->add_route(4, "subwoofer", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 0); + m_dcs->add_route(1, "speaker", 1.0, 1); + m_dcs->add_route(2, "speaker", 1.0, 2); + m_dcs->add_route(3, "speaker", 1.0, 3); + m_dcs->add_route(4, "speaker", 1.0, 4); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2282,21 +2270,17 @@ void vegas_state::sf2049se(machine_config &config) { denver(config); - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); - SPEAKER(config, "subwoofer").backrest(); + SPEAKER(config, "speaker", 5).front().headrest_left(2).headrest_right(3).backrest(4); DCS2_AUDIO_DENVER_5CH(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(8); m_dcs->set_polling_offset(0x872); - m_dcs->add_route(0, "flspeaker", 1.0); - m_dcs->add_route(1, "frspeaker", 1.0); - m_dcs->add_route(2, "rlspeaker", 1.0); - m_dcs->add_route(3, "rrspeaker", 1.0); - m_dcs->add_route(4, "subwoofer", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 0); + m_dcs->add_route(1, "speaker", 1.0, 1); + m_dcs->add_route(2, "speaker", 1.0, 2); + m_dcs->add_route(3, "speaker", 1.0, 3); + m_dcs->add_route(4, "speaker", 1.0, 4); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2316,21 +2300,17 @@ void vegas_state::sf2049te(machine_config &config) { denver(config); - SPEAKER(config, "flspeaker").front_left(); - SPEAKER(config, "frspeaker").front_right(); - SPEAKER(config, "rlspeaker").headrest_left(); - SPEAKER(config, "rrspeaker").headrest_right(); - SPEAKER(config, "subwoofer").backrest(); + SPEAKER(config, "speaker", 5).front().headrest_left(2).headrest_right(3).backrest(4); DCS2_AUDIO_DENVER_5CH(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(8); m_dcs->set_polling_offset(0x872); - m_dcs->add_route(0, "flspeaker", 1.0); - m_dcs->add_route(1, "frspeaker", 1.0); - m_dcs->add_route(2, "rlspeaker", 1.0); - m_dcs->add_route(3, "rrspeaker", 1.0); - m_dcs->add_route(4, "subwoofer", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 0); + m_dcs->add_route(1, "speaker", 1.0, 1); + m_dcs->add_route(2, "speaker", 1.0, 2); + m_dcs->add_route(3, "speaker", 1.0, 3); + m_dcs->add_route(4, "speaker", 1.0, 4); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); @@ -2350,15 +2330,14 @@ void vegas_state::cartfury(machine_config &config) { vegasv3(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DCS2_AUDIO_2104(config, m_dcs, 0); m_dcs->set_maincpu_tag(m_maincpu); m_dcs->set_dram_in_mb(4); m_dcs->set_polling_offset(0x0b5d); - m_dcs->add_route(0, "rspeaker", 1.0); - m_dcs->add_route(1, "lspeaker", 1.0); + m_dcs->add_route(0, "speaker", 1.0, 1); + m_dcs->add_route(1, "speaker", 1.0, 0); MIDWAY_IOASIC(config, m_ioasic, 0); m_ioasic->in_port_cb<0>().set_ioport("DIPS"); diff --git a/src/mame/midway/williams.cpp b/src/mame/midway/williams.cpp index 33cb34d7fc0..df483f85db5 100644 --- a/src/mame/midway/williams.cpp +++ b/src/mame/midway/williams.cpp @@ -1704,7 +1704,7 @@ void williams_state::sinistar_cockpit(machine_config &config) // additional sound hardware SPEAKER(config, "rspeaker").rear_center(); - MC1408(config, "rdac").add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + MC1408(config, "rdac").add_route(ALL_OUTPUTS, "rspeaker", 0.25, 1); // unknown DAC // pia INPUT_MERGER_ANY_HIGH(config, "soundirq_b").output_handler().set_inputline("soundcpu_b", M6808_IRQ_LINE); @@ -1814,10 +1814,9 @@ void blaster_state::blaster(machine_config &config) config.device_remove("speaker"); config.device_remove("dac"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - MC1408(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); // unknown DAC - MC1408(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + MC1408(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); // unknown DAC + MC1408(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC } diff --git a/src/mame/miltonbradley/milton6805.cpp b/src/mame/miltonbradley/milton6805.cpp index e7c5f21dd56..6fb89baba0d 100644 --- a/src/mame/miltonbradley/milton6805.cpp +++ b/src/mame/miltonbradley/milton6805.cpp @@ -86,7 +86,7 @@ public: protected: virtual void device_start() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream = nullptr; @@ -108,20 +108,20 @@ void milton_filter_device::device_start() m_led_out.resolve(); } -void milton_filter_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void milton_filter_device::sound_stream_update(sound_stream &stream) { - stream_buffer::sample_t level = 0; + sound_stream::sample_t level = 0; - for (int i = 0; i < outputs[0].samples(); i++) - level += fabsf(inputs[0].get(i)); + for (int i = 0; i < stream.samples(); i++) + level += fabsf(stream.get(0, i)); - outputs[0] = inputs[0]; + stream.copy(0, 0); - if (outputs[0].samples() > 0) - level /= outputs[0].samples(); + if (stream.samples() > 0) + level /= stream.samples(); // 2 leds connected to the audio circuit - const stream_buffer::sample_t threshold = 1500.0 / 32768.0; + const sound_stream::sample_t threshold = 1500.0 / 32768.0; m_led_out = (level > threshold) ? 1 : 0; } diff --git a/src/mame/misc/amspdwy.cpp b/src/mame/misc/amspdwy.cpp index 06e841ef09e..b1ea7cac4f9 100644 --- a/src/mame/misc/amspdwy.cpp +++ b/src/mame/misc/amspdwy.cpp @@ -465,16 +465,15 @@ void amspdwy_state::amspdwy(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::BGR_233_inverted, 32); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); YM2151(config, m_ym2151, 3000000); m_ym2151->irq_handler().set_inputline(m_audiocpu, 0); - m_ym2151->add_route(0, "lspeaker", 1.0); - m_ym2151->add_route(1, "rspeaker", 1.0); + m_ym2151->add_route(0, "speaker", 1.0, 0); + m_ym2151->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/misc/amuzy.cpp b/src/mame/misc/amuzy.cpp index 014f09c4b07..97c61725221 100644 --- a/src/mame/misc/amuzy.cpp +++ b/src/mame/misc/amuzy.cpp @@ -298,12 +298,11 @@ void amuzy_state::amuzy(machine_config &config) TIMER(config, "scantimer").configure_scanline(FUNC(amuzy_state::scanline), m_screen, 0, 1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM9810(config, m_oki, XTAL(4'096'000)); - m_oki->add_route(0, "lspeaker", 1.00); - m_oki->add_route(1, "rspeaker", 1.00); + m_oki->add_route(0, "speaker", 1.00, 0); + m_oki->add_route(1, "speaker", 1.00, 1); } static INPUT_PORTS_START( amuzy ) diff --git a/src/mame/misc/belatra.cpp b/src/mame/misc/belatra.cpp index 5495b58e449..e96280ec7da 100644 --- a/src/mame/misc/belatra.cpp +++ b/src/mame/misc/belatra.cpp @@ -147,8 +147,7 @@ void belatra_state::belatra(machine_config &config) // AT90S2313(config, "mcu", xxxx); // TODO: AVR 8-bit core, only the fairyl2 set has a dump - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // unknown sound } diff --git a/src/mame/misc/brglitz.cpp b/src/mame/misc/brglitz.cpp index 16a0bc0ab90..c858923593e 100644 --- a/src/mame/misc/brglitz.cpp +++ b/src/mame/misc/brglitz.cpp @@ -142,16 +142,15 @@ void brglitz_state::brglitz(machine_config &config) PIC16C55(config, m_soundcpu, 8_MHz_XTAL); // Divider unknown, ZTA 8.00MT resonator PIC16C55(config, m_soundcpu_2, 8_MHz_XTAL); // Divider unknown, ZTA 8.00MT resonator - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); msm6585_device &oki1(MSM6585(config, "oki1", 640_kHz_XTAL)); // CSB 640 P resonator - oki1.add_route(ALL_OUTPUTS, "lspeaker", 0.45); // Guess - oki1.add_route(ALL_OUTPUTS, "rspeaker", 0.45); // Guess + oki1.add_route(ALL_OUTPUTS, "speaker", 0.45, 0); // Guess + oki1.add_route(ALL_OUTPUTS, "speaker", 0.45, 1); // Guess msm6585_device &oki2(MSM6585(config, "oki2", 640_kHz_XTAL)); // CSB 640 P resonator - oki2.add_route(ALL_OUTPUTS, "lspeaker", 0.45); // Guess - oki2.add_route(ALL_OUTPUTS, "rspeaker", 0.45); // Guess + oki2.add_route(ALL_OUTPUTS, "speaker", 0.45, 0); // Guess + oki2.add_route(ALL_OUTPUTS, "speaker", 0.45, 1); // Guess } ROM_START(brglitz) diff --git a/src/mame/misc/cardline.cpp b/src/mame/misc/cardline.cpp index 347d5b7b34d..0e53214fd66 100644 --- a/src/mame/misc/cardline.cpp +++ b/src/mame/misc/cardline.cpp @@ -352,12 +352,11 @@ void cardline_state::cardline(machine_config &config) config.set_default_layout(layout_cardline); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", 1056000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } /*************************************************************************** diff --git a/src/mame/misc/coinmvga.cpp b/src/mame/misc/coinmvga.cpp index 48fa2fcb823..d8685672ebc 100644 --- a/src/mame/misc/coinmvga.cpp +++ b/src/mame/misc/coinmvga.cpp @@ -686,13 +686,12 @@ void coinmvga_state::coinmvga(machine_config &config) ramdac2.set_addrmap(0, &coinmvga_state::ramdac2_map); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", SND_CLOCK)); ymz.irq_handler().set_inputline("maincpu", 2); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/misc/cowtipping.cpp b/src/mame/misc/cowtipping.cpp index 73bb30b3861..0002f7d41be 100644 --- a/src/mame/misc/cowtipping.cpp +++ b/src/mame/misc/cowtipping.cpp @@ -99,8 +99,7 @@ void cowtipping_state::cowtipping(machine_config &config) PALETTE(config, "palette").set_entries(65536); // wrong - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/misc/cubeqst.cpp b/src/mame/misc/cubeqst.cpp index 79397b29611..c4b82fcc2c1 100644 --- a/src/mame/misc/cubeqst.cpp +++ b/src/mame/misc/cubeqst.cpp @@ -556,19 +556,18 @@ void cubeqst_state::cubeqst(machine_config &config) m_screen->set_screen_update("laserdisc", FUNC(laserdisc_device::screen_update)); m_screen->screen_vblank().set(FUNC(cubeqst_state::vblank_irq)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); for (int i = 0; i < 8; i++) { // AD7521JN.2D (59) + CD4051BE.3D (24) + 1500pF.C6-C13 (34) + TL074CN.3B/3C (53) + 10K.RN3/4 (30) - AD7521(config, m_ldacs[i]).add_route(0, "lspeaker", 0.125); + AD7521(config, m_ldacs[i]).add_route(0, "speaker", 0.125, 0); // AD7521JN.2D (59) + CD4051BE.1D (24) + 1500pF.C15-C22 (34) + TL074CN.1B/1C (53) + 10K.RN1/2 (30) - AD7521(config, m_rdacs[i]).add_route(0, "rspeaker", 0.125); + AD7521(config, m_rdacs[i]).add_route(0, "speaker", 0.125, 1); } } diff --git a/src/mame/misc/cupidon.cpp b/src/mame/misc/cupidon.cpp index 9e5a2114780..0dc6ed242f6 100644 --- a/src/mame/misc/cupidon.cpp +++ b/src/mame/misc/cupidon.cpp @@ -114,8 +114,7 @@ void cupidon_state::cupidon(machine_config &config) PALETTE(config, "palette").set_entries(0x10000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* unknown sound, probably DAC driven using 68340 DMA */ } diff --git a/src/mame/misc/cybertnk.cpp b/src/mame/misc/cybertnk.cpp index b411548fbbd..a18ce84fe11 100644 --- a/src/mame/misc/cybertnk.cpp +++ b/src/mame/misc/cybertnk.cpp @@ -860,16 +860,15 @@ void cybertnk_state::cybertnk(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x4000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0, HOLD_LINE); // Split output per chip - Y8950(config, "ym1", XTAL(3'579'545)).add_route(ALL_OUTPUTS, "lspeaker", 1.0); + Y8950(config, "ym1", XTAL(3'579'545)).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); - Y8950(config, "ym2", XTAL(3'579'545)).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + Y8950(config, "ym2", XTAL(3'579'545)).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } /*************************************************************************** diff --git a/src/mame/misc/dcheese.cpp b/src/mame/misc/dcheese.cpp index 454ad5d1bde..3784b4c19b7 100644 --- a/src/mame/misc/dcheese.cpp +++ b/src/mame/misc/dcheese.cpp @@ -404,15 +404,14 @@ void dcheese_state::dcheese(machine_config &config) PALETTE(config, "palette", FUNC(dcheese_state::dcheese_palette), 65536); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, 0); BSMT2000(config, m_bsmt, SOUND_OSC); - m_bsmt->add_route(0, "lspeaker", 1.2); - m_bsmt->add_route(1, "rspeaker", 1.2); + m_bsmt->add_route(0, "speaker", 1.2, 0); + m_bsmt->add_route(1, "speaker", 1.2, 1); } diff --git a/src/mame/misc/dgpix.cpp b/src/mame/misc/dgpix.cpp index 817ce0b5ba4..56dd770f2f8 100644 --- a/src/mame/misc/dgpix.cpp +++ b/src/mame/misc/dgpix.cpp @@ -508,12 +508,11 @@ void dgpix_state::dgpix_base(machine_config &config) PALETTE(config, "palette", palette_device::BGR_555); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); KS0164(config, m_sound, 16.9344_MHz_XTAL); - m_sound->add_route(0, "lspeaker", 1.0); - m_sound->add_route(1, "rspeaker", 1.0); + m_sound->add_route(0, "speaker", 1.0, 0); + m_sound->add_route(1, "speaker", 1.0, 1); INTEL_28F320J5(config, m_flash[6]); INTEL_28F320J5(config, m_flash[7]); diff --git a/src/mame/misc/discoboy.cpp b/src/mame/misc/discoboy.cpp index 2d232eb744b..e233ba2bcee 100644 --- a/src/mame/misc/discoboy.cpp +++ b/src/mame/misc/discoboy.cpp @@ -450,14 +450,13 @@ void discoboy_state::discoboy(machine_config &config) PALETTE(config, m_palette).set_entries(0x1000); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, 0); ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(10'000'000) / 4)); // 2.5 MHz? - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.6); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.6); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.6, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.6, 1); LS157(config, m_adpcm_select, 0); m_adpcm_select->out_callback().set("msm", FUNC(msm5205_device::data_w)); @@ -465,8 +464,8 @@ void discoboy_state::discoboy(machine_config &config) MSM5205(config, m_msm, XTAL(400'000)); m_msm->vck_legacy_callback().set(FUNC(discoboy_state::adpcm_int)); // interrupt function m_msm->set_prescaler_selector(msm5205_device::S96_4B); // 4KHz, 4 Bits - m_msm->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_msm->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } diff --git a/src/mame/misc/esh.cpp b/src/mame/misc/esh.cpp index f88e2ec6ee9..0ec36b83bfe 100644 --- a/src/mame/misc/esh.cpp +++ b/src/mame/misc/esh.cpp @@ -356,8 +356,8 @@ void esh_state::esh(machine_config &config) PIONEER_LDV1000(config, m_laserdisc, 0); m_laserdisc->command_strobe_callback().set(FUNC(esh_state::ld_command_strobe_cb)); m_laserdisc->set_overlay(256, 256, FUNC(esh_state::screen_update_esh)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_laserdisc->add_ntsc_screen(config, "screen"); @@ -366,8 +366,7 @@ void esh_state::esh(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_esh); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SPEAKER(config, "mono").front_center(); BEEP(config, m_beep, 2000).add_route(ALL_OUTPUTS, "mono", 0.25); diff --git a/src/mame/misc/flower_a.cpp b/src/mame/misc/flower_a.cpp index 176d367f491..34694792520 100644 --- a/src/mame/misc/flower_a.cpp +++ b/src/mame/misc/flower_a.cpp @@ -121,13 +121,12 @@ void flower_sound_device::device_reset() } } -void flower_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void flower_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; short *mix; u8 raw_sample; - std::fill_n(&m_mixer_buffer[0], buffer.samples(), 0); + std::fill_n(&m_mixer_buffer[0], stream.samples(), 0); for (auto &voice : m_channel_list) { @@ -139,7 +138,7 @@ void flower_sound_device::sound_stream_update(sound_stream &stream, std::vector< mix = &m_mixer_buffer[0]; - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { // Volume LUT ROM address bit: // Bit 0-7: Sample ROM data @@ -173,8 +172,8 @@ void flower_sound_device::sound_stream_update(sound_stream &stream, std::vector< /* mix it down */ mix = &m_mixer_buffer[0]; - for (int i = 0; i < buffer.samples(); i++) - buffer.put_int(i, m_mixer_lookup[*mix++], 32768); + for (int i = 0; i < stream.samples(); i++) + stream.put_int(0, i, m_mixer_lookup[*mix++], 32768); } //------------------------------------------------- diff --git a/src/mame/misc/flower_a.h b/src/mame/misc/flower_a.h index 84100bd3c37..dca4e99f61b 100644 --- a/src/mame/misc/flower_a.h +++ b/src/mame/misc/flower_a.h @@ -39,7 +39,7 @@ protected: virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; virtual space_config_vector memory_space_config() const override; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; address_space *m_iospace = nullptr; private: diff --git a/src/mame/misc/funkball.cpp b/src/mame/misc/funkball.cpp index 076a76ec8c2..cfbff8144f5 100644 --- a/src/mame/misc/funkball.cpp +++ b/src/mame/misc/funkball.cpp @@ -786,12 +786,11 @@ void funkball_state::funkball(machine_config &config) INTEL_28F320J5(config, "u30"); INTEL_28F320J5(config, "u3"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); KS0164(config, m_sound, 16.9344_MHz_XTAL); - m_sound->add_route(0, "lspeaker", 1.0); - m_sound->add_route(1, "rspeaker", 1.0); + m_sound->add_route(0, "speaker", 1.0, 0); + m_sound->add_route(1, "speaker", 1.0, 1); } ROM_START( funkball ) diff --git a/src/mame/misc/gamtor.cpp b/src/mame/misc/gamtor.cpp index 382d10e674b..1745d6b49b6 100644 --- a/src/mame/misc/gamtor.cpp +++ b/src/mame/misc/gamtor.cpp @@ -179,8 +179,7 @@ void gaminator_state::gaminator(machine_config &config) vga.set_screen("screen"); vga.set_vram_size(0x100000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* unknown sound */ } diff --git a/src/mame/misc/gms.cpp b/src/mame/misc/gms.cpp index 7781c7c952b..c35e44609ca 100644 --- a/src/mame/misc/gms.cpp +++ b/src/mame/misc/gms.cpp @@ -2274,16 +2274,15 @@ void gms_2layers_state::rbmk(machine_config &config) EEPROM_93C46_16BIT(config, m_eeprom); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, 22_MHz_XTAL / 20, okim6295_device::PIN7_HIGH); // pin 7 not verified, but seems to match recordings - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.47); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.47); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 1); YM2151(config, m_ymsnd, 22_MHz_XTAL / 8); - m_ymsnd->add_route(0, "lspeaker", 0.60); - m_ymsnd->add_route(1, "rspeaker", 0.60); + m_ymsnd->add_route(0, "speaker", 0.60, 0); + m_ymsnd->add_route(1, "speaker", 0.60, 1); } void gms_2layers_state::rbspm(machine_config &config) @@ -2305,8 +2304,8 @@ void gms_2layers_state::ssanguoj(machine_config &config) config.device_remove("ymsnd"); ym3812_device &ym(YM3812(config, "ym3812", 22_MHz_XTAL / 8)); - ym.add_route(0, "lspeaker", 0.60); - ym.add_route(1, "rspeaker", 0.60); + ym.add_route(0, "speaker", 0.60, 0); + ym.add_route(1, "speaker", 0.60, 1); } void gms_2layers_state::super555(machine_config &config) diff --git a/src/mame/misc/good.cpp b/src/mame/misc/good.cpp index 4ba1762bc76..97aa72c1f0b 100644 --- a/src/mame/misc/good.cpp +++ b/src/mame/misc/good.cpp @@ -311,12 +311,11 @@ void good_state::good(machine_config &config) PALETTE(config, "palette").set_format(palette_device::xRGB_555, 0x400); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", 1000000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.47); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.47); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } diff --git a/src/mame/misc/gumbo.cpp b/src/mame/misc/gumbo.cpp index c542fb2ea5d..a64ab57a7f0 100644 --- a/src/mame/misc/gumbo.cpp +++ b/src/mame/misc/gumbo.cpp @@ -342,12 +342,11 @@ void gumbo_state::gumbo(machine_config &config) PALETTE(config, "palette").set_format(palette_device::xRGB_555, 0x200); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", XTAL(14'318'181) / 16, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.47); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.47); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } void gumbo_state::mspuzzle(machine_config &config) diff --git a/src/mame/misc/gunpey.cpp b/src/mame/misc/gunpey.cpp index 56e5abcce20..0a91fa18b2d 100644 --- a/src/mame/misc/gunpey.cpp +++ b/src/mame/misc/gunpey.cpp @@ -1174,16 +1174,15 @@ void gunpey_state::gunpey(machine_config &config) PALETTE(config, m_palette, palette_device::RGB_555); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, XTAL(16'934'400) / 8, okim6295_device::PIN7_LOW); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.125); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.125); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.125, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.125, 1); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); - ymz.add_route(0, "lspeaker", 0.25); - ymz.add_route(1, "rspeaker", 0.25); + ymz.add_route(0, "speaker", 0.25, 0); + ymz.add_route(1, "speaker", 0.25, 1); } /***************************************************************************************/ diff --git a/src/mame/misc/hapyfish.cpp b/src/mame/misc/hapyfish.cpp index 4adefeb3cac..59526bedb1e 100644 --- a/src/mame/misc/hapyfish.cpp +++ b/src/mame/misc/hapyfish.cpp @@ -519,10 +519,9 @@ void hapyfish_state::hapyfish(machine_config &config) screen.set_visarea(0, 639, 0, 479); screen.set_screen_update("s3c2440", FUNC(s3c2440_device::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - UDA1341TS(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // uda1341ts.u12 - UDA1341TS(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // uda1341ts.u12 + SPEAKER(config, "speaker", 2).front(); + UDA1341TS(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // uda1341ts.u12 + UDA1341TS(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // uda1341ts.u12 S3C2440(config, m_s3c2440, 12000000); m_s3c2440->set_palette_tag("palette"); diff --git a/src/mame/misc/hideseek.cpp b/src/mame/misc/hideseek.cpp index 0656aff82fa..6e91de9e3a3 100644 --- a/src/mame/misc/hideseek.cpp +++ b/src/mame/misc/hideseek.cpp @@ -124,8 +124,7 @@ void hideseek_state::hideseek(machine_config &config) PALETTE(config, "palette", FUNC(hideseek_state::hideseek_palette), 0x10000); GFXDECODE(config, "gfxdecode", "palette", gfx_hideseek); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* sound : M9810 */ } diff --git a/src/mame/misc/inder_sb.cpp b/src/mame/misc/inder_sb.cpp index 33de7c663ac..6c9fdb12bd4 100644 --- a/src/mame/misc/inder_sb.cpp +++ b/src/mame/misc/inder_sb.cpp @@ -14,7 +14,7 @@ DEFINE_DEVICE_TYPE(INDER_AUDIO, inder_sb_device, "indersb", "Inder 4xDAC Sound B inder_sb_device::inder_sb_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, INDER_AUDIO, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_audiocpu(*this, "audiocpu") , m_ctc(*this, "ctc") , m_audiocpu_rom(*this, "audiocpu") diff --git a/src/mame/misc/istellar.cpp b/src/mame/misc/istellar.cpp index 5e5c70621bb..b40ea961fd1 100644 --- a/src/mame/misc/istellar.cpp +++ b/src/mame/misc/istellar.cpp @@ -381,8 +381,8 @@ void istellar_state::istellar(machine_config &config) PIONEER_LDV1000(config, m_laserdisc, 0); m_laserdisc->set_overlay(256, 256, FUNC(istellar_state::screen_update)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); // video hardware m_laserdisc->add_ntsc_screen(config, "screen"); @@ -394,8 +394,7 @@ void istellar_state::istellar(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_istellar); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/misc/jungleyo.cpp b/src/mame/misc/jungleyo.cpp index 593f64e35e9..073401cdf2d 100644 --- a/src/mame/misc/jungleyo.cpp +++ b/src/mame/misc/jungleyo.cpp @@ -884,12 +884,11 @@ void jungleyo_state::jungleyo(machine_config &config) PALETTE(config, m_palette).set_entries(0x8000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", 24_MHz_XTAL / 20, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.47); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.47); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } diff --git a/src/mame/misc/laz_ribrac.cpp b/src/mame/misc/laz_ribrac.cpp index 72b72dd15a2..0e78e8b37bc 100644 --- a/src/mame/misc/laz_ribrac.cpp +++ b/src/mame/misc/laz_ribrac.cpp @@ -306,14 +306,13 @@ void ribrac_state::ribrac(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // 6264 + MAX694 + battery /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki[0], 2.097152_MHz_XTAL, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); OKIM6295(config, m_oki[1], 2.097152_MHz_XTAL, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/misc/limenko.cpp b/src/mame/misc/limenko.cpp index 80e57a98466..f3a16cf7be9 100644 --- a/src/mame/misc/limenko.cpp +++ b/src/mame/misc/limenko.cpp @@ -712,8 +712,7 @@ void limenko_state::limenko(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x1000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(m_qs1000, FUNC(qs1000_device::set_irq)); @@ -725,8 +724,8 @@ void limenko_state::limenko(machine_config &config) m_qs1000->p1_out().set(FUNC(limenko_state::qs1000_p1_w)); m_qs1000->p2_out().set(FUNC(limenko_state::qs1000_p2_w)); m_qs1000->p3_out().set(FUNC(limenko_state::qs1000_p3_w)); - m_qs1000->add_route(0, "lspeaker", 1.0); - m_qs1000->add_route(1, "rspeaker", 1.0); + m_qs1000->add_route(0, "speaker", 1.0, 0); + m_qs1000->add_route(1, "speaker", 1.0, 1); } void limenko_state::spotty(machine_config &config) diff --git a/src/mame/misc/magictg.cpp b/src/mame/misc/magictg.cpp index 7112bbdc002..4980ad3c287 100644 --- a/src/mame/misc/magictg.cpp +++ b/src/mame/misc/magictg.cpp @@ -928,11 +928,10 @@ void magictg_state::magictg(machine_config &config) m_adsp->set_addrmap(AS_DATA, &magictg_state::adsp_data_map); m_adsp->set_addrmap(AS_IO, &magictg_state::adsp_io_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); pci_bus_legacy_device &pcibus(PCI_BUS_LEGACY(config, "pcibus", 0, 0)); pcibus.set_device(0, FUNC(magictg_state::pci_dev0_r), FUNC(magictg_state::pci_dev0_w)); diff --git a/src/mame/misc/micro3d.cpp b/src/mame/misc/micro3d.cpp index 5759ca49830..cf9c44a6732 100644 --- a/src/mame/misc/micro3d.cpp +++ b/src/mame/misc/micro3d.cpp @@ -381,24 +381,23 @@ void micro3d_state::micro3d(machine_config &config) m_adc->ch1_callback().set_ioport("THROTTLE"); m_adc->ch2_callback().set(FUNC(micro3d_state::adc_volume_r)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); UPD7759(config, m_upd7759); - m_upd7759->add_route(ALL_OUTPUTS, "lspeaker", 0.35); - m_upd7759->add_route(ALL_OUTPUTS, "rspeaker", 0.35); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.35, 0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.35, 1); ym2151_device &ym2151(YM2151(config, "ym2151", 3.579545_MHz_XTAL)); - ym2151.add_route(0, "lspeaker", 0.35); - ym2151.add_route(1, "rspeaker", 0.35); + ym2151.add_route(0, "speaker", 0.35, 0); + ym2151.add_route(1, "speaker", 0.35, 1); MICRO3D_SOUND(config, m_noise[0]); - m_noise[0]->add_route(0, "lspeaker", 1.0); - m_noise[0]->add_route(1, "rspeaker", 1.0); + m_noise[0]->add_route(0, "speaker", 1.0, 0); + m_noise[0]->add_route(1, "speaker", 1.0, 1); MICRO3D_SOUND(config, m_noise[1]); - m_noise[1]->add_route(0, "lspeaker", 1.0); - m_noise[1]->add_route(1, "rspeaker", 1.0); + m_noise[1]->add_route(0, "speaker", 1.0, 0); + m_noise[1]->add_route(1, "speaker", 1.0, 1); } void micro3d_state::botss11(machine_config &config) diff --git a/src/mame/misc/micro3d_a.cpp b/src/mame/misc/micro3d_a.cpp index 6db60dddcc3..02971a77c17 100644 --- a/src/mame/misc/micro3d_a.cpp +++ b/src/mame/misc/micro3d_a.cpp @@ -222,24 +222,17 @@ void micro3d_sound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void micro3d_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void micro3d_sound_device::sound_stream_update(sound_stream &stream) { lp_filter *iir = &m_filter; - auto &fl = outputs[0]; - auto &fr = outputs[1]; - - // Clear the buffers - fl.fill(0); - fr.fill(0); - if (m_gain == 0) return; float const pan_l = float(255 - m_dac[PAN]) / 255.0f; float const pan_r = float(m_dac[PAN]) / 255.0f; - for (int sampindex = 0; sampindex < fl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int step; @@ -289,7 +282,7 @@ void micro3d_sound_device::sound_stream_update(sound_stream &stream, std::vector } output *= 3.5f / 32768.f; - fl.put_clamp(sampindex, output * pan_l, 1.0); - fr.put_clamp(sampindex, output * pan_r, 1.0); + stream.put_clamp(0, sampindex, output * pan_l, 1.0); + stream.put_clamp(1, sampindex, output * pan_r, 1.0); } } diff --git a/src/mame/misc/micro3d_a.h b/src/mame/misc/micro3d_a.h index c47833cf9b2..2940041f4d1 100644 --- a/src/mame/misc/micro3d_a.h +++ b/src/mame/misc/micro3d_a.h @@ -24,7 +24,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: enum dac_registers diff --git a/src/mame/misc/mindset.cpp b/src/mame/misc/mindset.cpp index fca02a2fd58..24a3961d341 100644 --- a/src/mame/misc/mindset.cpp +++ b/src/mame/misc/mindset.cpp @@ -245,9 +245,7 @@ void mindset_sound_module::device_add_mconfig(machine_config &config) I8042(config, m_soundcpu, 12_MHz_XTAL/2); m_soundcpu->p1_out_cb().set(FUNC(mindset_sound_module::p1_w)); m_soundcpu->p2_out_cb().set(FUNC(mindset_sound_module::p2_w)); - - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); + DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } @@ -1346,8 +1344,8 @@ void mindset_state::mindset(machine_config &config) FLOPPY_CONNECTOR(config, m_fdco[0], pc_dd_floppies, "525dd", floppy_image_device::default_pc_floppy_formats); FLOPPY_CONNECTOR(config, m_fdco[1], pc_dd_floppies, "525dd", floppy_image_device::default_pc_floppy_formats); - SPEAKER(config, "lspeaker").front_left(); - DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); MINDSET_MODULE(config, "m0", mindset_modules, "stereo", false); MINDSET_MODULE(config, "m1", mindset_modules, "rs232", false); diff --git a/src/mame/misc/neoprint.cpp b/src/mame/misc/neoprint.cpp index 506f4963a0f..86027b296b7 100644 --- a/src/mame/misc/neoprint.cpp +++ b/src/mame/misc/neoprint.cpp @@ -536,17 +536,16 @@ void neoprint_state::neoprint(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x10000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym2610_device &ymsnd(YM2610(config, "ymsnd", 24000000 / 3)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(0, "rspeaker", 0.60); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(0, "speaker", 0.60, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } MACHINE_RESET_MEMBER(neoprint_state,nprsp) @@ -582,17 +581,16 @@ void neoprint_state::nprsp(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x10000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym2610_device &ymsnd(YM2610(config, "ymsnd", 24000000 / 3)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(0, "rspeaker", 0.60); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(0, "speaker", 0.60, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/misc/policetr.cpp b/src/mame/misc/policetr.cpp index 17a949e5ea0..97e96d6e2cd 100644 --- a/src/mame/misc/policetr.cpp +++ b/src/mame/misc/policetr.cpp @@ -452,12 +452,11 @@ void policetr_state::policetr(machine_config &config) BT481(config, m_ramdac, 0); // Bt481AKPJ110 /* sound hardware */ - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); BSMT2000(config, m_bsmt, MASTER_CLOCK/2); - m_bsmt->add_route(0, *m_lspeaker, 1.0); - m_bsmt->add_route(1, *m_rspeaker, 1.0); + m_bsmt->add_route(0, *m_speaker, 1.0, 0); + m_bsmt->add_route(1, *m_speaker, 1.0, 1); } void sshooter_state::sshooter(machine_config &config) diff --git a/src/mame/misc/policetr.h b/src/mame/misc/policetr.h index d692ad5c89b..ff625e16650 100644 --- a/src/mame/misc/policetr.h +++ b/src/mame/misc/policetr.h @@ -32,8 +32,7 @@ protected: m_maincpu(*this, "maincpu"), m_bsmt(*this, "bsmt"), m_bsmt_region(*this, "bsmt"), - m_lspeaker(*this, "lspeaker"), - m_rspeaker(*this, "rspeaker"), + m_speaker(*this, "speaker"), m_eeprom(*this, "eeprom"), m_screen(*this, "screen"), m_ramdac(*this, "ramdac"), @@ -67,8 +66,7 @@ protected: required_device<r3041_device> m_maincpu; required_device<bsmt2000_device> m_bsmt; required_region_ptr<uint8_t> m_bsmt_region; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<speaker_device> m_speaker; required_device<eeprom_serial_93cxx_device> m_eeprom; required_device<screen_device> m_screen; required_device<bt481_device> m_ramdac; diff --git a/src/mame/misc/proconn.cpp b/src/mame/misc/proconn.cpp index 4f6f0ceee65..5840b10f26e 100644 --- a/src/mame/misc/proconn.cpp +++ b/src/mame/misc/proconn.cpp @@ -328,15 +328,14 @@ void proconn_state::proconn(machine_config &config) Z80SIO(config, m_z80sio, 4000000); /* ?? Mhz */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.set_default_layout(layout_proconn); AY8910(config, m_ay, 1000000); /* ?? Mhz */ // YM2149F on PC92? m_ay->port_b_write_callback().set(FUNC(proconn_state::meter_w)); - m_ay->add_route(ALL_OUTPUTS, "rspeaker", 0.33); + m_ay->add_route(ALL_OUTPUTS, "speaker", 0.33, 1); METERS(config, m_meters, 0); m_meters->set_number(8); diff --git a/src/mame/misc/skimaxx.cpp b/src/mame/misc/skimaxx.cpp index c5ef1f693e9..dbd6e2ce5b1 100644 --- a/src/mame/misc/skimaxx.cpp +++ b/src/mame/misc/skimaxx.cpp @@ -560,16 +560,15 @@ void skimaxx_state::skimaxx(machine_config &config) PALETTE(config, "palette", palette_device::RGB_555); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - OKIM6295(config, "oki1", XTAL(4'000'000), okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // ? + OKIM6295(config, "oki1", XTAL(4'000'000), okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // ? - OKIM6295(config, "oki2", XTAL(4'000'000)/2, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // ? + OKIM6295(config, "oki2", XTAL(4'000'000)/2, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // ? - OKIM6295(config, "oki3", XTAL(4'000'000), okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // ? + OKIM6295(config, "oki3", XTAL(4'000'000), okim6295_device::PIN7_LOW).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // ? - OKIM6295(config, "oki4", XTAL(4'000'000)/2, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // ? + OKIM6295(config, "oki4", XTAL(4'000'000)/2, okim6295_device::PIN7_HIGH).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // ? } diff --git a/src/mame/misc/sliver.cpp b/src/mame/misc/sliver.cpp index 47ef5538120..fc40e885cea 100644 --- a/src/mame/misc/sliver.cpp +++ b/src/mame/misc/sliver.cpp @@ -541,15 +541,14 @@ void sliver_state::sliver(machine_config &config) ramdac_device &ramdac(RAMDAC(config, "ramdac", 0, "palette")); ramdac.set_addrmap(0, &sliver_state::ramdac_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); okim6295_device &oki(OKIM6295(config, "oki", 1000000, okim6295_device::PIN7_HIGH)); oki.set_addrmap(0, &sliver_state::oki_map); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.6); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.6); + oki.add_route(ALL_OUTPUTS, "speaker", 0.6, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.6, 1); } ROM_START( sliver ) diff --git a/src/mame/misc/spool99.cpp b/src/mame/misc/spool99.cpp index 5875f3529bb..ff8f39ed1c0 100644 --- a/src/mame/misc/spool99.cpp +++ b/src/mame/misc/spool99.cpp @@ -391,12 +391,11 @@ void spool99_state::spool99(machine_config &config) EEPROM_93C46_16BIT(config, "eeprom"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, 1000000, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.47); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.47); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } void spool99_state::vcarn(machine_config &config) diff --git a/src/mame/misc/sttechno.cpp b/src/mame/misc/sttechno.cpp index 87ee840a839..db1f54c861f 100644 --- a/src/mame/misc/sttechno.cpp +++ b/src/mame/misc/sttechno.cpp @@ -595,13 +595,12 @@ void sttechno_state::shambros(machine_config &config) FUJITSU_29F160TE_16BIT(config, m_flash[1]); FUJITSU_29F160TE_16BIT(config, m_video_flash); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); STT_SA1(config, m_sound, XTAL(42'954'545) / 3); m_sound->set_addrmap(0, &sttechno_state::sound_map); - m_sound->add_route(0, "lspeaker", 1.0); - m_sound->add_route(1, "rspeaker", 1.0); + m_sound->add_route(0, "speaker", 1.0, 0); + m_sound->add_route(1, "speaker", 1.0, 1); TIMER(config, "irq6_timer").configure_periodic(FUNC(sttechno_state::irq6_timer), attotime::from_hz(XTAL(42'954'545) / 3 / 448 / 128)); // probably some interrupt? RS232_PORT(config, m_rs232, sttechno_debug_serial_devices, nullptr); diff --git a/src/mame/misc/tapatune.cpp b/src/mame/misc/tapatune.cpp index a10dc98bdb9..454d4646a1f 100644 --- a/src/mame/misc/tapatune.cpp +++ b/src/mame/misc/tapatune.cpp @@ -542,12 +542,11 @@ void tapatune_state::tapatune_base(machine_config &config) TICKET_DISPENSER(config, "ticket", attotime::from_msec(100)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); BSMT2000(config, m_bsmt, XTAL(24'000'000)); - m_bsmt->add_route(0, "lspeaker", 1.0); - m_bsmt->add_route(1, "rspeaker", 1.0); + m_bsmt->add_route(0, "speaker", 1.0, 0); + m_bsmt->add_route(1, "speaker", 1.0, 1); } void tapatune_state::tapatune(machine_config &config) diff --git a/src/mame/misc/thayers.cpp b/src/mame/misc/thayers.cpp index cebe0e792e1..f9247fadbf7 100644 --- a/src/mame/misc/thayers.cpp +++ b/src/mame/misc/thayers.cpp @@ -680,15 +680,14 @@ void thayers_state::thayers(machine_config &config) screen.set_screen_update(m_player, FUNC(pioneer_ldv1000hle_device::screen_update)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - m_player->add_route(0, "lspeaker", 1.0); - m_player->add_route(1, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + m_player->add_route(0, "speaker", 1.0, 0); + m_player->add_route(1, "speaker", 1.0, 1); SSI263HLE(config, m_ssi, 860000); m_ssi->ar_callback().set(FUNC(thayers_state::ssi_data_request_w)); - m_ssi->add_route(0, "lspeaker", 1.0); - m_ssi->add_route(1, "lspeaker", 1.0); + m_ssi->add_route(0, "speaker", 1.0, 0); + m_ssi->add_route(1, "speaker", 1.0, 0); } diff --git a/src/mame/misc/tomsadvs.cpp b/src/mame/misc/tomsadvs.cpp index 2071932a48a..f817a85c671 100644 --- a/src/mame/misc/tomsadvs.cpp +++ b/src/mame/misc/tomsadvs.cpp @@ -73,16 +73,15 @@ void tomsadvs_state::tomsadvs(machine_config &config) { I80C32(config, m_maincpu, 12.288_MHz_XTAL); // Actually a Winbond W87C32C-40 - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki1(OKIM6295(config, "oki1", 12.288_MHz_XTAL/16, okim6295_device::PIN7_HIGH)); // Clock frequency & pin 7 not verified - oki1.add_route(ALL_OUTPUTS, "lspeaker", 0.45); // Guess - oki1.add_route(ALL_OUTPUTS, "rspeaker", 0.45); // Guess + oki1.add_route(ALL_OUTPUTS, "speaker", 0.45, 0); // Guess + oki1.add_route(ALL_OUTPUTS, "speaker", 0.45, 1); // Guess okim6295_device &oki2(OKIM6295(config, "oki2", 12.288_MHz_XTAL/16, okim6295_device::PIN7_HIGH)); // Clock frequency & pin 7 not verified - oki2.add_route(ALL_OUTPUTS, "lspeaker", 0.45); // Guess - oki2.add_route(ALL_OUTPUTS, "rspeaker", 0.45); // Guess + oki2.add_route(ALL_OUTPUTS, "speaker", 0.45, 0); // Guess + oki2.add_route(ALL_OUTPUTS, "speaker", 0.45, 1); // Guess } ROM_START(tomsadvs) diff --git a/src/mame/misc/vamphalf.cpp b/src/mame/misc/vamphalf.cpp index aa647cb0631..5c03e37be18 100644 --- a/src/mame/misc/vamphalf.cpp +++ b/src/mame/misc/vamphalf.cpp @@ -1148,14 +1148,13 @@ void vamphalf_state::common(machine_config &config) void vamphalf_state::sound_ym_oki(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 28_MHz_XTAL / 8).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); // 3.5MHz + YM2151(config, "ymsnd", 28_MHz_XTAL / 8).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); // 3.5MHz okim6295_device &oki1(OKIM6295(config, "oki1", 28_MHz_XTAL / 16 , okim6295_device::PIN7_HIGH)); // 1.75MHz - oki1.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki1.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void vamphalf_state::sound_ym_banked_oki(machine_config &config) @@ -1166,21 +1165,19 @@ void vamphalf_state::sound_ym_banked_oki(machine_config &config) void vamphalf_state::sound_suplup(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 14.318181_MHz_XTAL / 4).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); // 3.579545 MHz + YM2151(config, "ymsnd", 14.318181_MHz_XTAL / 4).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); // 3.579545 MHz okim6295_device &oki1(OKIM6295(config, "oki1", 14.318181_MHz_XTAL / 8, okim6295_device::PIN7_HIGH)); // 1.75MHz - oki1.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki1.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void vamphalf_state::sound_qs1000(machine_config &config) { /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set("qs1000", FUNC(qs1000_device::set_irq)); @@ -1190,8 +1187,8 @@ void vamphalf_state::sound_qs1000(machine_config &config) qs1000.set_external_rom(true); qs1000.p1_in().set("soundlatch", FUNC(generic_latch_8_device::read)); qs1000.p3_out().set(FUNC(vamphalf_state::qs1000_p3_w)); - qs1000.add_route(0, "lspeaker", 1.0); - qs1000.add_route(1, "rspeaker", 1.0); + qs1000.add_route(0, "speaker", 1.0, 0); + qs1000.add_route(1, "speaker", 1.0, 1); } void vamphalf_state::vamphalf(machine_config &config) @@ -1351,19 +1348,18 @@ void vamphalf_state::aoh(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_vamphalf); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); okim6295_device &oki1(OKIM6295(config, "oki1", 32_MHz_XTAL / 8, okim6295_device::PIN7_HIGH)); // 4MHz - oki1.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki1.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); okim6295_device &oki2(OKIM6295(config, "oki2", 32_MHz_XTAL / 32, okim6295_device::PIN7_HIGH)); // 1MHz oki2.set_addrmap(0, &vamphalf_state::banked_oki_map); - oki2.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki2.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki2.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki2.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } void vamphalf_state::boonggab(machine_config &config) diff --git a/src/mame/misc/vocalizer.cpp b/src/mame/misc/vocalizer.cpp index 7b8d73a1455..a7afd365fcd 100644 --- a/src/mame/misc/vocalizer.cpp +++ b/src/mame/misc/vocalizer.cpp @@ -522,8 +522,7 @@ void vocalizer_state::vocalizer(machine_config &config) m_lcdc->set_lcd_size(2, 8); m_lcdc->set_pixel_update_cb(FUNC(vocalizer_state::lcd_pixel_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ES5503(config, m_es5503, 8_MHz_XTAL).set_channels(16); m_es5503->set_addrmap(0, &vocalizer_state::sound_map); @@ -531,14 +530,14 @@ void vocalizer_state::vocalizer(machine_config &config) for (int i = 0; i < 16; i++) { if (i <= 8) - m_es5503->add_route(i, "lspeaker", 1.0); + m_es5503->add_route(i, "speaker", 1.0, 0); else if (i < 15) - m_es5503->add_route(i, "lspeaker", (15 - i) / 7.0); + m_es5503->add_route(i, "speaker", (15 - i, 0) / 7.0); if (i >= 8) - m_es5503->add_route(i, "rspeaker", 1.0); + m_es5503->add_route(i, "speaker", 1.0, 1); else if (i > 0) - m_es5503->add_route(i, "rspeaker", i / 8.0); + m_es5503->add_route(i, "speaker", i / 8.0, 1); } } diff --git a/src/mame/misc/xtom3d.cpp b/src/mame/misc/xtom3d.cpp index 6352416a705..d714f134d9b 100644 --- a/src/mame/misc/xtom3d.cpp +++ b/src/mame/misc/xtom3d.cpp @@ -365,12 +365,11 @@ void isa16_xtom3d_io_sound::device_add_mconfig(machine_config &config) // explicitly wants 16, cfr. pumpit1 eeprom test EEPROM_93C46_16BIT(config, "eeprom"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YMZ280B(config, m_ymz, XTAL(16'934'400)); - m_ymz->add_route(0, "lspeaker", 0.5); - m_ymz->add_route(1, "rspeaker", 0.5); + m_ymz->add_route(0, "speaker", 0.5, 0); + m_ymz->add_route(1, "speaker", 0.5, 1); } static INPUT_PORTS_START(xtom3d) diff --git a/src/mame/misc/yuvomz80.cpp b/src/mame/misc/yuvomz80.cpp index aa308c49e30..55cdf63fedf 100644 --- a/src/mame/misc/yuvomz80.cpp +++ b/src/mame/misc/yuvomz80.cpp @@ -132,12 +132,11 @@ void yuvomz80_state::hexaprsz(machine_config &config) I8255A(config, "ppi2", 0); I8255A(config, "ppi3", 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); - ymz.add_route(0, "lspeaker", 1.00); - ymz.add_route(1, "rspeaker", 1.00); + ymz.add_route(0, "speaker", 1.00, 0); + ymz.add_route(1, "speaker", 1.00, 1); } ROM_START( hexaprs ) diff --git a/src/mame/namco/dkmb.cpp b/src/mame/namco/dkmb.cpp index ba1d8256061..d3c75fcc131 100644 --- a/src/mame/namco/dkmb.cpp +++ b/src/mame/namco/dkmb.cpp @@ -137,8 +137,7 @@ void dkmb_state::dkmb(machine_config &config) PALETTE(config, "palette").set_entries(65536); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/namco/gal3.cpp b/src/mame/namco/gal3.cpp index b946491b57b..0f7588a8b40 100644 --- a/src/mame/namco/gal3.cpp +++ b/src/mame/namco/gal3.cpp @@ -681,19 +681,18 @@ void gal3_state::gal3(machine_config &config) m_namcos21_dsp_c67[1]->set_renderer_tag("namcos21_3d_2"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: Total 5 of C140s in sound board, verified from gal3zlgr PCB - gal3 uses same board? C140(config, m_c140_16g, 49152000/2304); //m_c140_16g->set_addrmap(0, &gal3_state::c140_16g_map); //to be verified - m_c140_16g->add_route(0, "lspeaker", 0.50); - m_c140_16g->add_route(1, "rspeaker", 0.50); + m_c140_16g->add_route(0, "speaker", 0.50, 0); + m_c140_16g->add_route(1, "speaker", 0.50, 1); C140(config, m_c140_16a, 49152000/2304); //m_c140_16a->set_addrmap(0, &gal3_state::c140_16a_map); //to be verified - m_c140_16a->add_route(0, "lspeaker", 0.50); - m_c140_16a->add_route(1, "rspeaker", 0.50); + m_c140_16a->add_route(0, "speaker", 0.50, 0); + m_c140_16a->add_route(1, "speaker", 0.50, 1); } /* diff --git a/src/mame/namco/geebee.cpp b/src/mame/namco/geebee.cpp index e05ba694a58..839b7296025 100644 --- a/src/mame/namco/geebee.cpp +++ b/src/mame/namco/geebee.cpp @@ -99,13 +99,11 @@ void geebee_sound_device::sound_w(u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void geebee_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void geebee_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put_int(sampindex, m_sound_signal, 32768); + stream.put_int(0, sampindex, m_sound_signal, 32768); // 1V = HSYNC = 18.432MHz / 3 / 2 / 384 = 8000Hz m_vcount++; diff --git a/src/mame/namco/geebee.h b/src/mame/namco/geebee.h index 7ec36b3bf69..1b4e3253b27 100644 --- a/src/mame/namco/geebee.h +++ b/src/mame/namco/geebee.h @@ -17,7 +17,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(volume_decay_tick); diff --git a/src/mame/namco/namcofl.cpp b/src/mame/namco/namcofl.cpp index 3e9bd011d53..7556a76f3e1 100644 --- a/src/mame/namco/namcofl.cpp +++ b/src/mame/namco/namcofl.cpp @@ -707,13 +707,12 @@ void namcofl_state::namcofl(machine_config &config) NAMCO_C116(config, m_c116, 0); m_c116->enable_shadows(); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", 48.384_MHz_XTAL / 2, 288)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - //c352.add_route(2, "lspeaker", 1.00); // Second DAC not present. - //c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + //c352.add_route(2, "speaker", 1.00); // Second DAC not present. + //c352.add_route(3, "speaker", 1.00); } ROM_START( speedrcr ) diff --git a/src/mame/namco/namcona1.cpp b/src/mame/namco/namcona1.cpp index 153b6452d03..20a2f517588 100644 --- a/src/mame/namco/namcona1.cpp +++ b/src/mame/namco/namcona1.cpp @@ -1067,13 +1067,12 @@ void namcona1_state::namcona_base(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_namcona1); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); C219(config, m_c219, 44100); m_c219->set_addrmap(0, &namcona1_state::namcona1_c219_map); - m_c219->add_route(0, "rspeaker", 1.00); - m_c219->add_route(1, "lspeaker", 1.00); + m_c219->add_route(0, "speaker", 1.00, 1); + m_c219->add_route(1, "speaker", 1.00, 0); } void namcona1_state::namcona1(machine_config &config) diff --git a/src/mame/namco/namconb1.cpp b/src/mame/namco/namconb1.cpp index 0b1631abec2..0f693d1362e 100644 --- a/src/mame/namco/namconb1.cpp +++ b/src/mame/namco/namconb1.cpp @@ -1012,14 +1012,13 @@ void namconb1_state::namconb1(machine_config &config) NAMCO_C116(config, m_c116); m_c116->enable_shadows(); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", XTAL(48'384'000) / 2, 288)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - //c352.add_route(2, "lspeaker", 1.00); // Second DAC not present. - //c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + //c352.add_route(2, "speaker", 1.00); // Second DAC not present. + //c352.add_route(3, "speaker", 1.00); } void gunbulet_state::gunbulet(machine_config &config) diff --git a/src/mame/namco/namcond1.cpp b/src/mame/namco/namcond1.cpp index dce25c7a58f..7d2ff628c4b 100644 --- a/src/mame/namco/namcond1.cpp +++ b/src/mame/namco/namcond1.cpp @@ -522,14 +522,13 @@ void namcond1_state::namcond1(machine_config &config) screen.set_palette("ygv608"); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", XTAL(49'152'000) / 2, 288)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - //c352.add_route(2, "lspeaker", 1.00); // Second DAC not present. - //c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + //c352.add_route(2, "speaker", 1.00); // Second DAC not present. + //c352.add_route(3, "speaker", 1.00); AT28C16(config, "at28c16", 0); } diff --git a/src/mame/namco/namcos1.cpp b/src/mame/namco/namcos1.cpp index ecd7ccb4da5..689639ec716 100644 --- a/src/mame/namco/namcos1.cpp +++ b/src/mame/namco/namcos1.cpp @@ -1057,27 +1057,26 @@ void namcos1_state::ns1(machine_config &config) m_c123tmap->set_tmap3_half_height(); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); ymsnd.irq_handler().set_inputline(m_audiocpu, M6809_FIRQ_LINE); - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); namco_cus30_device &cus30(NAMCO_CUS30(config, "namco", XTAL(49'152'000)/2048/2)); cus30.set_voices(8); cus30.set_stereo(1); - cus30.add_route(0, "lspeaker", 0.50); - cus30.add_route(1, "rspeaker", 0.50); + cus30.add_route(0, "speaker", 0.50, 0); + cus30.add_route(1, "speaker", 0.50, 1); DAC_8BIT_R2R(config, m_dac[0], 0); // 10-pin 1Kx8R SIP with HC374 latch - m_dac[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_dac[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_dac[0]->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_dac[0]->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); DAC_8BIT_R2R(config, m_dac[1], 0); // 10-pin 1Kx8R SIP with HC374 latch - m_dac[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_dac[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_dac[1]->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_dac[1]->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } void quester_state::quester(machine_config &config) diff --git a/src/mame/namco/namcos10.cpp b/src/mame/namco/namcos10.cpp index f8833e33dd2..b6f50ff71fd 100644 --- a/src/mame/namco/namcos10.cpp +++ b/src/mame/namco/namcos10.cpp @@ -1101,15 +1101,14 @@ void namcos10_state::namcos10_base(machine_config &config) SCREEN(config, "screen", SCREEN_TYPE_RASTER); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // CXD2938Q; SPU with CD-ROM controller - also seen in PSone, 101.4912MHz / 2 // TODO: This must be replaced with a proper CXD2938Q device, CD-ROM functionality of chip not used spu_device &spu(SPU(config, "spu", XTAL(101'491'200)/2, m_maincpu.target())); spu.set_stream_flags(STREAM_SYNCHRONOUS); - spu.add_route(0, "lspeaker", 0.75); - spu.add_route(1, "rspeaker", 0.75); + spu.add_route(0, "speaker", 0.75, 0); + spu.add_route(1, "speaker", 0.75, 1); // TODO: Trace main PCB to see where JAMMA I/O goes and/or how int10 can be triggered (SM10MA3?) m_io_update_interrupt.bind().set("maincpu:irq", FUNC(psxirq_device::intin10)); @@ -2899,8 +2898,8 @@ void namcos10_memp3_state::namcos10_memp3_base(machine_config &config) }); LC82310(config, m_lc82310, XTAL(16'934'400)); - m_lc82310->add_route(0, "lspeaker", 1.0); - m_lc82310->add_route(1, "rspeaker", 1.0); + m_lc82310->add_route(0, "speaker", 1.0, 0); + m_lc82310->add_route(1, "speaker", 1.0, 1); } void namcos10_memp3_state::machine_start() diff --git a/src/mame/namco/namcos11.cpp b/src/mame/namco/namcos11.cpp index be8856df52d..294fba09a38 100644 --- a/src/mame/namco/namcos11.cpp +++ b/src/mame/namco/namcos11.cpp @@ -775,14 +775,13 @@ void namcos11_state::coh110(machine_config &config) SCREEN(config, "screen", SCREEN_TYPE_RASTER); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", 25401600, 288)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - //c352.add_route(2, "lspeaker", 1.00); // Second DAC not present. - //c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + //c352.add_route(2, "speaker", 1.00); // Second DAC not present. + //c352.add_route(3, "speaker", 1.00); AT28C16(config, "at28c16", 0); } diff --git a/src/mame/namco/namcos12.cpp b/src/mame/namco/namcos12.cpp index 713c6d91cbf..203cee1f160 100644 --- a/src/mame/namco/namcos12.cpp +++ b/src/mame/namco/namcos12.cpp @@ -1191,14 +1191,13 @@ public: AT28C16(config, "at28c16", 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", 25401600, 288)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - //c352.add_route(2, "lspeaker", 1.00); // Second DAC not present. - //c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + //c352.add_route(2, "speaker", 1.00); // Second DAC not present. + //c352.add_route(3, "speaker", 1.00); } void aplarail(machine_config &config) ATTR_COLD @@ -1558,8 +1557,8 @@ public: coh700b(config); NAMCOS12_CDXA(config, m_cdxa_pcb, XTAL(14'745'600)); - m_cdxa_pcb->add_route(0, "lspeaker", 0.30); // roughly matched the volume of speaking lines between the CDXA audio vs non-CDXA audio - m_cdxa_pcb->add_route(1, "rspeaker", 0.30); + m_cdxa_pcb->add_route(0, "speaker", 0.30, 0); // roughly matched the volume of speaking lines between the CDXA audio vs non-CDXA audio + m_cdxa_pcb->add_route(1, "speaker", 0.30, 1); m_cdxa_pcb->psx_int10_callback().set("maincpu:irq", FUNC(psxirq_device::intin10)); } diff --git a/src/mame/namco/namcos2.cpp b/src/mame/namco/namcos2.cpp index 3dbfc3f441b..e9cfa29f8f8 100644 --- a/src/mame/namco/namcos2.cpp +++ b/src/mame/namco/namcos2.cpp @@ -1713,8 +1713,7 @@ void namcos2_state::configure_common_standard(machine_config &config) m_screen->set_raw(MAIN_OSC_CLOCK/8, 384, 0*8, 36*8, 264, 0*8, 28*8); m_screen->set_palette(m_c116); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); C140(config, m_c140, C140_SOUND_CLOCK); /* 21.333kHz */ m_c140->set_addrmap(0, &namcos2_state::c140_default_am); @@ -1820,10 +1819,10 @@ void namcos2_state::base_noio(machine_config &config) configure_c123tmap_standard(config); configure_namcos2_roz_standard(config); - m_c140->add_route(0, "lspeaker", 0.75); - m_c140->add_route(1, "rspeaker", 0.75); + m_c140->add_route(0, "speaker", 0.75, 0); + m_c140->add_route(1, "speaker", 0.75, 1); - YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 0.80).add_route(1, "rspeaker", 0.80); /* 3.579545MHz */ + YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 0.80, 0).add_route(1, "speaker", 0.80, 1); /* 3.579545MHz */ } @@ -1844,8 +1843,8 @@ void namcos2_state::base2(machine_config &config) base(config); m_c140->reset_routes(); - m_c140->add_route(0, "lspeaker", 1.0); - m_c140->add_route(1, "rspeaker", 1.0); + m_c140->add_route(0, "speaker", 1.0, 0); + m_c140->add_route(1, "speaker", 1.0, 1); } void namcos2_state::assaultp(machine_config &config) @@ -1860,10 +1859,10 @@ void namcos2_state::base3(machine_config &config) base(config); m_c140->reset_routes(); - m_c140->add_route(0, "lspeaker", 0.45); - m_c140->add_route(1, "rspeaker", 0.45); + m_c140->add_route(0, "speaker", 0.45, 0); + m_c140->add_route(1, "speaker", 0.45, 1); - YM2151(config.replace(), "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); /* 3.579545MHz */ + YM2151(config.replace(), "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); /* 3.579545MHz */ } @@ -1887,10 +1886,10 @@ void namcos2_state::finallap_noio(machine_config &config) configure_c123tmap_standard(config); configure_c45road_standard(config); - m_c140->add_route(0, "lspeaker", 0.75); - m_c140->add_route(1, "rspeaker", 0.75); + m_c140->add_route(0, "speaker", 0.75, 0); + m_c140->add_route(1, "speaker", 0.75, 1); - YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 0.80).add_route(1, "rspeaker", 0.80); /* 3.579545MHz */ + YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 0.80, 0).add_route(1, "speaker", 0.80, 1); /* 3.579545MHz */ } void namcos2_state::base_fl(machine_config &config) @@ -1954,10 +1953,10 @@ void namcos2_state::sgunner(machine_config &config) MCFG_VIDEO_START_OVERRIDE(namcos2_state, sgunner) - m_c140->add_route(0, "lspeaker", 0.75); - m_c140->add_route(1, "rspeaker", 0.75); + m_c140->add_route(0, "speaker", 0.75, 0); + m_c140->add_route(1, "speaker", 0.75, 1); - YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 0.80).add_route(1, "rspeaker", 0.80); /* 3.579545MHz */ + YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 0.80, 0).add_route(1, "speaker", 0.80, 1); /* 3.579545MHz */ } void namcos2_state::sgunner2(machine_config &config) @@ -1983,10 +1982,10 @@ void namcos2_state::sgunner2(machine_config &config) MCFG_VIDEO_START_OVERRIDE(namcos2_state, sgunner) - m_c140->add_route(0, "lspeaker", 0.75); - m_c140->add_route(1, "rspeaker", 0.75); + m_c140->add_route(0, "speaker", 0.75, 0); + m_c140->add_route(1, "speaker", 0.75, 1); - YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 0.80).add_route(1, "rspeaker", 0.80); /* 3.579545MHz */ + YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 0.80, 0).add_route(1, "speaker", 0.80, 1); /* 3.579545MHz */ } void namcos2_state::suzuka8h(machine_config &config) @@ -2016,10 +2015,10 @@ void namcos2_state::suzuka8h(machine_config &config) MCFG_VIDEO_START_OVERRIDE(namcos2_state, luckywld) - m_c140->add_route(0, "lspeaker", 0.75); - m_c140->add_route(1, "rspeaker", 0.75); + m_c140->add_route(0, "speaker", 0.75, 0); + m_c140->add_route(1, "speaker", 0.75, 1); - YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 0.80).add_route(1, "rspeaker", 0.80); /* 3.579545MHz */ + YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 0.80, 0).add_route(1, "speaker", 0.80, 1); /* 3.579545MHz */ } void namcos2_state::luckywld(machine_config &config) @@ -2061,10 +2060,10 @@ void namcos2_state::metlhawk(machine_config &config) MCFG_VIDEO_START_OVERRIDE(namcos2_state, metlhawk) - m_c140->add_route(0, "lspeaker", 1.0); - m_c140->add_route(1, "rspeaker", 1.0); + m_c140->add_route(0, "speaker", 1.0, 0); + m_c140->add_route(1, "speaker", 1.0, 1); - YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "lspeaker", 0.80).add_route(1, "rspeaker", 0.80); /* 3.579545MHz */ + YM2151(config, "ymsnd", YM2151_SOUND_CLOCK).add_route(0, "speaker", 0.80, 0).add_route(1, "speaker", 0.80, 1); /* 3.579545MHz */ // ymsnd.irq_handler().set_inputline("audiocpu", 1); } diff --git a/src/mame/namco/namcos21.cpp b/src/mame/namco/namcos21.cpp index f54550b1d28..50a66156140 100644 --- a/src/mame/namco/namcos21.cpp +++ b/src/mame/namco/namcos21.cpp @@ -923,16 +923,15 @@ void namcos21_state::winrun(machine_config &config) m_namcos21_3d->set_depth_reverse(true); m_namcos21_3d->set_framebuffer_size(496,480); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); C140(config, m_c140, 49.152_MHz_XTAL / 2304); m_c140->set_addrmap(0, &namcos21_state::c140_map); m_c140->int1_callback().set_inputline(m_audiocpu, M6809_FIRQ_LINE); - m_c140->add_route(0, "lspeaker", 0.50); - m_c140->add_route(1, "rspeaker", 0.50); + m_c140->add_route(0, "speaker", 0.50, 0); + m_c140->add_route(1, "speaker", 0.50, 1); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 0.30).add_route(1, "rspeaker", 0.30); + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 0.30, 0).add_route(1, "speaker", 0.30, 1); } diff --git a/src/mame/namco/namcos21_c67.cpp b/src/mame/namco/namcos21_c67.cpp index 927cb1fef69..4ac77ad478e 100644 --- a/src/mame/namco/namcos21_c67.cpp +++ b/src/mame/namco/namcos21_c67.cpp @@ -840,16 +840,15 @@ void namcos21_c67_state::namcos21(machine_config &config) m_c355spr->set_color_base(0x1000); m_c355spr->set_external_prifill(true); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); C140(config, m_c140, 49.152_MHz_XTAL / 2304); m_c140->set_addrmap(0, &namcos21_c67_state::c140_map); m_c140->int1_callback().set_inputline(m_audiocpu, M6809_FIRQ_LINE); - m_c140->add_route(0, "lspeaker", 0.50); - m_c140->add_route(1, "rspeaker", 0.50); + m_c140->add_route(0, "speaker", 0.50, 0); + m_c140->add_route(1, "speaker", 0.50, 1); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 0.30).add_route(1, "rspeaker", 0.30); + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 0.30, 0).add_route(1, "speaker", 0.30, 1); } void namcos21_c67_state::aircomb(machine_config &config) diff --git a/src/mame/namco/namcos21_de.cpp b/src/mame/namco/namcos21_de.cpp index 8bb7565ea8c..6b41f9c75ce 100644 --- a/src/mame/namco/namcos21_de.cpp +++ b/src/mame/namco/namcos21_de.cpp @@ -201,16 +201,15 @@ void namco_de_pcbstack_device::device_add_mconfig(machine_config &config) m_c355spr->set_color_base(0x1000); m_c355spr->set_external_prifill(true); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); C140(config, m_c140, 49.152_MHz_XTAL / 2304); m_c140->set_addrmap(0, &namco_de_pcbstack_device::c140_map); m_c140->int1_callback().set_inputline(m_audiocpu, M6809_FIRQ_LINE); - m_c140->add_route(0, "lspeaker", 0.50); - m_c140->add_route(1, "rspeaker", 0.50); + m_c140->add_route(0, "speaker", 0.50, 0); + m_c140->add_route(1, "speaker", 0.50, 1); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 0.30).add_route(1, "rspeaker", 0.30); + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 0.30, 0).add_route(1, "speaker", 0.30, 1); } diff --git a/src/mame/namco/namcos22.cpp b/src/mame/namco/namcos22.cpp index e44cc4d40a0..777bde6e38a 100644 --- a/src/mame/namco/namcos22.cpp +++ b/src/mame/namco/namcos22.cpp @@ -3787,12 +3787,11 @@ void namcos22_state::namcos22(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_namcos22); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); C352(config, m_c352, 49.152_MHz_XTAL/2, 288); - m_c352->add_route(0, "lspeaker", 1.0); - m_c352->add_route(1, "rspeaker", 1.0); + m_c352->add_route(0, "speaker", 1.0, 0); + m_c352->add_route(1, "speaker", 1.0, 1); } void namcos22_state::cybrcomm(machine_config &config) diff --git a/src/mame/namco/namcos23.cpp b/src/mame/namco/namcos23.cpp index 0cebfe9efae..ca36fc6b82e 100644 --- a/src/mame/namco/namcos23.cpp +++ b/src/mame/namco/namcos23.cpp @@ -6177,14 +6177,13 @@ void gorgon_state::gorgon(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_gorgon); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", C352CLOCK, C352DIV)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - c352.add_route(2, "lspeaker", 1.00); - c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + c352.add_route(2, "speaker", 1.00, 0); + c352.add_route(3, "speaker", 1.00, 1); JVS_PORT(config, m_jvs, jvs_port_devices, nullptr); m_jvs->rxd().set(m_subcpu, FUNC(h8_device::sci_rx_w<0>)); @@ -6254,14 +6253,13 @@ void namcos23_state::s23(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_namcos23); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", C352CLOCK, C352DIV)); - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - c352.add_route(2, "lspeaker", 1.00); - c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + c352.add_route(2, "speaker", 1.00, 0); + c352.add_route(3, "speaker", 1.00, 1); JVS_PORT(config, m_jvs, jvs_port_devices, nullptr); m_jvs->rxd().set(m_subcpu, FUNC(h8_device::sci_rx_w<0>)); diff --git a/src/mame/namco/polepos.cpp b/src/mame/namco/polepos.cpp index a0e5b05ff14..af62e4eb396 100644 --- a/src/mame/namco/polepos.cpp +++ b/src/mame/namco/polepos.cpp @@ -932,24 +932,23 @@ void polepos_state::polepos(machine_config &config) config.set_default_layout(layout_polepos); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); NAMCO(config, m_namco_sound, MASTER_CLOCK/512); m_namco_sound->set_voices(8); m_namco_sound->set_stereo(true); - m_namco_sound->add_route(0, "lspeaker", 0.80); - m_namco_sound->add_route(1, "rspeaker", 0.80); + m_namco_sound->add_route(0, "speaker", 0.80, 0); + m_namco_sound->add_route(1, "speaker", 0.80, 1); /* discrete circuit on the 54XX outputs */ discrete_sound_device &discrete(DISCRETE(config, "discrete", polepos_discrete)); - discrete.add_route(ALL_OUTPUTS, "lspeaker", 0.90); - discrete.add_route(ALL_OUTPUTS, "rspeaker", 0.90); + discrete.add_route(ALL_OUTPUTS, "speaker", 0.90, 0); + discrete.add_route(ALL_OUTPUTS, "speaker", 0.90, 1); /* engine sound */ polepos_sound_device &polepos(POLEPOS_SOUND(config, "polepos", MASTER_CLOCK/8)); - polepos.add_route(ALL_OUTPUTS, "lspeaker", 0.90 * 0.77); - polepos.add_route(ALL_OUTPUTS, "rspeaker", 0.90 * 0.77); + polepos.add_route(ALL_OUTPUTS, "speaker", 0.90 * 0.77, 0); + polepos.add_route(ALL_OUTPUTS, "speaker", 0.90 * 0.77, 1); } void polepos_state::bootleg_soundlatch_w(uint8_t data) @@ -1040,23 +1039,22 @@ void polepos_state::topracern(machine_config &config) config.set_default_layout(layout_topracer); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); NAMCO(config, m_namco_sound, MASTER_CLOCK/512); m_namco_sound->set_voices(8); m_namco_sound->set_stereo(true); - m_namco_sound->add_route(0, "lspeaker", 0.80); - m_namco_sound->add_route(1, "rspeaker", 0.80); + m_namco_sound->add_route(0, "speaker", 0.80, 0); + m_namco_sound->add_route(1, "speaker", 0.80, 1); /* engine sound */ polepos_sound_device &polepos(POLEPOS_SOUND(config, "polepos", 0)); - polepos.add_route(ALL_OUTPUTS, "lspeaker", 0.90 * 0.77); - polepos.add_route(ALL_OUTPUTS, "rspeaker", 0.90 * 0.77); + polepos.add_route(ALL_OUTPUTS, "speaker", 0.90 * 0.77, 0); + polepos.add_route(ALL_OUTPUTS, "speaker", 0.90 * 0.77, 1); dac_4bit_r2r_device &dac(DAC_4BIT_R2R(config, "dac", 0)); // unknown resistor configuration - dac.add_route(ALL_OUTPUTS, "lspeaker", 0.12); - dac.add_route(ALL_OUTPUTS, "rspeaker", 0.12); + dac.add_route(ALL_OUTPUTS, "speaker", 0.12, 0); + dac.add_route(ALL_OUTPUTS, "speaker", 0.12, 1); } void polepos_state::polepos2bi(machine_config &config) @@ -1072,8 +1070,8 @@ void polepos_state::polepos2bi(machine_config &config) m_soundlatch->set_separate_acknowledge(true); TMS5220(config, "tms", 600000) /* ? Mhz */ - .add_route(ALL_OUTPUTS, "lspeaker", 0.80) - .add_route(ALL_OUTPUTS, "rspeaker", 0.80); + .add_route(ALL_OUTPUTS, "speaker", 0.80, 0) + .add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } diff --git a/src/mame/namco/polepos_a.cpp b/src/mame/namco/polepos_a.cpp index 95a52451207..2e8b353cca4 100644 --- a/src/mame/namco/polepos_a.cpp +++ b/src/mame/namco/polepos_a.cpp @@ -254,20 +254,16 @@ void polepos_sound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void polepos_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void polepos_sound_device::sound_stream_update(sound_stream &stream) { uint32_t step, clock, slot; uint8_t *base; double volume, i_total; - auto &buffer = outputs[0]; int loop; /* if we're not enabled, just fill with 0 */ if (!m_sample_enable) - { - buffer.fill(0); return; - } /* determine the effective clock rate */ clock = (unscaled_clock() / 16) * ((m_sample_msb + 1) * 64 + m_sample_lsb + 1) / (64*64); @@ -279,7 +275,7 @@ void polepos_sound_device::sound_stream_update(sound_stream &stream, std::vector base = &machine().root_device().memregion("engine")->base()[slot * 0x800]; /* fill in the sample */ - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { m_filter_engine[0].x0 = (3.4 / 255 * base[(m_current_position >> 12) & 0x7ff] - 2) * volume; m_filter_engine[1].x0 = m_filter_engine[0].x0; @@ -298,7 +294,7 @@ void polepos_sound_device::sound_stream_update(sound_stream &stream, std::vector } i_total *= r_filt_total/2; /* now contains voltage adjusted by final gain */ - buffer.put(sampindex, i_total); + stream.put(0, sampindex, i_total); m_current_position += step; } } diff --git a/src/mame/namco/polepos_a.h b/src/mame/namco/polepos_a.h index 069a1d796c5..4033f6698d8 100644 --- a/src/mame/namco/polepos_a.h +++ b/src/mame/namco/polepos_a.h @@ -19,7 +19,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; public: void clson_w(int state); diff --git a/src/mame/namco/sweetland4.cpp b/src/mame/namco/sweetland4.cpp index 4155c960aad..007ff6e3017 100644 --- a/src/mame/namco/sweetland4.cpp +++ b/src/mame/namco/sweetland4.cpp @@ -134,24 +134,22 @@ void sweetland4_state::sweetland4(machine_config &config) RTC72423(config, "rtc", 32'768); // no evident XTAL on PCB - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", 4'096'000)); // no evident XTAL on PCB - oki.add_route(0, "lspeaker", 1.00); - oki.add_route(1, "rspeaker", 1.00); + oki.add_route(0, "speaker", 1.00, 0); + oki.add_route(1, "speaker", 1.00, 1); } void sweetland4_state::tairyodk(machine_config &config) { H83002(config, m_maincpu, 14.746_MHz_XTAL); // H8/3002 6413002F17 - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", 4.096_MHz_XTAL)); - oki.add_route(0, "lspeaker", 1.00); - oki.add_route(1, "rspeaker", 1.00); + oki.add_route(0, "speaker", 1.00, 0); + oki.add_route(1, "speaker", 1.00, 1); } diff --git a/src/mame/namco/tceptor.cpp b/src/mame/namco/tceptor.cpp index 226b9432f70..6741981c454 100644 --- a/src/mame/namco/tceptor.cpp +++ b/src/mame/namco/tceptor.cpp @@ -333,22 +333,21 @@ void tceptor_state::tceptor(machine_config &config) m_screen->set_palette(m_palette); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ym(YM2151(config, "ymsnd", XTAL(14'318'181)/4)); - ym.add_route(0, "lspeaker", 1.0); - ym.add_route(1, "rspeaker", 1.0); + ym.add_route(0, "speaker", 1.0, 0); + ym.add_route(1, "speaker", 1.0, 1); NAMCO_CUS30(config, m_cus30, XTAL(49'152'000)/2048); m_cus30->set_voices(8); m_cus30->set_stereo(true); - m_cus30->add_route(0, "lspeaker", 0.40); - m_cus30->add_route(1, "rspeaker", 0.40); + m_cus30->add_route(0, "speaker", 0.40, 0); + m_cus30->add_route(1, "speaker", 0.40, 1); dac_8bit_r2r_device &dac(DAC_8BIT_R2R(config, "dac", 0)); // unknown DAC - dac.add_route(ALL_OUTPUTS, "lspeaker", 0.4); - dac.add_route(ALL_OUTPUTS, "rspeaker", 0.4); + dac.add_route(ALL_OUTPUTS, "speaker", 0.4, 0); + dac.add_route(ALL_OUTPUTS, "speaker", 0.4, 1); } diff --git a/src/mame/namco/turrett.cpp b/src/mame/namco/turrett.cpp index f4221b7e5b3..cdf913d5f36 100644 --- a/src/mame/namco/turrett.cpp +++ b/src/mame/namco/turrett.cpp @@ -372,13 +372,12 @@ void turrett_state::turrett(machine_config &config) PALETTE(config, "palette", palette_device::RGB_555); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); turrett_device &ttsound(TURRETT(config, "ttsound", R3041_CLOCK)); // ? ttsound.set_addrmap(0, &turrett_state::turrett_sound_map); - ttsound.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - ttsound.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + ttsound.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + ttsound.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/namco/turrett.h b/src/mame/namco/turrett.h index 78fc37228a2..e4b755e25ac 100644 --- a/src/mame/namco/turrett.h +++ b/src/mame/namco/turrett.h @@ -121,7 +121,7 @@ protected: virtual void device_reset() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; // device_memory_interface overrides virtual space_config_vector memory_space_config() const override; diff --git a/src/mame/namco/turrett_a.cpp b/src/mame/namco/turrett_a.cpp index 72d0d61e35d..5d919b680d7 100644 --- a/src/mame/namco/turrett_a.cpp +++ b/src/mame/namco/turrett_a.cpp @@ -81,12 +81,8 @@ void turrett_device::device_reset() // sound_stream_update - update sound stream //------------------------------------------------- -void turrett_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void turrett_device::sound_stream_update(sound_stream &stream) { - // Silence the buffers - outputs[0].fill(0); - outputs[1].fill(0); - for (int ch = 0; ch < SOUND_CHANNELS; ++ch) { if (m_channels[ch].m_playing) @@ -101,7 +97,7 @@ void turrett_device::sound_stream_update(sound_stream &stream, std::vector<read_ // Channels 30 and 31 expect interleaved stereo samples uint32_t incr = (ch >= 30) ? 2 : 1; - for (int s = 0; s < outputs[0].samples(); ++s) + for (int s = 0; s < stream.samples(); ++s) { int16_t sample = m_cache.read_word(addr << 1); @@ -113,8 +109,8 @@ void turrett_device::sound_stream_update(sound_stream &stream, std::vector<read_ addr += incr; - outputs[0].add_int(s, (sample * lvol) >> 17, 32768); - outputs[1].add_int(s, (sample * rvol) >> 17, 32768); + stream.add_int(0, s, (sample * lvol) >> 17, 32768); + stream.add_int(1, s, (sample * rvol) >> 17, 32768); } } } diff --git a/src/mame/namco/warpwarp_a.cpp b/src/mame/namco/warpwarp_a.cpp index 79a3c06936a..f6e119a86f8 100644 --- a/src/mame/namco/warpwarp_a.cpp +++ b/src/mame/namco/warpwarp_a.cpp @@ -168,13 +168,11 @@ void warpwarp_sound_device::music2_w(u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void warpwarp_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void warpwarp_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - buffer.put_int(sampindex, m_sound_signal + m_music_signal, 32768 * 2); + stream.put_int(0, sampindex, m_sound_signal + m_music_signal, 32768 * 2); /* * The music signal is selected at a rate of 2H (1.536MHz) from the diff --git a/src/mame/namco/warpwarp_a.h b/src/mame/namco/warpwarp_a.h index 1f7e3f76e27..2f235146dc9 100644 --- a/src/mame/namco/warpwarp_a.h +++ b/src/mame/namco/warpwarp_a.h @@ -19,7 +19,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(sound_decay_tick); TIMER_CALLBACK_MEMBER(music_decay_tick); diff --git a/src/mame/nec/pc8801.cpp b/src/mame/nec/pc8801.cpp index 1895e6a0ece..ef12be03b27 100644 --- a/src/mame/nec/pc8801.cpp +++ b/src/mame/nec/pc8801.cpp @@ -1706,18 +1706,16 @@ void pc8801_state::pc8801(machine_config &config) // Note: original models up to OPNA variants really have an internal mono speaker, // but user eventually can have a stereo mixing audio card mounted so for simplicity we MCM here. - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); // TODO: DAC_1BIT // 2400 Hz according to schematics, unaffected by clock speed setting (confirmed on real HW) BEEP(config, m_beeper, MASTER_CLOCK / 16 / 13 / 8); - for (auto &speaker : { m_lspeaker, m_rspeaker }) - { - m_cassette->add_route(ALL_OUTPUTS, speaker, 0.025); - m_beeper->add_route(ALL_OUTPUTS, speaker, 0.10); - } + m_cassette->add_route(ALL_OUTPUTS, m_speaker, 0.025, 0); + m_cassette->add_route(ALL_OUTPUTS, m_speaker, 0.025, 1); + m_beeper->add_route(ALL_OUTPUTS, m_speaker, 0.10, 0); + m_beeper->add_route(ALL_OUTPUTS, m_speaker, 0.10, 1); MSX_GENERAL_PURPOSE_PORT(config, m_mouse_port, msx_general_purpose_port_devices, "joystick"); @@ -1738,14 +1736,15 @@ void pc8801mk2sr_state::pc8801mk2sr(machine_config &config) m_opn->port_b_read_callback().set(FUNC(pc8801mk2sr_state::opn_portb_r)); m_opn->port_b_write_callback().set(FUNC(pc8801mk2sr_state::opn_portb_w)); - for (auto &speaker : { m_lspeaker, m_rspeaker }) - { - // TODO: per-channel mixing is unconfirmed - m_opn->add_route(0, speaker, 0.125); - m_opn->add_route(1, speaker, 0.125); - m_opn->add_route(2, speaker, 0.125); - m_opn->add_route(3, speaker, 0.125); - } + // TODO: per-channel mixing is unconfirmed + m_opn->add_route(0, m_speaker, 0.125, 0); + m_opn->add_route(1, m_speaker, 0.125, 0); + m_opn->add_route(2, m_speaker, 0.125, 0); + m_opn->add_route(3, m_speaker, 0.125, 0); + m_opn->add_route(0, m_speaker, 0.125, 1); + m_opn->add_route(1, m_speaker, 0.125, 1); + m_opn->add_route(2, m_speaker, 0.125, 1); + m_opn->add_route(3, m_speaker, 0.125, 1); } void pc8801mk2sr_state::pc8801mk2mr(machine_config &config) @@ -1768,10 +1767,10 @@ void pc8801fh_state::pc8801fh(machine_config &config) m_opna->port_b_write_callback().set(FUNC(pc8801fh_state::opn_portb_w)); // TODO: per-channel mixing is unconfirmed - m_opna->add_route(0, m_lspeaker, 0.25); - m_opna->add_route(0, m_rspeaker, 0.25); - m_opna->add_route(1, m_lspeaker, 0.75); - m_opna->add_route(2, m_rspeaker, 0.75); + m_opna->add_route(0, m_speaker, 0.25, 0); + m_opna->add_route(0, m_speaker, 0.25, 1); + m_opna->add_route(1, m_speaker, 0.75, 0); + m_opna->add_route(2, m_speaker, 0.75, 1); // TODO: add possible configuration override for baudrate here // ... diff --git a/src/mame/nec/pc8801.h b/src/mame/nec/pc8801.h index 7b9d5114426..68465a8934c 100644 --- a/src/mame/nec/pc8801.h +++ b/src/mame/nec/pc8801.h @@ -49,8 +49,7 @@ public: , m_usart(*this, "usart") // , m_cassette(*this, "cassette") , m_beeper(*this, "beeper") - , m_lspeaker(*this, "lspeaker") - , m_rspeaker(*this, "rspeaker") + , m_speaker(*this, "speaker") , m_palette(*this, "palette") , m_n80rom(*this, "n80rom") , m_n88rom(*this, "n88rom") @@ -91,8 +90,7 @@ protected: required_device<i8251_device> m_usart; // required_device<cassette_image_device> m_cassette; required_device<beep_device> m_beeper; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<speaker_device> m_speaker; required_device<palette_device> m_palette; required_region_ptr<u8> m_n80rom; required_region_ptr<u8> m_n88rom; diff --git a/src/mame/nec/pc88va.cpp b/src/mame/nec/pc88va.cpp index 01c5828c9c6..bef7285dd8a 100644 --- a/src/mame/nec/pc88va.cpp +++ b/src/mame/nec/pc88va.cpp @@ -1503,8 +1503,7 @@ void pc88va_state::pc88va(machine_config &config) MSX_GENERAL_PURPOSE_PORT(config, m_mouse_port, msx_general_purpose_port_devices, "joystick"); - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker).front(); // TODO: YM2203 for vanilla pc88va // PC-88VA-12 "Sound Board II", YM2608B @@ -1515,10 +1514,10 @@ void pc88va_state::pc88va(machine_config &config) m_opna->port_b_read_callback().set(FUNC(pc88va_state::opn_portb_r)); m_opna->port_b_write_callback().set(FUNC(pc88va_state::opn_portb_w)); // TODO: per-channel mixing is unconfirmed - m_opna->add_route(0, m_lspeaker, 0.25); - m_opna->add_route(0, m_rspeaker, 0.25); - m_opna->add_route(1, m_lspeaker, 0.75); - m_opna->add_route(2, m_rspeaker, 0.75); + m_opna->add_route(0, m_speaker, 0.25, 0); + m_opna->add_route(0, m_speaker, 0.25, 1); + m_opna->add_route(1, m_speaker, 0.75, 0); + m_opna->add_route(2, m_speaker, 0.75, 1); // TODO: set pc98 compatible // Needs a MS-Engine disk dump first, that applies an overlay on PC Engine OS so that it can run PC-98 software diff --git a/src/mame/nec/pc88va.h b/src/mame/nec/pc88va.h index 42d92d8650d..572ff1480c5 100644 --- a/src/mame/nec/pc88va.h +++ b/src/mame/nec/pc88va.h @@ -65,8 +65,7 @@ public: , m_cbus(*this, "cbus%d", 0) , m_mouse_port(*this, "mouseport") // labelled "マウス" (mouse) - can't use "mouse" because of core -mouse option , m_opna(*this, "opna") - , m_lspeaker(*this, "lspeaker") - , m_rspeaker(*this, "rspeaker") + , m_speaker(*this, "speaker") , m_palram(*this, "palram") , m_sysbank(*this, "sysbank") , m_workram(*this, "workram") @@ -136,8 +135,7 @@ private: required_device_array<pc9801_slot_device, 2> m_cbus; required_device<msx_general_purpose_port_device> m_mouse_port; required_device<ym2608_device> m_opna; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<speaker_device> m_speaker; required_shared_ptr<uint16_t> m_palram; required_device<address_map_bank_device> m_sysbank; required_shared_ptr<uint16_t> m_workram; diff --git a/src/mame/nec/pce.cpp b/src/mame/nec/pce.cpp index 99ae503303a..3cffb9a5a8a 100644 --- a/src/mame/nec/pce.cpp +++ b/src/mame/nec/pce.cpp @@ -190,8 +190,8 @@ void pce_state::pce_common(machine_config &config) m_maincpu->set_addrmap(AS_IO, &pce_state::pce_io); m_maincpu->port_in_cb().set(FUNC(pce_state::controller_r)); m_maincpu->port_out_cb().set(FUNC(pce_state::controller_w)); - m_maincpu->add_route(0, "lspeaker", 1.00); - m_maincpu->add_route(1, "rspeaker", 1.00); + m_maincpu->add_route(0, "speaker", 1.00, 0); + m_maincpu->add_route(1, "speaker", 1.00, 1); config.set_maximum_quantum(attotime::from_hz(60)); @@ -211,8 +211,7 @@ void pce_state::pce_common(machine_config &config) huc6270.set_vram_size(0x10000); huc6270.irq().set_inputline(m_maincpu, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); PCE_CONTROL_PORT(config, m_port_ctrl, pce_control_port_devices, "joypad2"); @@ -220,8 +219,8 @@ void pce_state::pce_common(machine_config &config) PCE_CD(config, m_cd, 0); m_cd->irq().set_inputline(m_maincpu, 1); m_cd->set_maincpu(m_maincpu); - m_cd->add_route(0, "lspeaker", 1.0); - m_cd->add_route(1, "rspeaker", 1.0); + m_cd->add_route(0, "speaker", 1.0, 0); + m_cd->add_route(1, "speaker", 1.0, 1); SOFTWARE_LIST(config, "cd_list").set_original("pcecd"); } @@ -258,8 +257,8 @@ void pce_state::sgx(machine_config &config) m_maincpu->set_addrmap(AS_IO, &pce_state::sgx_io); m_maincpu->port_in_cb().set(FUNC(pce_state::controller_r)); m_maincpu->port_out_cb().set(FUNC(pce_state::controller_w)); - m_maincpu->add_route(0, "lspeaker", 1.00); - m_maincpu->add_route(1, "rspeaker", 1.00); + m_maincpu->add_route(0, "speaker", 1.00, 0); + m_maincpu->add_route(1, "speaker", 1.00, 1); config.set_maximum_quantum(attotime::from_hz(60)); @@ -297,8 +296,7 @@ void pce_state::sgx(machine_config &config) huc6202.read_1_callback().set("huc6270_1", FUNC(huc6270_device::read)); huc6202.write_1_callback().set("huc6270_1", FUNC(huc6270_device::write)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // turbo pad bundled PCE_CONTROL_PORT(config, m_port_ctrl, pce_control_port_devices, "joypad2_turbo"); @@ -312,8 +310,8 @@ void pce_state::sgx(machine_config &config) PCE_CD(config, m_cd, 0); m_cd->irq().set_inputline(m_maincpu, 1); m_cd->set_maincpu(m_maincpu); - m_cd->add_route(0, "lspeaker", 1.0); - m_cd->add_route(1, "rspeaker", 1.0); + m_cd->add_route(0, "speaker", 1.0, 0); + m_cd->add_route(1, "speaker", 1.0, 1); SOFTWARE_LIST(config, "cd_list").set_original("pcecd"); } diff --git a/src/mame/nec/pce_cd.cpp b/src/mame/nec/pce_cd.cpp index 7785200ce69..54ccffdf7de 100644 --- a/src/mame/nec/pce_cd.cpp +++ b/src/mame/nec/pce_cd.cpp @@ -82,7 +82,7 @@ void pce_cd_device::regs_map(address_map &map) pce_cd_device::pce_cd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, PCE_CD, tag, owner, clock) , device_memory_interface(mconfig, *this) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_space_config("io", ENDIANNESS_LITTLE, 8, 4, 0, address_map_constructor(FUNC(pce_cd_device::regs_map), this)) , m_maincpu(*this, finder_base::DUMMY_TAG) , m_irq_cb(*this) @@ -263,14 +263,14 @@ void pce_cd_device::device_add_mconfig(machine_config &config) MSM5205(config, m_msm, PCE_CD_CLOCK / 6); m_msm->vck_legacy_callback().set(FUNC(pce_cd_device::msm5205_int)); /* interrupt function */ m_msm->set_prescaler_selector(msm5205_device::S48_4B); /* 1/48 prescaler, 4bit data */ - m_msm->add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 0); - m_msm->add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 1); + m_msm->add_route(ALL_OUTPUTS, *this, 0.50, 0); + m_msm->add_route(ALL_OUTPUTS, *this, 0.50, 1); CDDA(config, m_cdda); m_cdda->set_cdrom_tag(m_cdrom); m_cdda->audio_end_cb().set(FUNC(pce_cd_device::cdda_end_mark_cb)); - m_cdda->add_route(0, *this, 1.00, AUTO_ALLOC_INPUT, 0); - m_cdda->add_route(1, *this, 1.00, AUTO_ALLOC_INPUT, 1); + m_cdda->add_route(0, *this, 1.00, 0); + m_cdda->add_route(1, *this, 1.00, 1); } void pce_cd_device::adpcm_stop(uint8_t irq_flag) diff --git a/src/mame/nec/pcfx.cpp b/src/mame/nec/pcfx.cpp index 4c2d7b0c5c2..74839194b62 100644 --- a/src/mame/nec/pcfx.cpp +++ b/src/mame/nec/pcfx.cpp @@ -453,15 +453,14 @@ void pcfx_state::pcfx(machine_config &config) SOFTWARE_LIST(config, "cd_list").set_original("pcfx"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); huc6230_device &huc6230(HuC6230(config, "huc6230", XTAL(21'477'272))); huc6230.adpcm_update_cb<0>().set("huc6272", FUNC(huc6272_device::adpcm_update_0)); huc6230.adpcm_update_cb<1>().set("huc6272", FUNC(huc6272_device::adpcm_update_1)); huc6230.vca_callback().set("huc6272", FUNC(huc6272_device::cdda_update)); - huc6230.add_route(0, "lspeaker", 1.0); - huc6230.add_route(1, "rspeaker", 1.0); + huc6230.add_route(0, "speaker", 1.0, 0); + huc6230.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/neogeo/midas.cpp b/src/mame/neogeo/midas.cpp index d4fa0b0a088..9b13ff10010 100644 --- a/src/mame/neogeo/midas.cpp +++ b/src/mame/neogeo/midas.cpp @@ -671,12 +671,11 @@ void midas_state::livequiz(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_888, 0x10000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); - ymz.add_route(0, "lspeaker", 0.80); - ymz.add_route(1, "rspeaker", 0.80); + ymz.add_route(0, "speaker", 0.80, 0); + ymz.add_route(1, "speaker", 0.80, 1); } void hammer_state::hammer(machine_config &config) diff --git a/src/mame/neogeo/neogeo.cpp b/src/mame/neogeo/neogeo.cpp index abb05e81541..e4980fc40ae 100644 --- a/src/mame/neogeo/neogeo.cpp +++ b/src/mame/neogeo/neogeo.cpp @@ -1968,13 +1968,12 @@ void neogeo_base_state::neogeo_base(machine_config &config) void neogeo_base_state::neogeo_stereo(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_ym->add_route(0, "lspeaker", 0.28); - m_ym->add_route(0, "rspeaker", 0.28); - m_ym->add_route(1, "lspeaker", 0.98); - m_ym->add_route(2, "rspeaker", 0.98); + m_ym->add_route(0, "speaker", 0.28, 0); + m_ym->add_route(0, "speaker", 0.28, 1); + m_ym->add_route(1, "speaker", 0.98, 0); + m_ym->add_route(2, "speaker", 0.98, 1); } diff --git a/src/mame/nichibutsu/gomoku_a.cpp b/src/mame/nichibutsu/gomoku_a.cpp index 30e08c94711..509e2cf087e 100644 --- a/src/mame/nichibutsu/gomoku_a.cpp +++ b/src/mame/nichibutsu/gomoku_a.cpp @@ -79,22 +79,18 @@ void gomoku_sound_device::device_start() // sound_stream_update - handle a stream update in mono //------------------------------------------------- -void gomoku_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gomoku_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; sound_channel *voice; short *mix; int ch; // if no sound, we're done if (m_sound_enable == 0) - { - buffer.fill(0); return; - } // zap the contents of the mixer buffer - std::fill_n(&m_mixer_buffer[0], buffer.samples(), 0); + std::fill_n(&m_mixer_buffer[0], stream.samples(), 0); // loop over each voice and add its contribution for (ch = 0, voice = std::begin(m_channel_list); voice < std::end(m_channel_list); ch++, voice++) @@ -116,7 +112,7 @@ void gomoku_sound_device::sound_stream_update(sound_stream &stream, std::vector< mix = &m_mixer_buffer[0]; // add our contribution - for (int i = 0; i < buffer.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { c += f; @@ -157,8 +153,8 @@ void gomoku_sound_device::sound_stream_update(sound_stream &stream, std::vector< // mix it down mix = &m_mixer_buffer[0]; - for (int i = 0; i < buffer.samples(); i++) - buffer.put_int(i, *mix++, 128 * MAX_VOICES); + for (int i = 0; i < stream.samples(); i++) + stream.put_int(0, i, *mix++, 128 * MAX_VOICES); } diff --git a/src/mame/nichibutsu/gomoku_a.h b/src/mame/nichibutsu/gomoku_a.h index 87497169cf8..01d017b4ae2 100644 --- a/src/mame/nichibutsu/gomoku_a.h +++ b/src/mame/nichibutsu/gomoku_a.h @@ -23,7 +23,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void make_mixer_table(int voices, int gain); diff --git a/src/mame/nichibutsu/hrdvd.cpp b/src/mame/nichibutsu/hrdvd.cpp index 2670170e97f..d15455ba29a 100644 --- a/src/mame/nichibutsu/hrdvd.cpp +++ b/src/mame/nichibutsu/hrdvd.cpp @@ -79,8 +79,7 @@ public: m_mpega(*this, "mpeg_audio"), m_pll(*this, "pll"), m_nichisnd(*this, "nichisnd"), - m_lspeaker(*this, "lspeaker"), - m_rspeaker(*this, "rspeaker"), + m_speaker(*this, "speaker"), m_screen(*this, "screen"), m_key(*this, "KEY.%u", 0), m_region_maincpu(*this, "maincpu") @@ -94,8 +93,7 @@ public: required_device<nn71003f_device> m_mpega; required_device<tc9223_device> m_pll; required_device<nichisnd_device> m_nichisnd; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<speaker_device> m_speaker; required_device<screen_device> m_screen; required_ioport_array<5> m_key; required_memory_region m_region_maincpu; @@ -516,16 +514,15 @@ void hrdvd_state::hrdvd(machine_config &config) m_mpeg->drq_w().set(FUNC(hrdvd_state::mpeg_dreq_w)); NN71003F(config, m_mpega, 0); - m_mpega->add_route(0, m_lspeaker, 1.0); - m_mpega->add_route(1, m_rspeaker, 1.0); + m_mpega->add_route(0, m_speaker, 1.0, 0); + m_mpega->add_route(1, m_speaker, 1.0, 1); m_mpeg->sp2_frm_w().set(m_mpega, FUNC(nn71003f_device::frm_w)); m_mpeg->sp2_clk_w().set(m_mpega, FUNC(nn71003f_device::clk_w)); m_mpeg->sp2_dat_w().set(m_mpega, FUNC(nn71003f_device::dat_w)); NICHISND(config, m_nichisnd, 0); - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker, 2).front(); } diff --git a/src/mame/nichibutsu/wiping_a.cpp b/src/mame/nichibutsu/wiping_a.cpp index 8d43425f7d3..b82403e0f32 100644 --- a/src/mame/nichibutsu/wiping_a.cpp +++ b/src/mame/nichibutsu/wiping_a.cpp @@ -125,22 +125,18 @@ void wiping_sound_device::sound_w(offs_t offset, uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void wiping_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void wiping_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; wp_sound_channel *voice; short *mix; int i; /* if no sound, we're done */ if (m_sound_enable == 0) - { - buffer.fill(0); return; - } /* zap the contents of the mixer buffer */ - std::fill_n(&m_mixer_buffer[0], buffer.samples(), 0); + std::fill_n(&m_mixer_buffer[0], stream.samples(), 0); /* loop over each voice and add its contribution */ for (voice = m_channel_list; voice < m_last_channel; voice++) @@ -157,7 +153,7 @@ void wiping_sound_device::sound_stream_update(sound_stream &stream, std::vector< mix = &m_mixer_buffer[0]; /* add our contribution */ - for (i = 0; i < buffer.samples(); i++) + for (i = 0; i < stream.samples(); i++) { int offs; @@ -202,6 +198,6 @@ void wiping_sound_device::sound_stream_update(sound_stream &stream, std::vector< /* mix it down */ mix = &m_mixer_buffer[0]; - for (i = 0; i < buffer.samples(); i++) - buffer.put_int(i, *mix++, 128 * MAX_VOICES); + for (i = 0; i < stream.samples(); i++) + stream.put_int(0, i, *mix++, 128 * MAX_VOICES); } diff --git a/src/mame/nichibutsu/wiping_a.h b/src/mame/nichibutsu/wiping_a.h index 7794f7884bc..4a38a582b0c 100644 --- a/src/mame/nichibutsu/wiping_a.h +++ b/src/mame/nichibutsu/wiping_a.h @@ -17,7 +17,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // 8 voices max diff --git a/src/mame/nintendo/aleck64.cpp b/src/mame/nintendo/aleck64.cpp index 94935040290..449c8b71b9b 100644 --- a/src/mame/nintendo/aleck64.cpp +++ b/src/mame/nintendo/aleck64.cpp @@ -1060,11 +1060,10 @@ void aleck64_state::aleck64(machine_config &config) PALETTE(config, "palette").set_entries(0x1000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); N64PERIPH(config, m_rcp_periphs, 0); } diff --git a/src/mame/nintendo/gb.cpp b/src/mame/nintendo/gb.cpp index 878bb83c878..17b552aa546 100644 --- a/src/mame/nintendo/gb.cpp +++ b/src/mame/nintendo/gb.cpp @@ -1059,12 +1059,11 @@ void gb_state::gameboy(machine_config &config) DMG_PPU(config, m_ppu, m_maincpu); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DMG_APU(config, m_apu, MASTER_CLOCK); - m_apu->add_route(0, "lspeaker", 0.50); - m_apu->add_route(1, "rspeaker", 0.50); + m_apu->add_route(0, "speaker", 0.50, 0); + m_apu->add_route(1, "speaker", 0.50, 1); // cartslot GB_CART_SLOT(config, m_cartslot, gameboy_cartridges, nullptr); @@ -1098,12 +1097,11 @@ void sgb_state::supergb(machine_config &config) SGB_PPU(config, m_ppu, m_maincpu); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DMG_APU(config, m_apu, 4'295'454); - m_apu->add_route(0, "lspeaker", 0.50); - m_apu->add_route(1, "rspeaker", 0.50); + m_apu->add_route(0, "speaker", 0.50, 0); + m_apu->add_route(1, "speaker", 0.50, 1); // cartslot GB_CART_SLOT(config, m_cartslot, gameboy_cartridges, nullptr); @@ -1161,12 +1159,11 @@ void gbc_state::gbcolor(machine_config &config) CGB_PPU(config, m_ppu, m_maincpu); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); CGB04_APU(config, m_apu, GBC_CLOCK / 2); - m_apu->add_route(0, "lspeaker", 0.50); - m_apu->add_route(1, "rspeaker", 0.50); + m_apu->add_route(0, "speaker", 0.50, 0); + m_apu->add_route(1, "speaker", 0.50, 1); // cartslot GB_CART_SLOT(config, m_cartslot, gameboy_cartridges, nullptr); @@ -1199,11 +1196,10 @@ void megaduck_state::megaduck(machine_config &config) DMG_PPU(config, m_ppu, m_maincpu); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DMG_APU(config, m_apu, XTAL(4'194'304)); - m_apu->add_route(0, "lspeaker", 0.50); - m_apu->add_route(1, "rspeaker", 0.50); + m_apu->add_route(0, "speaker", 0.50, 0); + m_apu->add_route(1, "speaker", 0.50, 1); // cartslot MEGADUCK_CART_SLOT(config, m_cartslot, megaduck_cartridges, nullptr); diff --git a/src/mame/nintendo/gba.cpp b/src/mame/nintendo/gba.cpp index af5bdbba8e7..c9ab50537b1 100644 --- a/src/mame/nintendo/gba.cpp +++ b/src/mame/nintendo/gba.cpp @@ -1455,16 +1455,15 @@ void gba_state::gbadv(machine_config &config) lcd.dma_hblank_callback().set(FUNC(gba_state::dma_hblank_callback)); lcd.dma_vblank_callback().set(FUNC(gba_state::dma_vblank_callback)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AGB_APU(config, m_gbsound, 4.194304_MHz_XTAL); - m_gbsound->add_route(0, "lspeaker", 0.5); - m_gbsound->add_route(1, "rspeaker", 0.5); + m_gbsound->add_route(0, "speaker", 0.5, 0); + m_gbsound->add_route(1, "speaker", 0.5, 1); - DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_ldac[0], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_rdac[0], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_ldac[1], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_rdac[1], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_ldac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_rdac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC + DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_ldac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R_TWOS_COMPLEMENT(config, m_rdac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } diff --git a/src/mame/nintendo/n64.cpp b/src/mame/nintendo/n64.cpp index d6936a46b5c..ea389fdb726 100644 --- a/src/mame/nintendo/n64.cpp +++ b/src/mame/nintendo/n64.cpp @@ -420,11 +420,10 @@ void n64_console_state::n64(machine_config &config) PALETTE(config, "palette").set_entries(0x1000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); N64PERIPH(config, m_rcp_periphs, 0); diff --git a/src/mame/nintendo/n64_gateway.cpp b/src/mame/nintendo/n64_gateway.cpp index 59974992707..d3a33d5227c 100644 --- a/src/mame/nintendo/n64_gateway.cpp +++ b/src/mame/nintendo/n64_gateway.cpp @@ -341,11 +341,10 @@ void n64_gateway_state::n64_lodgenet(machine_config &config) PALETTE(config, "palette").set_entries(0x1000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); N64PERIPH(config, m_rcp_periphs, 0); diff --git a/src/mame/nintendo/nss.cpp b/src/mame/nintendo/nss.cpp index 27c381bea95..7d985c6042c 100644 --- a/src/mame/nintendo/nss.cpp +++ b/src/mame/nintendo/nss.cpp @@ -848,13 +848,12 @@ void nss_state::nss(machine_config &config) M6M80011AP(config, "m6m80011ap"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); S_DSP(config, m_s_dsp, XTAL(24'576'000)); m_s_dsp->set_addrmap(0, &nss_state::spc_map); - m_s_dsp->add_route(0, "lspeaker", 1.00); - m_s_dsp->add_route(1, "rspeaker", 1.00); + m_s_dsp->add_route(0, "speaker", 1.00, 0); + m_s_dsp->add_route(1, "speaker", 1.00, 1); /* video hardware */ /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs */ diff --git a/src/mame/nintendo/punchout.cpp b/src/mame/nintendo/punchout.cpp index fbe0d95bad3..f8649010ebc 100644 --- a/src/mame/nintendo/punchout.cpp +++ b/src/mame/nintendo/punchout.cpp @@ -652,16 +652,15 @@ void punchout_state::punchout(machine_config &config) bottom.set_palette(m_palette); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); GENERIC_LATCH_8(config, "soundlatch2"); VLM5030(config, m_vlm, RP2A03_NTSC_XTAL/6); m_vlm->set_addrmap(0, &punchout_state::punchout_vlm_map); - m_vlm->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_audiocpu->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vlm->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_audiocpu->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } diff --git a/src/mame/nintendo/sfcbox.cpp b/src/mame/nintendo/sfcbox.cpp index d4702cea3e4..2458dab5e7a 100644 --- a/src/mame/nintendo/sfcbox.cpp +++ b/src/mame/nintendo/sfcbox.cpp @@ -468,13 +468,12 @@ void sfcbox_state::sfcbox(machine_config &config) S3520CF(config, m_s3520cf); /* RTC */ /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); S_DSP(config, m_s_dsp, XTAL(24'576'000)); m_s_dsp->set_addrmap(0, &sfcbox_state::spc_map); - m_s_dsp->add_route(0, "lspeaker", 1.00); - m_s_dsp->add_route(1, "rspeaker", 1.00); + m_s_dsp->add_route(0, "speaker", 1.00, 0); + m_s_dsp->add_route(1, "speaker", 1.00, 1); /* video hardware */ /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs */ diff --git a/src/mame/nintendo/snes.cpp b/src/mame/nintendo/snes.cpp index 93ad4be6e64..4958cc64c79 100644 --- a/src/mame/nintendo/snes.cpp +++ b/src/mame/nintendo/snes.cpp @@ -1362,13 +1362,12 @@ void snes_console_state::snes(machine_config &config) m_ctrl2->set_gunlatch_callback(FUNC(snes_console_state::gun_latch_cb)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); S_DSP(config, m_s_dsp, XTAL(24'576'000)); m_s_dsp->set_addrmap(0, &snes_console_state::spc_map); - m_s_dsp->add_route(0, "lspeaker", 1.00); - m_s_dsp->add_route(1, "rspeaker", 1.00); + m_s_dsp->add_route(0, "speaker", 1.00, 0); + m_s_dsp->add_route(1, "speaker", 1.00, 1); SNS_CART_SLOT(config, m_cartslot, MCLK_NTSC, snes_cart, nullptr); m_cartslot->set_must_be_loaded(true); diff --git a/src/mame/nintendo/snesb.cpp b/src/mame/nintendo/snesb.cpp index 9b5111e5717..d3d3fdf6590 100644 --- a/src/mame/nintendo/snesb.cpp +++ b/src/mame/nintendo/snesb.cpp @@ -1016,13 +1016,12 @@ void snesb_state::base(machine_config &config) m_ppu->set_screen("screen"); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); S_DSP(config, m_s_dsp, XTAL(24'576'000)); m_s_dsp->set_addrmap(0, &snesb_state::spc_map); - m_s_dsp->add_route(0, "lspeaker", 1.00); - m_s_dsp->add_route(1, "rspeaker", 1.00); + m_s_dsp->add_route(0, "speaker", 1.00, 0); + m_s_dsp->add_route(1, "speaker", 1.00, 1); } void snesb_state::extrainp(machine_config &config) diff --git a/src/mame/nintendo/snesb51.cpp b/src/mame/nintendo/snesb51.cpp index c1fdd2d59b8..07f94623866 100644 --- a/src/mame/nintendo/snesb51.cpp +++ b/src/mame/nintendo/snesb51.cpp @@ -271,13 +271,12 @@ void snesb51_state::base(machine_config &config) m_ppu->set_screen("screen"); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); S_DSP(config, m_s_dsp, XTAL(24'576'000)); m_s_dsp->set_addrmap(0, &snesb51_state::spc_map); - m_s_dsp->add_route(0, "lspeaker", 1.00); - m_s_dsp->add_route(1, "rspeaker", 1.00); + m_s_dsp->add_route(0, "speaker", 1.00, 0); + m_s_dsp->add_route(1, "speaker", 1.00, 1); } void snesb51_state::mk3snes(machine_config &config) diff --git a/src/mame/nintendo/vboy.cpp b/src/mame/nintendo/vboy.cpp index 0a75ed431bc..98bf25c4d21 100644 --- a/src/mame/nintendo/vboy.cpp +++ b/src/mame/nintendo/vboy.cpp @@ -1273,11 +1273,10 @@ void vboy_state::vboy(machine_config &config) SOFTWARE_LIST(config, "cart_list").set_original("vboy"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); vboysnd_device &vbsnd(VBOYSND(config, "vbsnd")); - vbsnd.add_route(0, "lspeaker", 1.0); - vbsnd.add_route(1, "rspeaker", 1.0); + vbsnd.add_route(0, "speaker", 1.0, 0); + vbsnd.add_route(1, "speaker", 1.0, 1); } /* ROM definition */ diff --git a/src/mame/nintendo/vsnes.cpp b/src/mame/nintendo/vsnes.cpp index 714350e8e27..0f88a601dda 100644 --- a/src/mame/nintendo/vsnes.cpp +++ b/src/mame/nintendo/vsnes.cpp @@ -2588,10 +2588,9 @@ void vs_dual_state::vsdual(machine_config &config) m_ppu2->int_callback().set_inputline(m_subcpu, INPUT_LINE_NMI); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - maincpu.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - subcpu.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + SPEAKER(config, "speaker", 2).front(); + maincpu.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + subcpu.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); // watchdog resets system between 1.23s and 1.33s in hardware tests, exact timing unknown WATCHDOG_TIMER(config, m_watchdog).set_time(attotime::from_msec(1300)); diff --git a/src/mame/nintendo/vt1682.cpp b/src/mame/nintendo/vt1682.cpp index 676ff96b795..c91f691f12a 100644 --- a/src/mame/nintendo/vt1682.cpp +++ b/src/mame/nintendo/vt1682.cpp @@ -5789,11 +5789,10 @@ void vt_vt1682_state::vt_vt1682_common(machine_config& config) VT_VT1682_IO(config, m_io, 0); VT_VT1682_UIO(config, m_uio, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_12BIT_R2R(config, m_leftdac, 0).add_route(0, "lspeaker", 0.5); // unknown 12-bit DAC - DAC_12BIT_R2R(config, m_rightdac, 0).add_route(0, "rspeaker", 0.5); // unknown 12-bit DAC + DAC_12BIT_R2R(config, m_leftdac, 0).add_route(0, "speaker", 0.5, 0); // unknown 12-bit DAC + DAC_12BIT_R2R(config, m_rightdac, 0).add_route(0, "speaker", 0.5, 1); // unknown 12-bit DAC } @@ -6178,8 +6177,7 @@ void intec_interact_state::intech_interact(machine_config& config) m_leftdac->reset_routes(); m_rightdac->reset_routes(); - config.device_remove(":lspeaker"); - config.device_remove(":rspeaker"); + config.device_remove(":speaker"); SPEAKER(config, "mono").front_center(); m_leftdac->add_route(0, "mono", 0.5); @@ -6241,8 +6239,7 @@ void vt1682_dance_state::vt1682_dance(machine_config& config) m_leftdac->reset_routes(); m_rightdac->reset_routes(); - config.device_remove(":lspeaker"); - config.device_remove(":rspeaker"); + config.device_remove(":speaker"); SPEAKER(config, "mono").front_center(); m_leftdac->add_route(0, "mono", 0.5); @@ -6271,8 +6268,7 @@ void vt1682_lxts3_state::vt1682_lxts3(machine_config& config) m_leftdac->reset_routes(); m_rightdac->reset_routes(); - config.device_remove(":lspeaker"); - config.device_remove(":rspeaker"); + config.device_remove(":speaker"); SPEAKER(config, "mono").front_center(); m_leftdac->add_route(0, "mono", 0.5); @@ -6296,8 +6292,7 @@ void vt1682_mx10_state::mx10(machine_config& config) m_leftdac->reset_routes(); m_rightdac->reset_routes(); - config.device_remove(":lspeaker"); - config.device_remove(":rspeaker"); + config.device_remove(":speaker"); SPEAKER(config, "mono").front_center(); m_leftdac->add_route(0, "mono", 0.5); @@ -6315,8 +6310,7 @@ void vt1682_lxts3_state::vt1682_unk1682(machine_config& config) m_leftdac->reset_routes(); m_rightdac->reset_routes(); - config.device_remove(":lspeaker"); - config.device_remove(":rspeaker"); + config.device_remove(":speaker"); SPEAKER(config, "mono").front_center(); m_leftdac->add_route(0, "mono", 0.5); diff --git a/src/mame/nmk/macrossp.cpp b/src/mame/nmk/macrossp.cpp index 5e6d021e1e4..f4628b3528e 100644 --- a/src/mame/nmk/macrossp.cpp +++ b/src/mame/nmk/macrossp.cpp @@ -1016,8 +1016,7 @@ void macrossp_state::macrossp(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::RGBx_888, 4096); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_16(config, m_soundlatch); @@ -1026,8 +1025,8 @@ void macrossp_state::macrossp(machine_config &config) ensoniq.set_addrmap(1, ¯ossp_state::es5506_bank1_map); ensoniq.set_channels(1); ensoniq.irq_cb().set(FUNC(macrossp_state::irqhandler)); - ensoniq.add_route(0, "lspeaker", 0.1); - ensoniq.add_route(1, "rspeaker", 0.1); + ensoniq.add_route(0, "speaker", 0.1, 0); + ensoniq.add_route(1, "speaker", 0.1, 1); } void macrossp_state::quizmoon(machine_config &config) diff --git a/src/mame/nmk/nmkmedal.cpp b/src/mame/nmk/nmkmedal.cpp index 503aec9330c..ca66536f9e6 100644 --- a/src/mame/nmk/nmkmedal.cpp +++ b/src/mame/nmk/nmkmedal.cpp @@ -372,12 +372,11 @@ void omatsuri_state::omatsuri(machine_config &config) TMP90841(config, m_maincpu, 16_MHz_XTAL / 2); m_maincpu->set_addrmap(AS_PROGRAM, &omatsuri_state::mem_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16_MHz_XTAL)); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/oberheim/dmx.cpp b/src/mame/oberheim/dmx.cpp index 84b448a75a4..1857ce49454 100644 --- a/src/mame/oberheim/dmx.cpp +++ b/src/mame/oberheim/dmx.cpp @@ -185,7 +185,7 @@ protected: void device_add_mconfig(machine_config &config) override ATTR_COLD; void device_start() override ATTR_COLD; void device_reset() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: void reset_counter(); @@ -340,9 +340,9 @@ void dmx_voice_card_device::device_reset() m_eg->set_instant_v(0); } -void dmx_voice_card_device::sound_stream_update(sound_stream &stream, const std::vector<read_stream_view> &inputs, std::vector<write_stream_view> &outputs) +void dmx_voice_card_device::sound_stream_update(sound_stream &stream) { - outputs[0].copy(inputs[0]); + stream.copy(0, 0); } void dmx_voice_card_device::reset_counter() @@ -787,8 +787,8 @@ public: , m_voice_rc(*this, "voice_rc_filter_%d", 0) , m_left_mixer(*this, "left_mixer") , m_right_mixer(*this, "right_mixer") - , m_left_speaker(*this, "lspeaker") - , m_right_speaker(*this, "rspeaker") + , m_mono_mixer(*this, "mono_mixer") + , m_speaker(*this, "speaker") , m_samples(*this, "sample_%d", 0) { } @@ -853,8 +853,8 @@ private: required_device_array<filter_rc_device, 9> m_voice_rc; required_device<mixer_device> m_left_mixer; required_device<mixer_device> m_right_mixer; - required_device<speaker_device> m_left_speaker; - required_device<speaker_device> m_right_speaker; + required_device<mixer_device> m_mono_mixer; + required_device<speaker_device> m_speaker; required_memory_region_array<8> m_samples; // 40103 timer (U11 in Processor Board) @@ -1178,10 +1178,10 @@ template<int GROUP> void dmx_state::gen_trigger_w(u8 data) void dmx_state::update_output() { const float stereo_gain = (m_output_select->read() & 0x01) ? 1 : 0; - m_left_speaker->set_input_gain(0, stereo_gain); // left - m_left_speaker->set_input_gain(1, 1 - stereo_gain); // mono - m_right_speaker->set_input_gain(0, stereo_gain); // right - m_right_speaker->set_input_gain(1, 1 - stereo_gain); // mono + m_left_mixer ->set_route_gain(0, m_speaker, 0, stereo_gain); + m_mono_mixer ->set_route_gain(0, m_speaker, 0, 1 - stereo_gain); + m_right_mixer->set_route_gain(0, m_speaker, 1, stereo_gain); + m_mono_mixer ->set_route_gain(0, m_speaker, 1, 1 - stereo_gain); LOGMASKED(LOG_FADERS, "Output changed to: %d\n", m_output_select->read()); } @@ -1365,20 +1365,18 @@ void dmx_state::dmx(machine_config &config) m_voice_rc[METRONOME_INDEX]->add_route(ALL_OUTPUTS, m_right_mixer, 1.0); // Passive mixer using 1K resistors (R33 and R34). - mixer_device &mono_mixer = MIXER(config, "mono_mixer"); - m_left_mixer->add_route(ALL_OUTPUTS, mono_mixer, 0.5); - m_right_mixer->add_route(ALL_OUTPUTS, mono_mixer, 0.5); + MIXER(config, m_mono_mixer); + m_left_mixer->add_route(ALL_OUTPUTS, m_mono_mixer, 0.5); + m_right_mixer->add_route(ALL_OUTPUTS, m_mono_mixer, 0.5); // Only one of the left (right) or mono will be active for each speaker at // runtime. Controlled by a config setting (see update_output()). - SPEAKER(config, m_left_speaker).front_left(); - m_left_mixer->add_route(ALL_OUTPUTS, m_left_speaker, 1.0); - mono_mixer.add_route(ALL_OUTPUTS, m_left_speaker, 1.0); - - SPEAKER(config, m_right_speaker).front_right(); - m_right_mixer->add_route(ALL_OUTPUTS, m_right_speaker, 1.0); - mono_mixer.add_route(ALL_OUTPUTS, m_right_speaker, 1.0); + SPEAKER(config, m_speaker, 2).front(); + m_left_mixer->add_route(ALL_OUTPUTS, m_speaker, 1.0, 0); + m_mono_mixer->add_route(ALL_OUTPUTS, m_speaker, 1.0, 0); + m_right_mixer->add_route(ALL_OUTPUTS, m_speaker, 1.0, 1); + m_mono_mixer->add_route(ALL_OUTPUTS, m_speaker, 1.0, 1); } DECLARE_INPUT_CHANGED_MEMBER(dmx_state::clk_in_changed) diff --git a/src/mame/pc/calchase.cpp b/src/mame/pc/calchase.cpp index 110d0b3bc38..cf7d58bb784 100644 --- a/src/mame/pc/calchase.cpp +++ b/src/mame/pc/calchase.cpp @@ -183,10 +183,9 @@ void isa16_calchase_jamma_if::device_add_mconfig(machine_config &config) { NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); // DS1220Y - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_12BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); // unknown DAC - DAC_12BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_12BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); // unknown DAC + DAC_12BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC } void isa16_calchase_jamma_if::device_start() diff --git a/src/mame/pce/ggconnie.cpp b/src/mame/pce/ggconnie.cpp index 47811c284e3..570c8529eff 100644 --- a/src/mame/pce/ggconnie.cpp +++ b/src/mame/pce/ggconnie.cpp @@ -406,8 +406,8 @@ void ggconnie_state::ggconnie(machine_config &config) m_maincpu->set_addrmap(AS_IO, &ggconnie_state::sgx_io); m_maincpu->port_in_cb().set_ioport("IN0"); m_maincpu->port_out_cb().set(FUNC(ggconnie_state::lamp_w)); - m_maincpu->add_route(0, "lspeaker", 1.00); - m_maincpu->add_route(1, "rspeaker", 1.00); + m_maincpu->add_route(0, "speaker", 1.00, 0); + m_maincpu->add_route(1, "speaker", 1.00, 1); // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); @@ -447,13 +447,12 @@ void ggconnie_state::ggconnie(machine_config &config) MSM6242(config, m_rtc, XTAL(32'768)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, 2_MHz_XTAL, okim6295_device::PIN7_HIGH); // 2MHz resonator, pin 7 verified m_oki->set_addrmap(0, &ggconnie_state::oki_map); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 1.00); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 1.00); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.00, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.00, 1); } ROM_START(ggconnie) diff --git a/src/mame/pce/paranoia.cpp b/src/mame/pce/paranoia.cpp index 2d859ac48b4..6201622422b 100644 --- a/src/mame/pce/paranoia.cpp +++ b/src/mame/pce/paranoia.cpp @@ -175,8 +175,8 @@ void paranoia_state::paranoia(machine_config &config) m_maincpu->set_addrmap(AS_IO, ¶noia_state::pce_io); m_maincpu->port_in_cb().set(FUNC(paranoia_state::pce_joystick_r)); m_maincpu->port_out_cb().set(FUNC(paranoia_state::pce_joystick_w)); - m_maincpu->add_route(0, "lspeaker", 1.00); - m_maincpu->add_route(1, "rspeaker", 1.00); + m_maincpu->add_route(0, "speaker", 1.00, 0); + m_maincpu->add_route(1, "speaker", 1.00, 1); config.set_maximum_quantum(attotime::from_hz(60)); @@ -210,8 +210,7 @@ void paranoia_state::paranoia(machine_config &config) huc6270.set_vram_size(0x10000); huc6270.irq().set_inputline(m_maincpu, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START(paranoia) diff --git a/src/mame/pce/tourvis.cpp b/src/mame/pce/tourvis.cpp index bfd0ea18c4c..b56900fd930 100644 --- a/src/mame/pce/tourvis.cpp +++ b/src/mame/pce/tourvis.cpp @@ -400,8 +400,8 @@ void tourvision_state::tourvision(machine_config &config) m_maincpu->set_addrmap(AS_IO, &tourvision_state::pce_io); m_maincpu->port_in_cb().set(FUNC(tourvision_state::pce_joystick_r)); m_maincpu->port_out_cb().set(FUNC(tourvision_state::pce_joystick_w)); - m_maincpu->add_route(0, "lspeaker", 1.00); - m_maincpu->add_route(1, "rspeaker", 1.00); + m_maincpu->add_route(0, "speaker", 1.00, 0); + m_maincpu->add_route(1, "speaker", 1.00, 1); config.set_maximum_quantum(attotime::from_hz(60)); @@ -430,8 +430,7 @@ void tourvision_state::tourvision(machine_config &config) i8155.out_pc_callback().set(FUNC(tourvision_state::tourvision_i8155_c_w)); i8155.out_to_callback().set(FUNC(tourvision_state::tourvision_timer_out)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_cartslot_device &cartslot(GENERIC_CARTSLOT(config, "cartslot", generic_plain_slot, "tourvision_cart", "bin")); cartslot.set_device_load(FUNC(tourvision_state::cart_load)); diff --git a/src/mame/pce/uapce.cpp b/src/mame/pce/uapce.cpp index e8d84becebc..563acc56026 100644 --- a/src/mame/pce/uapce.cpp +++ b/src/mame/pce/uapce.cpp @@ -331,8 +331,8 @@ void uapce_state::uapce(machine_config &config) m_maincpu->set_addrmap(AS_IO, &uapce_state::pce_io); m_maincpu->port_in_cb().set(FUNC(uapce_state::pce_joystick_r)); m_maincpu->port_out_cb().set(FUNC(uapce_state::pce_joystick_w)); - m_maincpu->add_route(0, "lspeaker", 0.5); - m_maincpu->add_route(1, "rspeaker", 0.5); + m_maincpu->add_route(0, "speaker", 0.5, 0); + m_maincpu->add_route(1, "speaker", 0.5, 1); z80_device &sub(Z80(config, "sub", 1400000)); sub.set_addrmap(AS_PROGRAM, &uapce_state::z80_map); @@ -355,10 +355,9 @@ void uapce_state::uapce(machine_config &config) huc6270.set_vram_size(0x10000); huc6270.irq().set_inputline(m_maincpu, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DISCRETE(config, m_discrete, uapce_discrete).add_route(0, "rspeaker", 1.00); + DISCRETE(config, m_discrete, uapce_discrete).add_route(0, "speaker", 1.00, 1); } ROM_START(blazlaz) diff --git a/src/mame/philips/cdi.cpp b/src/mame/philips/cdi.cpp index 09d376931d8..37f74a9b004 100644 --- a/src/mame/philips/cdi.cpp +++ b/src/mame/philips/cdi.cpp @@ -462,14 +462,13 @@ void cdi_state::cdimono1_base(machine_config &config) m_cdrom->set_interface("cdrom"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DMADAC(config, m_dmadac[0]); - m_dmadac[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + m_dmadac[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); DMADAC(config, m_dmadac[1]); - m_dmadac[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_dmadac[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); MK48T08(config, "mk48t08"); } @@ -508,14 +507,13 @@ void cdi_state::cdimono2(machine_config &config) SOFTWARE_LIST(config, "photocd_list").set_compatible("photo_cd"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DMADAC(config, m_dmadac[0]); - m_dmadac[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + m_dmadac[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); DMADAC(config, m_dmadac[1]); - m_dmadac[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_dmadac[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); MK48T08(config, "mk48t08"); } @@ -553,14 +551,13 @@ void cdi_state::cdi910(machine_config &config) SOFTWARE_LIST(config, "photocd_list").set_compatible("photo_cd"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DMADAC(config, m_dmadac[0]); - m_dmadac[0]->add_route(ALL_OUTPUTS, "lspeaker", 1.0); + m_dmadac[0]->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); DMADAC(config, m_dmadac[1]); - m_dmadac[1]->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_dmadac[1]->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); MK48T08(config, "mk48t08"); } diff --git a/src/mame/phoenix/phoenix_a.cpp b/src/mame/phoenix/phoenix_a.cpp index 0f24cd62de4..f02882de6d0 100644 --- a/src/mame/phoenix/phoenix_a.cpp +++ b/src/mame/phoenix/phoenix_a.cpp @@ -522,15 +522,14 @@ void phoenix_sound_device::control_b_w(uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void phoenix_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void phoenix_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - int samplerate = buffer.sample_rate(); + int samplerate = stream.sample_rate(); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int sum = 0; sum = noise(samplerate) / 2; - buffer.put_int_clamp(sampindex, sum, 32768); + stream.put_int_clamp(0, sampindex, sum, 32768); } } diff --git a/src/mame/phoenix/phoenix_a.h b/src/mame/phoenix/phoenix_a.h index 7cb6097f487..5a9be29e71f 100644 --- a/src/mame/phoenix/phoenix_a.h +++ b/src/mame/phoenix/phoenix_a.h @@ -22,7 +22,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct c_state diff --git a/src/mame/phoenix/pleiads.cpp b/src/mame/phoenix/pleiads.cpp index f2fdf14e2ee..9698a84434f 100644 --- a/src/mame/phoenix/pleiads.cpp +++ b/src/mame/phoenix/pleiads.cpp @@ -694,24 +694,23 @@ void pleiads_sound_device::common_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void pleiads_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void pleiads_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - int rate = buffer.sample_rate(); + int rate = stream.sample_rate(); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int sum = tone1(rate)/2 + tone23(rate)/2 + tone4(rate) + noise(rate); - buffer.put_int_clamp(sampindex, sum, 32768); + stream.put_int_clamp(0, sampindex, sum, 32768); } } -void naughtyb_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void naughtyb_sound_device::sound_stream_update(sound_stream &stream) { - pleiads_sound_device::sound_stream_update(stream, inputs, outputs); + pleiads_sound_device::sound_stream_update(stream); } -void popflame_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void popflame_sound_device::sound_stream_update(sound_stream &stream) { - pleiads_sound_device::sound_stream_update(stream, inputs, outputs); + pleiads_sound_device::sound_stream_update(stream); } diff --git a/src/mame/phoenix/pleiads.h b/src/mame/phoenix/pleiads.h index 8ae08cb88a2..a93bd6d3e32 100644 --- a/src/mame/phoenix/pleiads.h +++ b/src/mame/phoenix/pleiads.h @@ -51,7 +51,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void common_start(); inline int tone1(int samplerate); @@ -105,7 +105,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; @@ -119,7 +119,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; diff --git a/src/mame/pinball/alvg.cpp b/src/mame/pinball/alvg.cpp index 2fad5e6a868..409ff508ea5 100644 --- a/src/mame/pinball/alvg.cpp +++ b/src/mame/pinball/alvg.cpp @@ -559,13 +559,12 @@ void alvg_state::pca008(machine_config &config) m_audiocpu->set_addrmap(AS_PROGRAM, &alvg_state::pca008_map); m_via1->writepa_handler().set(FUNC(alvg_state::via1_pa_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); BSMT2000(config, m_bsmt, XTAL(24'000'000)); m_bsmt->set_ready_callback(FUNC(alvg_state::bsmt_ready_w)); - m_bsmt->add_route(0, "lspeaker", 1.2); - m_bsmt->add_route(1, "rspeaker", 1.2); + m_bsmt->add_route(0, "speaker", 1.2, 0); + m_bsmt->add_route(1, "speaker", 1.2, 1); CLOCK(config, "fclock", 2'000'000 / 4096).signal_handler().set_inputline(m_audiocpu, 1); } diff --git a/src/mame/pinball/de_3.cpp b/src/mame/pinball/de_3.cpp index 2522e3f90b4..cb657e58560 100644 --- a/src/mame/pinball/de_3.cpp +++ b/src/mame/pinball/de_3.cpp @@ -527,12 +527,11 @@ void de_3_state::de_3_dmd2(machine_config &config) de_3(config); DECODMD2(config, m_dmdtype2, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DECOBSMT(config, m_decobsmt, 0); - m_decobsmt->add_route(0, "lspeaker", 1.0); - m_decobsmt->add_route(1, "rspeaker", 1.0); + m_decobsmt->add_route(0, "speaker", 1.0, 0); + m_decobsmt->add_route(1, "speaker", 1.0, 1); } void de_3_state::de_3_dmd1(machine_config &config) @@ -540,12 +539,11 @@ void de_3_state::de_3_dmd1(machine_config &config) de_3(config); DECODMD1(config, m_dmdtype1, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DECOBSMT(config, m_decobsmt, 0); - m_decobsmt->add_route(0, "lspeaker", 1.0); - m_decobsmt->add_route(1, "rspeaker", 1.0); + m_decobsmt->add_route(0, "speaker", 1.0, 0); + m_decobsmt->add_route(1, "speaker", 1.0, 1); } void de_3_state::de_3_dmdo(machine_config &config) @@ -573,12 +571,11 @@ void de_3_state::de_3b(machine_config &config) DECODMD3(config, m_dmdtype3, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DECOBSMT(config, m_decobsmt, 0); - m_decobsmt->add_route(0, "lspeaker", 1.0); - m_decobsmt->add_route(1, "rspeaker", 1.0); + m_decobsmt->add_route(0, "speaker", 1.0, 0); + m_decobsmt->add_route(1, "speaker", 1.0, 1); } void de_3_state::detest(machine_config &config) diff --git a/src/mame/pinball/idsa.cpp b/src/mame/pinball/idsa.cpp index 6aded4eb558..6ba4ffdc3db 100644 --- a/src/mame/pinball/idsa.cpp +++ b/src/mame/pinball/idsa.cpp @@ -356,20 +356,19 @@ void idsa_state::idsa(machine_config &config) /* sound hardware */ genpin_audio(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SP0256(config, m_speech, 3120000); // unknown variant - m_speech->add_route(ALL_OUTPUTS, "lspeaker", 1.5); + m_speech->add_route(ALL_OUTPUTS, "speaker", 1.5, 0); ay8910_device &aysnd1(AY8910(config, "aysnd1", 2000000)); // 2Mhz according to pinmame, schematic omits the clock line aysnd1.port_a_write_callback().set(FUNC(idsa_state::ay1_a_w)); aysnd1.port_b_write_callback().set(FUNC(idsa_state::ay1_b_w)); - aysnd1.add_route(ALL_OUTPUTS, "lspeaker", 0.75); + aysnd1.add_route(ALL_OUTPUTS, "speaker", 0.75, 0); ay8910_device &aysnd2(AY8910(config, "aysnd2", 2000000)); aysnd2.port_a_write_callback().set(FUNC(idsa_state::ay2_a_w)); aysnd2.port_b_write_callback().set(FUNC(idsa_state::ay2_b_w)); - aysnd2.add_route(ALL_OUTPUTS, "rspeaker", 0.75); + aysnd2.add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } void idsa_state::bsktbllp(machine_config &config) diff --git a/src/mame/pinball/lancelot.cpp b/src/mame/pinball/lancelot.cpp index 71d89d112eb..01c06954ba5 100644 --- a/src/mame/pinball/lancelot.cpp +++ b/src/mame/pinball/lancelot.cpp @@ -183,14 +183,14 @@ void lancelot_state::lancelot(machine_config &config) OKIM6295(config, m_oki, 1'656'000, okim6295_device::PIN7_HIGH); // pin7 is controlled by P63 from the audio cpu m_oki->add_route(ALL_OUTPUTS, "mono", 0.50); - SPEAKER(config, "lspeaker").front_left(); // YAC512 left - SPEAKER(config, "rspeaker").front_right(); // YAC512 right + SPEAKER(config, "speaker", 2).front(); // YAC512 left + // YAC512 right ymf262_device &ymf(YMF262(config, "ymf", 14'318'180)); ymf.irq_handler().set_inputline("audiocpu", 2); // to P82/INT2 of the audio cpu - ymf.add_route(0, "lspeaker", 0.50); - ymf.add_route(1, "rspeaker", 0.50); - ymf.add_route(2, "lspeaker", 0.50); - ymf.add_route(3, "rspeaker", 0.50); + ymf.add_route(0, "speaker", 0.50, 0); + ymf.add_route(1, "speaker", 0.50, 1); + ymf.add_route(2, "speaker", 0.50, 0); + ymf.add_route(3, "speaker", 0.50, 1); } /*------------------------------------------------------------------- diff --git a/src/mame/pinball/mrgame.cpp b/src/mame/pinball/mrgame.cpp index f56cbeddedd..79ef944620f 100644 --- a/src/mame/pinball/mrgame.cpp +++ b/src/mame/pinball/mrgame.cpp @@ -715,10 +715,9 @@ void mrgame_state::mrgame(machine_config &config) /* Sound */ genpin_audio(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); // unknown DAC - DAC_8BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); // unknown DAC + DAC_8BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC dac_8bit_r2r_device &dacvol(DAC_8BIT_R2R(config, "dacvol", 0)); dacvol.set_output_range(0, 1); // unknown DAC @@ -729,8 +728,8 @@ void mrgame_state::mrgame(machine_config &config) tms5220_device &tms(TMS5220(config, "tms", 672000)); // uses a RC combination. 672k copied from jedi.h tms.ready_cb().set_inputline("audiocpu2", Z80_INPUT_LINE_WAIT); - tms.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - tms.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + tms.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + tms.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); /* Devices */ TIMER(config, "irq_timer").configure_periodic(FUNC(mrgame_state::irq_timer), attotime::from_hz(16000)); //ugh diff --git a/src/mame/pinball/nsm.cpp b/src/mame/pinball/nsm.cpp index df5b2b8fff0..d6a8bbcb8e6 100644 --- a/src/mame/pinball/nsm.cpp +++ b/src/mame/pinball/nsm.cpp @@ -433,13 +433,12 @@ void nsm_state::nsm(machine_config &config) /* Sound */ genpin_audio(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ay8912_device &ay1(AY8912(config, "ay1", 11052000/8)); - ay1.add_route(ALL_OUTPUTS, "lspeaker", 0.75); + ay1.add_route(ALL_OUTPUTS, "speaker", 0.75, 0); ay1.port_a_write_callback().set(FUNC(nsm_state::ay1a_w)); ay8912_device &ay2(AY8912(config, "ay2", 11052000/8)); - ay2.add_route(ALL_OUTPUTS, "rspeaker", 0.75); + ay2.add_route(ALL_OUTPUTS, "speaker", 0.75, 1); ay2.port_a_write_callback().set(FUNC(nsm_state::ay2a_w)); } diff --git a/src/mame/pinball/pinsnd88.cpp b/src/mame/pinball/pinsnd88.cpp index bcd66da5c40..9fd44832258 100644 --- a/src/mame/pinball/pinsnd88.cpp +++ b/src/mame/pinball/pinsnd88.cpp @@ -112,7 +112,7 @@ DEFINE_DEVICE_TYPE(PINSND88, pinsnd88_device, "pinsnd88", "Williams Pin Sound '8 pinsnd88_device::pinsnd88_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig,PINSND88,tag,owner,clock) - , device_mixer_interface(mconfig, *this, 2) // 2 channels + , device_mixer_interface(mconfig, *this) , m_cpu(*this, "cpu") , m_dac(*this, "dac") , m_ym2151(*this, "ym2151") @@ -208,16 +208,16 @@ void pinsnd88_device::device_add_mconfig(machine_config &config) // TODO: analog filters and "volume" controls for the two channels AD7224(config, m_dac, 0); - m_dac->add_route(ALL_OUTPUTS, *this, 0.41/2.0, AUTO_ALLOC_INPUT, 0); // 470K - m_dac->add_route(ALL_OUTPUTS, *this, 0.5/2.0, AUTO_ALLOC_INPUT, 1); // 330K + m_dac->add_route(ALL_OUTPUTS, *this, 0.41/2.0, 0); // 470K + m_dac->add_route(ALL_OUTPUTS, *this, 0.5/2.0, 1); // 330K GENERIC_LATCH_8(config, m_inputlatch); m_inputlatch->data_pending_callback().set_inputline(m_cpu, M6809_IRQ_LINE); YM2151(config, m_ym2151, XTAL(3'579'545)); // "3.58 MHz" on schematics and parts list m_ym2151->irq_handler().set_inputline(m_cpu, M6809_FIRQ_LINE); // IRQ is not true state, but neither is the M6809_FIRQ_LINE so we're fine. - m_ym2151->add_route(ALL_OUTPUTS, *this, 0.59/2.0, AUTO_ALLOC_INPUT, 0); // 330K - m_ym2151->add_route(ALL_OUTPUTS, *this, 0.5/2.0, AUTO_ALLOC_INPUT, 1); // 330K + m_ym2151->add_route(ALL_OUTPUTS, *this, 0.59/2.0, 0); // 330K + m_ym2151->add_route(ALL_OUTPUTS, *this, 0.5/2.0, 1); // 330K } void pinsnd88_device::device_start() diff --git a/src/mame/pinball/play_3.cpp b/src/mame/pinball/play_3.cpp index 67624c18c66..a9dd656ccbe 100644 --- a/src/mame/pinball/play_3.cpp +++ b/src/mame/pinball/play_3.cpp @@ -596,10 +596,9 @@ void play_3_state::play_3(machine_config &config) m_audiocpu->wait_cb().set_constant(1); m_audiocpu->clear_cb().set(FUNC(play_3_state::clear_a_r)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - AY8910(config, m_ay1, 3.579545_MHz_XTAL / 2).add_route(ALL_OUTPUTS, "lspeaker", 0.75); - AY8910(config, m_ay2, 3.579545_MHz_XTAL / 2).add_route(ALL_OUTPUTS, "rspeaker", 0.75); + SPEAKER(config, "speaker", 2).front(); + AY8910(config, m_ay1, 3.579545_MHz_XTAL / 2).add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + AY8910(config, m_ay2, 3.579545_MHz_XTAL / 2).add_route(ALL_OUTPUTS, "speaker", 0.75, 1); m_ay1->set_resistors_load(6900, 6900, 6900); m_ay2->set_resistors_load(6900, 6900, 6900); m_ay1->port_a_write_callback().set_nop(); @@ -614,8 +613,7 @@ void play_3_state::spain82(machine_config &config) config.device_remove("audiocpu"); config.device_remove("ay1"); config.device_remove("ay2"); - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); EFO_SOUND3(config, m_sound3); } @@ -640,8 +638,7 @@ void play_3_state::sklflite(machine_config &config) config.device_remove("audiocpu"); config.device_remove("ay1"); config.device_remove("ay2"); - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); EFO_ZSU1(config, m_zsu); } diff --git a/src/mame/pinball/s11b.cpp b/src/mame/pinball/s11b.cpp index f1a53f35778..ab225e6b074 100644 --- a/src/mame/pinball/s11b.cpp +++ b/src/mame/pinball/s11b.cpp @@ -388,10 +388,10 @@ void s11b_state::s11b_jokerz(machine_config &config) PINSND88(config, m_ps88); // the dac and cvsd volumes should be equally mixed on the s11 board send to the audio board, whatever type it is // the 4 gain values in the add_route statements are actually irrelevant, the ps88 device will override them - m_dac->add_route(ALL_OUTPUTS, m_ps88, 0.29, AUTO_ALLOC_INPUT, 0); - m_dac->add_route(ALL_OUTPUTS, m_ps88, 0.25, AUTO_ALLOC_INPUT, 1); - m_cvsd_filter2->add_route(ALL_OUTPUTS, m_ps88, (0.29*4.0), AUTO_ALLOC_INPUT, 0); - m_cvsd_filter2->add_route(ALL_OUTPUTS, m_ps88, (0.25*4.0), AUTO_ALLOC_INPUT, 1); + m_dac->add_route(ALL_OUTPUTS, m_ps88, 0.29, 0); + m_dac->add_route(ALL_OUTPUTS, m_ps88, 0.25, 1); + m_cvsd_filter2->add_route(ALL_OUTPUTS, m_ps88, (0.29*4.0), 0); + m_cvsd_filter2->add_route(ALL_OUTPUTS, m_ps88, (0.25*4.0), 1); m_pia34->ca2_handler().set(m_ps88, FUNC(pinsnd88_device::resetq_w)); m_ps88->syncq_cb().set(m_pia34, FUNC(pia6821_device::ca1_w)); // the sync connection comes from sound connector pin 16 to MCA1, not the usual pin 12 to MCB1 SPEAKER(config, "cabinet").front_floor(); // the cabinet speaker is aimed down underneath the pinball table itself diff --git a/src/mame/pinball/techno.cpp b/src/mame/pinball/techno.cpp index 56c672e0e0e..a32fcf8e513 100644 --- a/src/mame/pinball/techno.cpp +++ b/src/mame/pinball/techno.cpp @@ -401,10 +401,9 @@ void techno_state::techno(machine_config &config) // Sound genpin_audio(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // DAC0808 - Y8950(config, "ym1", 3580000).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // TKY2016 - no crystal, just a random oscillator, sch says 3.58MHz + SPEAKER(config, "speaker", 2).front(); + DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // DAC0808 + Y8950(config, "ym1", 3580000).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // TKY2016 - no crystal, just a random oscillator, sch says 3.58MHz } ROM_START(xforce) diff --git a/src/mame/pinball/vd.cpp b/src/mame/pinball/vd.cpp index c556f3a6456..c10c7fa64d7 100644 --- a/src/mame/pinball/vd.cpp +++ b/src/mame/pinball/vd.cpp @@ -315,14 +315,13 @@ void vd_state::vd(machine_config &config) /* Sound */ genpin_audio(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ay8910_device &ay1(AY8910(config, "ay1", 2000000)); //? - ay1.add_route(ALL_OUTPUTS, "lspeaker", 0.5); + ay1.add_route(ALL_OUTPUTS, "speaker", 0.5, 0); ay1.port_a_read_callback().set_ioport("DSW2"); ay1.port_b_read_callback().set_ioport("DSW1"); ay8910_device &ay2(AY8910(config, "ay2", 2000000)); //? - ay2.add_route(ALL_OUTPUTS, "rspeaker", 0.5); + ay2.add_route(ALL_OUTPUTS, "speaker", 0.5, 1); ay2.port_b_read_callback().set_ioport("DSW3"); /* Video */ diff --git a/src/mame/pinball/whitestar.cpp b/src/mame/pinball/whitestar.cpp index cfe9ab72984..f90dc1b1686 100644 --- a/src/mame/pinball/whitestar.cpp +++ b/src/mame/pinball/whitestar.cpp @@ -328,12 +328,11 @@ void whitestar_state::whitestar(machine_config &config) // sound hardware genpin_audio(config); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DECOBSMT(config, m_decobsmt, 0); - m_decobsmt->add_route(0, "lspeaker", 1.0); - m_decobsmt->add_route(1, "rspeaker", 1.0); + m_decobsmt->add_route(0, "speaker", 1.0, 0); + m_decobsmt->add_route(1, "speaker", 1.0, 1); DECODMD2(config, m_decodmd, 0); } diff --git a/src/mame/psikyo/psikyo4.cpp b/src/mame/psikyo/psikyo4.cpp index e29872ff2af..8d0f3e9f645 100644 --- a/src/mame/psikyo/psikyo4.cpp +++ b/src/mame/psikyo/psikyo4.cpp @@ -633,18 +633,17 @@ void psikyo4_state::ps4big(machine_config &config) m_rscreen->set_palette(m_palette[1]); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymf278b_device &ymf(YMF278B(config, "ymf", 57272700/2)); ymf.set_addrmap(0, &psikyo4_state::ps4_ymf_map); ymf.irq_handler().set_inputline("maincpu", 12); - ymf.add_route(0, "rspeaker", 1.0); // Output for each screen - ymf.add_route(1, "lspeaker", 1.0); - ymf.add_route(2, "rspeaker", 1.0); - ymf.add_route(3, "lspeaker", 1.0); - ymf.add_route(4, "rspeaker", 1.0); - ymf.add_route(5, "lspeaker", 1.0); + ymf.add_route(0, "speaker", 1.0, 1); // Output for each screen + ymf.add_route(1, "speaker", 1.0, 0); + ymf.add_route(2, "speaker", 1.0, 1); + ymf.add_route(3, "speaker", 1.0, 0); + ymf.add_route(4, "speaker", 1.0, 1); + ymf.add_route(5, "speaker", 1.0, 0); } void psikyo4_state::ps4small(machine_config &config) diff --git a/src/mame/psion/psion3a.cpp b/src/mame/psion/psion3a.cpp index 5092a98cf42..21f524e0b96 100644 --- a/src/mame/psion/psion3a.cpp +++ b/src/mame/psion/psion3a.cpp @@ -39,7 +39,7 @@ public: protected: void device_start() override ATTR_COLD; - void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; @@ -61,9 +61,9 @@ void psion3a_codec_device::device_start() m_stream = stream_alloc(0, 1, 8000); } -void psion3a_codec_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void psion3a_codec_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(stream_buffer::sample_t(m_audio_out) * (1.0 / 4096.0)); + stream.fill(0, sound_stream::sample_t(m_audio_out) * (1.0 / 4096.0)); } void psion3a_codec_device::pcm_in(uint8_t data) diff --git a/src/mame/rare/btoads.cpp b/src/mame/rare/btoads.cpp index 208fc593e9c..dec3a659790 100644 --- a/src/mame/rare/btoads.cpp +++ b/src/mame/rare/btoads.cpp @@ -946,12 +946,11 @@ void btoads_state::btoads(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(tms34020_device::tms340x0_rgb32)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); BSMT2000(config, m_bsmt, SOUND_CLOCK); - m_bsmt->add_route(0, "lspeaker", 1.0); - m_bsmt->add_route(1, "rspeaker", 1.0); + m_bsmt->add_route(0, "speaker", 1.0, 0); + m_bsmt->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/roland/roland_cm32p.cpp b/src/mame/roland/roland_cm32p.cpp index 892a0854711..7042325222f 100644 --- a/src/mame/roland/roland_cm32p.cpp +++ b/src/mame/roland/roland_cm32p.cpp @@ -631,13 +631,12 @@ void cm32p_state::cm32p(machine_config &config) maincpu.serial_tx_cb().set(FUNC(cm32p_state::midi_w)); maincpu.in_p0_cb().set(FUNC(cm32p_state::port0_r)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MB87419_MB87420(config, pcm, 32.768_MHz_XTAL); pcm->int_callback().set_inputline(cpu, i8x9x_device::EXTINT_LINE); - pcm->add_route(0, "lspeaker", 1.0); - pcm->add_route(1, "rspeaker", 1.0); + pcm->add_route(0, "speaker", 1.0, 0); + pcm->add_route(1, "speaker", 1.0, 1); RAM(config, some_ram).set_default_size("8K"); diff --git a/src/mame/roland/roland_d70.cpp b/src/mame/roland/roland_d70.cpp index 2e568c06f6c..280ee8e395d 100644 --- a/src/mame/roland/roland_d70.cpp +++ b/src/mame/roland/roland_d70.cpp @@ -514,13 +514,12 @@ void roland_d70_state::d70(machine_config &config) { maincpu.ach3_cb().set(FUNC(roland_d70_state::ach3_r)); maincpu.ach4_cb().set(FUNC(roland_d70_state::ach4_r)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MB87419_MB87420(config, m_pcm, 32.768_MHz_XTAL); m_pcm->int_callback().set_inputline(m_cpu, i8x9x_device::EXTINT_LINE); - m_pcm->add_route(0, "lspeaker", 1.0); - m_pcm->add_route(1, "rspeaker", 1.0); + m_pcm->add_route(0, "speaker", 1.0, 0); + m_pcm->add_route(1, "speaker", 1.0, 1); T6963C(config, m_lcd, 0); m_lcd->set_addrmap(0, &roland_d70_state::lcd_map); diff --git a/src/mame/roland/roland_r8.cpp b/src/mame/roland/roland_r8.cpp index 2b19e450e39..9f4a98243ae 100644 --- a/src/mame/roland/roland_r8.cpp +++ b/src/mame/roland/roland_r8.cpp @@ -256,14 +256,13 @@ void roland_r8_base_state::r8_common(machine_config &config) //bu3904s_device &fsk(BU3904S(config, "fsk", 12_MHz_XTAL)); //fsk.xint_callback().set_inputline(m_maincpu, upd78k2_device::INTP0_LINE); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MB87419_MB87420(config, m_pcm, 33.8688_MHz_XTAL); //m_pcm->int_callback().set_inputline(m_maincpu, upd78k2_device::INTP1_LINE); m_pcm->set_device_rom_tag("pcm"); - m_pcm->add_route(0, "lspeaker", 1.0); - m_pcm->add_route(1, "rspeaker", 1.0); + m_pcm->add_route(0, "speaker", 1.0, 0); + m_pcm->add_route(1, "speaker", 1.0, 1); } void roland_r8_state::r8(machine_config &config) @@ -306,14 +305,13 @@ void roland_r8mk2_state::r8mk2(machine_config &config) //bu3904s_device &fsk(BU3904S(config, "fsk", 12_MHz_XTAL)); //fsk.xint_callback().set_inputline(m_maincpu, upd78k2_device::INTP0_LINE); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MB87419_MB87420(config, m_pcm, 33.8688_MHz_XTAL); //m_pcm->int_callback().set_inputline(m_maincpu, upd78k2_device::INTP1_LINE); m_pcm->set_device_rom_tag("pcm"); - m_pcm->add_route(0, "lspeaker", 1.0); - m_pcm->add_route(1, "rspeaker", 1.0); + m_pcm->add_route(0, "speaker", 1.0, 0); + m_pcm->add_route(1, "speaker", 1.0, 1); GENERIC_CARTSLOT(config, m_pcmcard, generic_romram_plain_slot, "r8_card", "bin"); m_pcmcard->set_device_load(FUNC(roland_r8mk2_state::pcmcard_load)); diff --git a/src/mame/roland/roland_u20.cpp b/src/mame/roland/roland_u20.cpp index ec16bc69acc..68611cd0754 100644 --- a/src/mame/roland/roland_u20.cpp +++ b/src/mame/roland/roland_u20.cpp @@ -51,14 +51,13 @@ void roland_u20_state::u20(machine_config &config) //R15239124(config, "keyscan", 12_MHz_XTAL); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MB87419_MB87420(config, m_pcm, 32.768_MHz_XTAL); m_pcm->int_callback().set_inputline(m_maincpu, i8x9x_device::EXTINT_LINE); m_pcm->set_device_rom_tag("waverom"); - m_pcm->add_route(0, "lspeaker", 1.0); - m_pcm->add_route(1, "rspeaker", 1.0); + m_pcm->add_route(0, "speaker", 1.0, 0); + m_pcm->add_route(1, "speaker", 1.0, 1); } void roland_u20_state::u220(machine_config &config) diff --git a/src/mame/sega/bingoc.cpp b/src/mame/sega/bingoc.cpp index 8eb8c130f81..f00024035f3 100644 --- a/src/mame/sega/bingoc.cpp +++ b/src/mame/sega/bingoc.cpp @@ -217,16 +217,16 @@ void bingoc_state::bingoc(machine_config &config) PALETTE(config, "palette").set_entries(0x100); - SPEAKER(config, "lspeaker").front_left(); //might just be mono... - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); //might just be mono... + GENERIC_LATCH_8(config, m_soundlatch); - YM2151(config, "ymsnd", 7159160/2).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", 7159160/2).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); UPD7759(config, m_upd7759); - m_upd7759->add_route(ALL_OUTPUTS, "lspeaker", 1.0); - m_upd7759->add_route(ALL_OUTPUTS, "rspeaker", 1.0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // terminals BINGOCT(config, "term1"); diff --git a/src/mame/sega/calcune.cpp b/src/mame/sega/calcune.cpp index bf1628f9f69..79b70ebe91c 100644 --- a/src/mame/sega/calcune.cpp +++ b/src/mame/sega/calcune.cpp @@ -274,8 +274,8 @@ void calcune_state::calcune(machine_config &config) m_vdp[0]->lv6_irq().set(FUNC(calcune_state::vdp_lv6irqline_callback_genesis_68k)); m_vdp[0]->lv4_irq().set(FUNC(calcune_state::vdp_lv4irqline_callback_genesis_68k)); m_vdp[0]->set_alt_timing(1); - m_vdp[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_vdp[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_vdp[0]->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + m_vdp[0]->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); SEGA315_5313(config, m_vdp[1], OSC1_CLOCK, m_maincpu); m_vdp[1]->set_is_pal(false); @@ -284,8 +284,8 @@ void calcune_state::calcune(machine_config &config) // m_vdp[1]->lv6_irq().set(FUNC(calcune_state::vdp_lv6irqline_callback_genesis_68k)); // m_vdp[1]->lv4_irq().set(FUNC(calcune_state::vdp_lv4irqline_callback_genesis_68k)); m_vdp[1]->set_alt_timing(1); - m_vdp[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_vdp[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_vdp[1]->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + m_vdp[1]->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); TIMER(config, "scantimer").configure_scanline(m_vdp[0], FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "megadriv", 0, 1); TIMER(config, "scantimer2").configure_scanline(m_vdp[1], FUNC(sega315_5313_device::megadriv_scanline_timer_callback_alt_timing), "megadriv", 0, 1); @@ -293,12 +293,11 @@ void calcune_state::calcune(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } void calcune_state::init_calcune() diff --git a/src/mame/sega/coolridr.cpp b/src/mame/sega/coolridr.cpp index cbd052ebb98..9cdc9b40da3 100644 --- a/src/mame/sega/coolridr.cpp +++ b/src/mame/sega/coolridr.cpp @@ -3268,21 +3268,20 @@ void coolridr_state::coolridr(machine_config &config) config.set_default_layout(layout_dualhsxs); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); scsp_device &scsp1(SCSP(config, "scsp1", XTAL(22'579'000))); // 22.579 MHz scsp1.set_addrmap(0, &coolridr_state::scsp_map<0>); scsp1.irq_cb().set(FUNC(coolridr_state::scsp_irq)); scsp1.main_irq_cb().set(FUNC(coolridr_state::scsp1_to_sh1_irq)); - scsp1.add_route(0, "lspeaker", 1.0); - scsp1.add_route(1, "rspeaker", 1.0); + scsp1.add_route(0, "speaker", 1.0, 0); + scsp1.add_route(1, "speaker", 1.0, 1); scsp_device &scsp2(SCSP(config, "scsp2", XTAL(22'579'000))); // 22.579 MHz scsp2.set_addrmap(0, &coolridr_state::scsp_map<1>); scsp2.main_irq_cb().set(FUNC(coolridr_state::scsp2_to_sh1_irq)); - scsp2.add_route(0, "lspeaker", 1.0); - scsp2.add_route(1, "rspeaker", 1.0); + scsp2.add_route(0, "speaker", 1.0, 0); + scsp2.add_route(1, "speaker", 1.0, 1); } void coolridr_state::aquastge(machine_config &config) diff --git a/src/mame/sega/dccons.cpp b/src/mame/sega/dccons.cpp index ffa48432211..ff95a502d3e 100644 --- a/src/mame/sega/dccons.cpp +++ b/src/mame/sega/dccons.cpp @@ -419,15 +419,14 @@ void dc_cons_state::dc_base(machine_config &config) POWERVR2(config, m_powervr2, 0); m_powervr2->irq_callback().set(FUNC(dc_state::pvr_irq)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AICA(config, m_aica, (XTAL(33'868'800)*2)/3); // 67.7376MHz(2*33.8688MHz), div 3 for audio block m_aica->irq().set(FUNC(dc_state::aica_irq)); m_aica->main_irq().set(FUNC(dc_state::sh4_aica_irq)); m_aica->set_addrmap(0, &dc_cons_state::aica_map); - m_aica->add_route(0, "lspeaker", 0.4); - m_aica->add_route(1, "rspeaker", 0.4); + m_aica->add_route(0, "speaker", 0.4, 0); + m_aica->add_route(1, "speaker", 0.4, 1); AICARTC(config, "aicartc", XTAL(32'768)); diff --git a/src/mame/sega/dsbz80.cpp b/src/mame/sega/dsbz80.cpp index f6060d890cb..581bd6c0e9a 100644 --- a/src/mame/sega/dsbz80.cpp +++ b/src/mame/sega/dsbz80.cpp @@ -267,12 +267,9 @@ void dsbz80_device::mpeg_stereo_w(uint8_t data) m_mp_pan = data & 3; // 0 = stereo, 1 = left on both channels, 2 = right on both channels } -void dsbz80_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void dsbz80_device::sound_stream_update(sound_stream &stream) { - auto &out_l = outputs[0]; - auto &out_r = outputs[1]; - - int samples = out_l.samples(); + int samples = stream.samples(); int sampindex = 0; for (;;) { @@ -281,20 +278,20 @@ void dsbz80_device::sound_stream_update(sound_stream &stream, std::vector<read_s switch (m_mp_pan) { case 0: // stereo - out_l.put_int(sampindex, m_audio_buf[m_audio_pos*2] * m_mp_vol, 32768 * 128); - out_r.put_int(sampindex, m_audio_buf[m_audio_pos*2+1] * m_mp_vol, 32768 * 128); + stream.put_int(0, sampindex, m_audio_buf[m_audio_pos*2] * m_mp_vol, 32768 * 128); + stream.put_int(1, sampindex, m_audio_buf[m_audio_pos*2+1] * m_mp_vol, 32768 * 128); sampindex++; break; case 1: // left only - out_l.put_int(sampindex, m_audio_buf[m_audio_pos*2] * m_mp_vol, 32768 * 128); - out_r.put_int(sampindex, m_audio_buf[m_audio_pos*2] * m_mp_vol, 32768 * 128); + stream.put_int(0, sampindex, m_audio_buf[m_audio_pos*2] * m_mp_vol, 32768 * 128); + stream.put_int(1, sampindex, m_audio_buf[m_audio_pos*2] * m_mp_vol, 32768 * 128); sampindex++; break; case 2: // right only - out_l.put_int(sampindex, m_audio_buf[m_audio_pos*2+1] * m_mp_vol, 32768 * 128); - out_r.put_int(sampindex, m_audio_buf[m_audio_pos*2+1] * m_mp_vol, 32768 * 128); + stream.put_int(0, sampindex, m_audio_buf[m_audio_pos*2+1] * m_mp_vol, 32768 * 128); + stream.put_int(1, sampindex, m_audio_buf[m_audio_pos*2+1] * m_mp_vol, 32768 * 128); sampindex++; break; } @@ -309,8 +306,6 @@ void dsbz80_device::sound_stream_update(sound_stream &stream, std::vector<read_s if (m_mp_state == 0) { - out_l.fill(0, sampindex); - out_r.fill(0, sampindex); break; } diff --git a/src/mame/sega/dsbz80.h b/src/mame/sega/dsbz80.h index 1d2813aef32..197354137d3 100644 --- a/src/mame/sega/dsbz80.h +++ b/src/mame/sega/dsbz80.h @@ -35,7 +35,7 @@ protected: virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; // device_sound_interface implementation - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: required_device<cpu_device> m_ourcpu; diff --git a/src/mame/sega/flashbeats.cpp b/src/mame/sega/flashbeats.cpp index 6b58033e564..bfdea31ddc0 100644 --- a/src/mame/sega/flashbeats.cpp +++ b/src/mame/sega/flashbeats.cpp @@ -143,14 +143,13 @@ void flashbeats_state::flashbeats(machine_config &config) //te7752.out_port6_cb().set(FUNC(flashbeats_state::te7752_port6_w)); //te7752.out_port7_cb().set(FUNC(flashbeats_state::te7752_port7_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SCSP(config, m_scsp, 22579200); // TODO : Unknown clock, divider m_scsp->set_addrmap(0, &flashbeats_state::scsp_mem); m_scsp->irq_cb().set(FUNC(flashbeats_state::scsp_irq)); - m_scsp->add_route(0, "lspeaker", 1.0); - m_scsp->add_route(1, "rspeaker", 1.0); + m_scsp->add_route(0, "speaker", 1.0, 0); + m_scsp->add_route(1, "speaker", 1.0, 1); } void flashbeats_state::scsp_irq(offs_t offset, uint8_t data) diff --git a/src/mame/sega/gpworld.cpp b/src/mame/sega/gpworld.cpp index 888378c8cf1..afd86580e52 100644 --- a/src/mame/sega/gpworld.cpp +++ b/src/mame/sega/gpworld.cpp @@ -495,8 +495,8 @@ void gpworld_state::gpworld(machine_config &config) PIONEER_LDV1000(config, m_laserdisc, 0); m_laserdisc->set_overlay(512, 256, FUNC(gpworld_state::screen_update)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_laserdisc->add_ntsc_screen(config, "screen"); @@ -505,8 +505,7 @@ void gpworld_state::gpworld(machine_config &config) PALETTE(config, m_palette).set_entries(1024); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/sega/hikaru.cpp b/src/mame/sega/hikaru.cpp index 1a8120043c7..8dccf3e70ca 100644 --- a/src/mame/sega/hikaru.cpp +++ b/src/mame/sega/hikaru.cpp @@ -544,14 +544,13 @@ void hikaru_state::hikaru(machine_config &config) PALETTE(config, "palette").set_entries(0x1000); -// SPEAKER(config, "lspeaker").front_left(); -// SPEAKER(config, "rspeaker").front_right(); +// SPEAKER(config, "speaker").front(); // 67.7376MHz(2*33.8688MHz), div 3 for audio block -// AICA(config, "aica", (XTAL(33'868'800)*2)/3).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); +// AICA(config, "aica", (XTAL(33'868'800)*2)/3).add_route(0, "speaker", 1.0).add_route(1, "speaker", 1.0); // 33.8688MHz on Board -// AICA(config, "aica_pcb", (XTAL(33'868'800)*2)/3).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); // AICA PCB +// AICA(config, "aica_pcb", (XTAL(33'868'800)*2)/3).add_route(0, "speaker", 1.0).add_route(1, "speaker", 1.0); // AICA PCB } diff --git a/src/mame/sega/mdconsole.cpp b/src/mame/sega/mdconsole.cpp index 981eff4ff75..064d5e4fb57 100644 --- a/src/mame/sega/mdconsole.cpp +++ b/src/mame/sega/mdconsole.cpp @@ -510,21 +510,21 @@ void md_cons_state::genesis_32x(machine_config &config) m_vdp->set_md_32x_scanline_helper(FUNC(md_cons_state::_32x_scanline_helper_callback)); m_vdp->set_md_32x_interrupt(FUNC(md_cons_state::_32x_interrupt_callback)); m_vdp->reset_routes(); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", (0.50)/2); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", (0.50)/2); + m_vdp->add_route(ALL_OUTPUTS, "speaker", (0.50)/2); + m_vdp->add_route(ALL_OUTPUTS, "speaker", (0.50)/2); SEGA_32X_NTSC(config, m_32x, (MASTER_CLOCK_NTSC * 3) / 7, m_maincpu, m_scan_timer); m_32x->set_screen("megadriv"); - m_32x->add_route(0, "lspeaker", 1.00); - m_32x->add_route(1, "rspeaker", 1.00); + m_32x->add_route(0, "speaker", 1.00); + m_32x->add_route(1, "speaker", 1.00); m_screen->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console)); // we need to remove and re-add the YM because the balance is different // due to MAME having severe issues if the dac output is > 0.40? (sound is corrupted even if DAC is silent?!) m_ymsnd->reset_routes(); - m_ymsnd->add_route(0, "lspeaker", (0.50)/2); - m_ymsnd->add_route(1, "rspeaker", (0.50)/2); + m_ymsnd->add_route(0, "speaker", (0.50)/2); + m_ymsnd->add_route(1, "speaker", (0.50)/2); md_ctrl_ports(config); md_exp_port(config); @@ -545,21 +545,21 @@ void md_cons_state::mdj_32x(machine_config &config) m_vdp->set_md_32x_scanline_helper(FUNC(md_cons_state::_32x_scanline_helper_callback)); m_vdp->set_md_32x_interrupt(FUNC(md_cons_state::_32x_interrupt_callback)); m_vdp->reset_routes(); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", (0.50)/2); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", (0.50)/2); + m_vdp->add_route(ALL_OUTPUTS, "speaker", (0.50)/2); + m_vdp->add_route(ALL_OUTPUTS, "speaker", (0.50)/2); SEGA_32X_NTSC(config, m_32x, (MASTER_CLOCK_NTSC * 3) / 7, m_maincpu, m_scan_timer); m_32x->set_screen("megadriv"); - m_32x->add_route(0, "lspeaker", 1.00); - m_32x->add_route(1, "rspeaker", 1.00); + m_32x->add_route(0, "speaker", 1.00); + m_32x->add_route(1, "speaker", 1.00); m_screen->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console)); // we need to remove and re-add the sound system because the balance is different // due to MAME having severe issues if the dac output is > 0.40? (sound is corrupted even if DAC is silent?!) m_ymsnd->reset_routes(); - m_ymsnd->add_route(0, "lspeaker", (0.50)/2); - m_ymsnd->add_route(1, "rspeaker", (0.50)/2); + m_ymsnd->add_route(0, "speaker", (0.50)/2); + m_ymsnd->add_route(1, "speaker", (0.50)/2); md_ctrl_ports(config); md_exp_port(config); @@ -580,21 +580,21 @@ void md_cons_state::md_32x(machine_config &config) m_vdp->set_md_32x_scanline_helper(FUNC(md_cons_state::_32x_scanline_helper_callback)); m_vdp->set_md_32x_interrupt(FUNC(md_cons_state::_32x_interrupt_callback)); m_vdp->reset_routes(); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", (0.50)/2); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", (0.50)/2); + m_vdp->add_route(ALL_OUTPUTS, "speaker", (0.50)/2); + m_vdp->add_route(ALL_OUTPUTS, "speaker", (0.50)/2); SEGA_32X_PAL(config, m_32x, (MASTER_CLOCK_PAL * 3) / 7, m_maincpu, m_scan_timer); m_32x->set_screen("megadriv"); - m_32x->add_route(0, "lspeaker", 1.00); - m_32x->add_route(1, "rspeaker", 1.00); + m_32x->add_route(0, "speaker", 1.00); + m_32x->add_route(1, "speaker", 1.00); m_screen->screen_vblank().set(FUNC(md_cons_state::screen_vblank_console)); // we need to remove and re-add the sound system because the balance is different // due to MAME having severe issues if the dac output is > 0.40? (sound is corrupted even if DAC is silent?!) m_ymsnd->reset_routes(); - m_ymsnd->add_route(0, "lspeaker", (0.50)/2); - m_ymsnd->add_route(1, "rspeaker", (0.50)/2); + m_ymsnd->add_route(0, "speaker", (0.50)/2); + m_ymsnd->add_route(1, "speaker", (0.50)/2); md_ctrl_ports(config); md_exp_port(config); diff --git a/src/mame/sega/megacd.cpp b/src/mame/sega/megacd.cpp index 8f288cdcdf8..a35d2814a26 100644 --- a/src/mame/sega/megacd.cpp +++ b/src/mame/sega/megacd.cpp @@ -296,8 +296,8 @@ void sega_segacd_device::device_add_mconfig(machine_config &config) config.set_default_layout(layout_megacd); RF5C164(config, m_rfsnd, SEGACD_CLOCK); // or Sega 315-5476A - m_rfsnd->add_route( 0, ":lspeaker", 0.50 ); - m_rfsnd->add_route( 1, ":rspeaker", 0.50 ); + m_rfsnd->add_route( 0, ":speaker", 0.50, 0 ); + m_rfsnd->add_route( 1, ":speaker", 0.50, 1 ); m_rfsnd->set_addrmap(0, &sega_segacd_device::segacd_pcm_map); NVRAM(config, "backupram", nvram_device::DEFAULT_ALL_0); diff --git a/src/mame/sega/megadriv.cpp b/src/mame/sega/megadriv.cpp index 226e890ba8e..7cc00059936 100644 --- a/src/mame/sega/megadriv.cpp +++ b/src/mame/sega/megadriv.cpp @@ -880,16 +880,15 @@ void md_base_state::md_ntsc(machine_config &config) megadriv_ioports(config); m_vdp->snd_irq().set(FUNC(md_base_state::vdp_sndirqline_callback_genesis_z80)); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2612(config, m_ymsnd, MASTER_CLOCK_NTSC / 7); // 7.67 MHz - m_ymsnd->add_route(0, "lspeaker", 0.50); - m_ymsnd->add_route(1, "rspeaker", 0.50); + m_ymsnd->add_route(0, "speaker", 0.50, 0); + m_ymsnd->add_route(1, "speaker", 0.50, 1); } void md_base_state::md2_ntsc(machine_config &config) @@ -898,8 +897,8 @@ void md_base_state::md2_ntsc(machine_config &config) // Internalized YM3438 in VDP ASIC YM3438(config.replace(), m_ymsnd, MASTER_CLOCK_NTSC / 7); // 7.67 MHz - m_ymsnd->add_route(0, "lspeaker", 0.50); - m_ymsnd->add_route(1, "rspeaker", 0.50); + m_ymsnd->add_route(0, "speaker", 0.50, 0); + m_ymsnd->add_route(1, "speaker", 0.50, 1); } /************ PAL hardware has a different master clock *************/ @@ -919,16 +918,15 @@ void md_base_state::md_pal(machine_config &config) megadriv_ioports(config); m_vdp->snd_irq().set(FUNC(md_base_state::vdp_sndirqline_callback_genesis_z80)); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2612(config, m_ymsnd, MASTER_CLOCK_PAL / 7); // 7.67 MHz - m_ymsnd->add_route(0, "lspeaker", 0.50); - m_ymsnd->add_route(1, "rspeaker", 0.50); + m_ymsnd->add_route(0, "speaker", 0.50, 0); + m_ymsnd->add_route(1, "speaker", 0.50, 1); } void md_base_state::md2_pal(machine_config &config) @@ -937,8 +935,8 @@ void md_base_state::md2_pal(machine_config &config) // Internalized YM3438 in VDP ASIC YM3438(config.replace(), m_ymsnd, MASTER_CLOCK_PAL / 7); /* 7.67 MHz */ - m_ymsnd->add_route(0, "lspeaker", 0.50); - m_ymsnd->add_route(1, "rspeaker", 0.50); + m_ymsnd->add_route(0, "speaker", 0.50, 0); + m_ymsnd->add_route(1, "speaker", 0.50, 1); } diff --git a/src/mame/sega/megaplay.cpp b/src/mame/sega/megaplay.cpp index 1e3a9014642..f3845526efd 100644 --- a/src/mame/sega/megaplay.cpp +++ b/src/mame/sega/megaplay.cpp @@ -707,8 +707,8 @@ void mplay_state::megaplay(machine_config &config) m_vdp1->set_hcounter_divide(5); m_vdp1->set_is_pal(false); m_vdp1->n_int().set_inputline(m_bioscpu, 0); - m_vdp1->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_vdp1->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_vdp1->add_route(ALL_OUTPUTS, "speaker", 0.25); + m_vdp1->add_route(ALL_OUTPUTS, "speaker", 0.25); } diff --git a/src/mame/sega/megatech.cpp b/src/mame/sega/megatech.cpp index 12291378237..08f3686d644 100644 --- a/src/mame/sega/megatech.cpp +++ b/src/mame/sega/megatech.cpp @@ -745,8 +745,8 @@ void mtech_state::megatech(machine_config &config) m_vdp1->set_screen("menu"); m_vdp1->set_is_pal(false); m_vdp1->n_int().set_inputline(m_bioscpu, 0); - m_vdp1->add_route(ALL_OUTPUTS, "lspeaker", 0.25); - m_vdp1->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_vdp1->add_route(ALL_OUTPUTS, "speaker", 0.25); + m_vdp1->add_route(ALL_OUTPUTS, "speaker", 0.25); } diff --git a/src/mame/sega/model2.cpp b/src/mame/sega/model2.cpp index 382d55331d2..e2033e2311c 100644 --- a/src/mame/sega/model2.cpp +++ b/src/mame/sega/model2.cpp @@ -2508,14 +2508,13 @@ void model2_state::model2_scsp(machine_config &config) M68000(config, m_audiocpu, 45.1584_MHz_XTAL / 4); // SCSP Clock / 2 m_audiocpu->set_addrmap(AS_PROGRAM, &model2_state::model2_snd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SCSP(config, m_scsp, 45.1584_MHz_XTAL / 2); // 45.158MHz XTAL at Video board(Model 2A-CRX) m_scsp->set_addrmap(0, &model2_state::scsp_map); m_scsp->irq_cb().set(FUNC(model2_state::scsp_irq)); - m_scsp->add_route(0, "lspeaker", 1.0); - m_scsp->add_route(1, "rspeaker", 1.0); + m_scsp->add_route(0, "speaker", 1.0, 0); + m_scsp->add_route(1, "speaker", 1.0, 1); I8251(config, m_uart, 8000000); // uPD71051C, clock unknown // m_uart->rxrdy_handler().set(FUNC(model2_state::sound_ready_w)); @@ -3004,8 +3003,8 @@ void model2c_state::stcc(machine_config &config) io.an_port_callback<2>().set_ioport("BRAKE"); DSBZ80(config, m_dsbz80, 0); - m_dsbz80->add_route(0, "lspeaker", 1.0); - m_dsbz80->add_route(1, "rspeaker", 1.0); + m_dsbz80->add_route(0, "speaker", 1.0, 0); + m_dsbz80->add_route(1, "speaker", 1.0, 1); m_uart->txd_handler().set(m_dsbz80, FUNC(dsbz80_device::write_txd)); } diff --git a/src/mame/sega/model3.cpp b/src/mame/sega/model3.cpp index b4ed68a1dfb..7bca87e8e49 100644 --- a/src/mame/sega/model3.cpp +++ b/src/mame/sega/model3.cpp @@ -6357,19 +6357,18 @@ void model3_state::add_base_devices(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfxdecode_device::empty); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SCSP(config, m_scsp1, 45.1584_MHz_XTAL / 2); // 45.158 MHz XTAL m_scsp1->set_addrmap(0, &model3_state::scsp1_map); m_scsp1->irq_cb().set(FUNC(model3_state::scsp_irq)); - m_scsp1->add_route(0, "lspeaker", 1.0); - m_scsp1->add_route(1, "rspeaker", 1.0); + m_scsp1->add_route(0, "speaker", 1.0, 0); + m_scsp1->add_route(1, "speaker", 1.0, 1); scsp_device &scsp2(SCSP(config, "scsp2", 45.1584_MHz_XTAL / 2)); scsp2.set_addrmap(0, &model3_state::scsp2_map); - scsp2.add_route(0, "lspeaker", 1.0); - scsp2.add_route(1, "rspeaker", 1.0); + scsp2.add_route(0, "speaker", 1.0, 0); + scsp2.add_route(1, "speaker", 1.0, 1); SEGA_BILLBOARD(config, m_billboard, 0); @@ -6458,8 +6457,8 @@ void model3_state::scud(machine_config &config) model3_15(config); DSBZ80(config, m_dsbz80, 0); - m_dsbz80->add_route(0, "lspeaker", 1.0); - m_dsbz80->add_route(1, "rspeaker", 1.0); + m_dsbz80->add_route(0, "speaker", 1.0, 0); + m_dsbz80->add_route(1, "speaker", 1.0, 1); I8251(config, m_uart, 8000000); // uPD71051 m_uart->txd_handler().set(m_dsbz80, FUNC(dsbz80_device::write_txd)); diff --git a/src/mame/sega/naomi.cpp b/src/mame/sega/naomi.cpp index 3802d1136e7..073d5738c46 100644 --- a/src/mame/sega/naomi.cpp +++ b/src/mame/sega/naomi.cpp @@ -2444,15 +2444,14 @@ void dc_state::naomi_aw_base(machine_config &config) POWERVR2(config, m_powervr2, 0); m_powervr2->irq_callback().set(FUNC(dc_state::pvr_irq)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AICA(config, m_aica, (XTAL(33'868'800)*2)/3); // 67.7376MHz(2*33.8688MHz), div 3 for audio block m_aica->irq().set(FUNC(dc_state::aica_irq)); m_aica->main_irq().set(FUNC(dc_state::sh4_aica_irq)); m_aica->set_addrmap(0, &dc_state::aica_map); - m_aica->add_route(0, "lspeaker", 1.0); - m_aica->add_route(1, "rspeaker", 1.0); + m_aica->add_route(0, "speaker", 1.0, 0); + m_aica->add_route(1, "speaker", 1.0, 1); AICARTC(config, "aicartc", XTAL(32'768)); } diff --git a/src/mame/sega/puckpkmn.cpp b/src/mame/sega/puckpkmn.cpp index ba640ac2c8c..aded3db7cfe 100644 --- a/src/mame/sega/puckpkmn.cpp +++ b/src/mame/sega/puckpkmn.cpp @@ -403,21 +403,20 @@ void puckpkmn_state::puckpkmn(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &puckpkmn_state::puckpkmn_map); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // Internalized YM3438 in VDP ASIC YM3438(config, m_ymsnd, MASTER_CLOCK_NTSC / 7); // 7.67 MHz - m_ymsnd->add_route(0, "lspeaker", 0.50); - m_ymsnd->add_route(1, "rspeaker", 0.50); + m_ymsnd->add_route(0, "speaker", 0.50, 0); + m_ymsnd->add_route(1, "speaker", 0.50, 1); okim6295_device &oki(OKIM6295(config, "oki", XTAL(4'000'000) / 4, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.25); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.25); + oki.add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } void puckpkmn_state::jingling(machine_config &config) diff --git a/src/mame/sega/saturn.cpp b/src/mame/sega/saturn.cpp index 2c32097969b..378b8053cca 100644 --- a/src/mame/sega/saturn.cpp +++ b/src/mame/sega/saturn.cpp @@ -864,15 +864,14 @@ void sat_console_state::saturn(machine_config &config) MCFG_VIDEO_START_OVERRIDE(sat_console_state,stv_vdp2) - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SCSP(config, m_scsp, 8467200*8/3); // 8.4672 MHz EXTCLK * 8 / 3 = 22.5792 MHz m_scsp->set_addrmap(0, &sat_console_state::scsp_mem); m_scsp->irq_cb().set(FUNC(saturn_state::scsp_irq)); m_scsp->main_irq_cb().set(m_scu, FUNC(sega_scu_device::sound_req_w)); - m_scsp->add_route(0, "lspeaker", 1.0); - m_scsp->add_route(1, "rspeaker", 1.0); + m_scsp->add_route(0, "speaker", 1.0, 0); + m_scsp->add_route(1, "speaker", 1.0, 1); stvcd_device &stvcd(STVCD(config, "stvcd", 0)); stvcd.add_route(0, "scsp", 1.0, 0); diff --git a/src/mame/sega/segaatom.cpp b/src/mame/sega/segaatom.cpp index d5f5d4475f8..eb71dc6f3af 100644 --- a/src/mame/sega/segaatom.cpp +++ b/src/mame/sega/segaatom.cpp @@ -112,12 +112,11 @@ void atom2_state::atom2(machine_config &config) PALETTE(config, "palette").set_entries(65536); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz770_device &ymz770(YMZ770(config, "ymz770", 16.384_MHz_XTAL)); - ymz770.add_route(0, "lspeaker", 1.0); - ymz770.add_route(1, "rspeaker", 1.0); + ymz770.add_route(0, "speaker", 1.0, 0); + ymz770.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/sega/segafruit.cpp b/src/mame/sega/segafruit.cpp index 51aa9223cf2..6a90fab3d15 100644 --- a/src/mame/sega/segafruit.cpp +++ b/src/mame/sega/segafruit.cpp @@ -303,13 +303,12 @@ void segafruit_state::segafruit(machine_config & config) GENERIC_LATCH_8(config, m_soundlatch);//.data_pending_callback().set_inputline(m_soundcpu, INPUT_LINE_IRQ0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); RF5C68(config, m_rf5c68, 16_MHz_XTAL / 2); // divider not verified; m_rf5c68->set_addrmap(0, &segafruit_state::pcm_map); - m_rf5c68->add_route(0, "lspeaker", 0.40); - m_rf5c68->add_route(1, "rspeaker", 0.40); + m_rf5c68->add_route(0, "speaker", 0.40, 0); + m_rf5c68->add_route(1, "speaker", 0.40, 1); } ROM_START(m4001) diff --git a/src/mame/sega/segag80r.h b/src/mame/sega/segag80r.h index a1257d9e55b..af44db4d1e1 100644 --- a/src/mame/sega/segag80r.h +++ b/src/mame/sega/segag80r.h @@ -204,7 +204,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state diff --git a/src/mame/sega/segag80r_a.cpp b/src/mame/sega/segag80r_a.cpp index 858d8b00a10..50a84d4a094 100644 --- a/src/mame/sega/segag80r_a.cpp +++ b/src/mame/sega/segag80r_a.cpp @@ -59,14 +59,14 @@ void sega005_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void sega005_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sega005_sound_device::sound_stream_update(sound_stream &stream) { segag80r_state *state = machine().driver_data<segag80r_state>(); const uint8_t *sound_prom = state->memregion("proms")->base(); int i; /* no implementation yet */ - for (i = 0; i < outputs[0].samples(); i++) + for (i = 0; i < stream.samples(); i++) { if (!(state->m_sound_state[1] & 0x10) && (++state->m_square_count & 0xff) == 0) { @@ -77,7 +77,7 @@ void sega005_sound_device::sound_stream_update(sound_stream &stream, std::vector state->m_square_state += 2; } - outputs[0].put(i, (state->m_square_state & 2) ? 1.0 : 0.0); + stream.put(0, i, (state->m_square_state & 2) ? 1.0 : 0.0); } } diff --git a/src/mame/sega/segahang.cpp b/src/mame/sega/segahang.cpp index 1a0f0bbbaf8..c11159505d3 100644 --- a/src/mame/sega/segahang.cpp +++ b/src/mame/sega/segahang.cpp @@ -821,24 +821,23 @@ void segahang_state::sound_board_2203(machine_config &config) m_soundcpu->set_addrmap(AS_IO, &segahang_state::sound_portmap_2203); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2203_device &ymsnd(YM2203(config, "ymsnd", MASTER_CLOCK_8MHz/2)); ymsnd.irq_handler().set_inputline("soundcpu", 0); - ymsnd.add_route(0, "lspeaker", 0.13); - ymsnd.add_route(0, "rspeaker", 0.13); - ymsnd.add_route(1, "lspeaker", 0.13); - ymsnd.add_route(1, "rspeaker", 0.13); - ymsnd.add_route(2, "lspeaker", 0.13); - ymsnd.add_route(2, "rspeaker", 0.13); - ymsnd.add_route(3, "lspeaker", 0.37); - ymsnd.add_route(3, "rspeaker", 0.37); + ymsnd.add_route(0, "speaker", 0.13, 0); + ymsnd.add_route(0, "speaker", 0.13, 1); + ymsnd.add_route(1, "speaker", 0.13, 0); + ymsnd.add_route(1, "speaker", 0.13, 1); + ymsnd.add_route(2, "speaker", 0.13, 0); + ymsnd.add_route(2, "speaker", 0.13, 1); + ymsnd.add_route(3, "speaker", 0.37, 0); + ymsnd.add_route(3, "speaker", 0.37, 1); segapcm_device &pcm(SEGAPCM(config, "pcm", MASTER_CLOCK_8MHz)); pcm.set_bank(segapcm_device::BANK_512); - pcm.add_route(0, "lspeaker", 1.0); - pcm.add_route(1, "rspeaker", 1.0); + pcm.add_route(0, "speaker", 1.0, 0); + pcm.add_route(1, "speaker", 1.0, 1); } void segahang_state::sound_board_2203x2(machine_config &config) @@ -849,34 +848,33 @@ void segahang_state::sound_board_2203x2(machine_config &config) m_soundcpu->set_addrmap(AS_IO, &segahang_state::sound_portmap_2203x2); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2203_device &ym1(YM2203(config, "ym1", MASTER_CLOCK_8MHz/2)); ym1.irq_handler().set_inputline("soundcpu", 0); - ym1.add_route(0, "lspeaker", 0.13); - ym1.add_route(0, "rspeaker", 0.13); - ym1.add_route(1, "lspeaker", 0.13); - ym1.add_route(1, "rspeaker", 0.13); - ym1.add_route(2, "lspeaker", 0.13); - ym1.add_route(2, "rspeaker", 0.13); - ym1.add_route(3, "lspeaker", 0.37); - ym1.add_route(3, "rspeaker", 0.37); + ym1.add_route(0, "speaker", 0.13, 0); + ym1.add_route(0, "speaker", 0.13, 1); + ym1.add_route(1, "speaker", 0.13, 0); + ym1.add_route(1, "speaker", 0.13, 1); + ym1.add_route(2, "speaker", 0.13, 0); + ym1.add_route(2, "speaker", 0.13, 1); + ym1.add_route(3, "speaker", 0.37, 0); + ym1.add_route(3, "speaker", 0.37, 1); ym2203_device &ym2(YM2203(config, "ym2", MASTER_CLOCK_8MHz/2)); - ym2.add_route(0, "lspeaker", 0.13); - ym2.add_route(0, "rspeaker", 0.13); - ym2.add_route(1, "lspeaker", 0.13); - ym2.add_route(1, "rspeaker", 0.13); - ym2.add_route(2, "lspeaker", 0.13); - ym2.add_route(2, "rspeaker", 0.13); - ym2.add_route(3, "lspeaker", 0.37); - ym2.add_route(3, "rspeaker", 0.37); + ym2.add_route(0, "speaker", 0.13, 0); + ym2.add_route(0, "speaker", 0.13, 1); + ym2.add_route(1, "speaker", 0.13, 0); + ym2.add_route(1, "speaker", 0.13, 1); + ym2.add_route(2, "speaker", 0.13, 0); + ym2.add_route(2, "speaker", 0.13, 1); + ym2.add_route(3, "speaker", 0.37, 0); + ym2.add_route(3, "speaker", 0.37, 1); segapcm_device &pcm(SEGAPCM(config, "pcm", MASTER_CLOCK_8MHz/2)); pcm.set_bank(segapcm_device::BANK_512); - pcm.add_route(0, "lspeaker", 1.0); - pcm.add_route(1, "rspeaker", 1.0); + pcm.add_route(0, "speaker", 1.0, 0); + pcm.add_route(1, "speaker", 1.0, 1); } void segahang_state::sound_board_2151(machine_config &config) @@ -887,18 +885,17 @@ void segahang_state::sound_board_2151(machine_config &config) m_soundcpu->set_addrmap(AS_IO, &segahang_state::sound_portmap_2151); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", MASTER_CLOCK_8MHz/2)); ymsnd.irq_handler().set_inputline(m_soundcpu, 0); - ymsnd.add_route(0, "lspeaker", 0.43); - ymsnd.add_route(1, "rspeaker", 0.43); + ymsnd.add_route(0, "speaker", 0.43, 0); + ymsnd.add_route(1, "speaker", 0.43, 1); segapcm_device &pcm(SEGAPCM(config, "pcm", MASTER_CLOCK_8MHz/2)); pcm.set_bank(segapcm_device::BANK_512); - pcm.add_route(0, "lspeaker", 1.0); - pcm.add_route(1, "rspeaker", 1.0); + pcm.add_route(0, "speaker", 1.0, 0); + pcm.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/sega/segald.cpp b/src/mame/sega/segald.cpp index a557f4e8067..9c522dc6ddb 100644 --- a/src/mame/sega/segald.cpp +++ b/src/mame/sega/segald.cpp @@ -384,8 +384,8 @@ void segald_state::astron(machine_config &config) PIONEER_LDV1000(config, m_laserdisc, 0); m_laserdisc->set_overlay(256, 256, FUNC(segald_state::screen_update_astron)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_laserdisc->add_ntsc_screen(config, "screen"); @@ -394,8 +394,7 @@ void segald_state::astron(machine_config &config) PALETTE(config, m_palette).set_entries(256); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/sega/segaorun.cpp b/src/mame/sega/segaorun.cpp index 786063ce037..05b3e974f03 100644 --- a/src/mame/sega/segaorun.cpp +++ b/src/mame/sega/segaorun.cpp @@ -1202,15 +1202,14 @@ void segaorun_state::outrun_base(machine_config &config) SEGAIC16_ROAD(config, m_segaic16road, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", SOUND_CLOCK/4).add_route(0, "lspeaker", 0.43).add_route(1, "rspeaker", 0.43); + YM2151(config, "ymsnd", SOUND_CLOCK/4).add_route(0, "speaker", 0.43, 0).add_route(1, "speaker", 0.43, 1); segapcm_device &pcm(SEGAPCM(config, "pcm", SOUND_CLOCK/4)); pcm.set_bank(segapcm_device::BANK_512); - pcm.add_route(0, "lspeaker", 1.0); - pcm.add_route(1, "rspeaker", 1.0); + pcm.add_route(0, "speaker", 1.0, 0); + pcm.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/sega/segapico.cpp b/src/mame/sega/segapico.cpp index a97a3ca06cd..dff6f2ae139 100644 --- a/src/mame/sega/segapico.cpp +++ b/src/mame/sega/segapico.cpp @@ -404,19 +404,18 @@ void pico_state::pico_ntsc(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &pico_state::pico_mem); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); PICO_CART_SLOT(config, m_picocart, pico_cart, nullptr).set_must_be_loaded(true); SOFTWARE_LIST(config, "cart_list").set_original("pico"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SEGA_315_5641_PCM(config, m_sega_315_5641_pcm, upd7759_device::STANDARD_CLOCK*2); m_sega_315_5641_pcm->fifo_cb().set(FUNC(pico_state::sound_cause_irq)); - m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "lspeaker", 0.16); - m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "rspeaker", 0.16); + m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "speaker", 0.16, 0); + m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "speaker", 0.16, 1); } void pico_state::pico_pal(machine_config &config) @@ -425,19 +424,18 @@ void pico_state::pico_pal(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &pico_state::pico_mem); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); PICO_CART_SLOT(config, m_picocart, pico_cart, nullptr).set_must_be_loaded(true); SOFTWARE_LIST(config, "cart_list").set_original("pico"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SEGA_315_5641_PCM(config, m_sega_315_5641_pcm, upd7759_device::STANDARD_CLOCK*2); m_sega_315_5641_pcm->fifo_cb().set(FUNC(pico_state::sound_cause_irq)); - m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "lspeaker", 0.16); - m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "rspeaker", 0.16); + m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "speaker", 0.16, 0); + m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "speaker", 0.16, 1); } @@ -683,19 +681,18 @@ void copera_state::copera(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &copera_state::copera_mem); - m_vdp->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_vdp->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_vdp->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); COPERA_CART_SLOT(config, m_picocart, copera_cart, nullptr).set_must_be_loaded(true); SOFTWARE_LIST(config, "cart_list").set_original("copera"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SEGA_315_5641_PCM(config, m_sega_315_5641_pcm, upd7759_device::STANDARD_CLOCK); m_sega_315_5641_pcm->fifo_cb().set(FUNC(copera_state::copera_pcm_cb)); - m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "lspeaker", 0.16); - m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "rspeaker", 0.16); + m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "speaker", 0.16, 0); + m_sega_315_5641_pcm->add_route(ALL_OUTPUTS, "speaker", 0.16, 1); } void copera_state::copera_pcm_cb(int state) diff --git a/src/mame/sega/segas24.cpp b/src/mame/sega/segas24.cpp index 9d7409c93d8..a30b65073b6 100644 --- a/src/mame/sega/segas24.cpp +++ b/src/mame/sega/segas24.cpp @@ -1951,15 +1951,14 @@ void segas24_state::system24(machine_config &config) PALETTE(config, m_palette).set_entries(8192*2); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", 4000000)); ymsnd.irq_handler().set(FUNC(segas24_state::irq_ym)); - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); - DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } void segas24_state::system24_rom(machine_config &config) diff --git a/src/mame/sega/segas32.cpp b/src/mame/sega/segas32.cpp index 0c5659741b7..10bf23e5a40 100644 --- a/src/mame/sega/segas32.cpp +++ b/src/mame/sega/segas32.cpp @@ -2274,21 +2274,20 @@ void segas32_state::device_add_mconfig(machine_config &config) m_screen->set_screen_update(FUNC(segas32_state::screen_update_system32)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3438_device &ym1(YM3438(config, "ym1", MASTER_CLOCK/4)); ym1.irq_handler().set(FUNC(segas32_state::ym3438_irq_handler)); - ym1.add_route(0, "lspeaker", 0.40); - ym1.add_route(1, "rspeaker", 0.40); + ym1.add_route(0, "speaker", 0.40, 0); + ym1.add_route(1, "speaker", 0.40, 1); ym3438_device &ym2(YM3438(config, "ym2", MASTER_CLOCK/4)); - ym2.add_route(0, "lspeaker", 0.40); - ym2.add_route(1, "rspeaker", 0.40); + ym2.add_route(0, "speaker", 0.40, 0); + ym2.add_route(1, "speaker", 0.40, 1); rf5c68_device &rfsnd(RF5C68(config, "rfsnd", 50_MHz_XTAL/4)); // ASSP (RF)5C105 or Sega 315-5476A - rfsnd.add_route(0, "lspeaker", 0.55); - rfsnd.add_route(1, "rspeaker", 0.55); + rfsnd.add_route(0, "speaker", 0.55, 0); + rfsnd.add_route(1, "speaker", 0.55, 1); rfsnd.set_addrmap(0, &segas32_state::rf5c68_map); S32COMM(config, m_s32comm, 0); @@ -2510,8 +2509,8 @@ void segas32_cd_state::device_add_mconfig(machine_config &config) NSCSI_CONNECTOR(config, "scsi:0").option_set("cdrom", NSCSI_CDROM).machine_config( [](device_t *device) { - device->subdevice<cdda_device>("cdda")->add_route(0, "^^lspeaker", 1.0); - device->subdevice<cdda_device>("cdda")->add_route(1, "^^rspeaker", 1.0); + device->subdevice<cdda_device>("cdda")->add_route(0, "^^speaker", 1.0, 0); + device->subdevice<cdda_device>("cdda")->add_route(1, "^^speaker", 1.0, 1); }); NSCSI_CONNECTOR(config, "scsi:1", scsi_devices, nullptr); NSCSI_CONNECTOR(config, "scsi:2", scsi_devices, nullptr); @@ -2607,18 +2606,17 @@ void sega_multi32_state::device_add_mconfig(machine_config &config) screen2.set_screen_update(FUNC(segas32_state::screen_update_multi32_right)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3438_device &ymsnd(YM3438(config, "ymsnd", MASTER_CLOCK/4)); ymsnd.irq_handler().set(FUNC(segas32_state::ym3438_irq_handler)); - ymsnd.add_route(1, "lspeaker", 0.40); - ymsnd.add_route(0, "rspeaker", 0.40); + ymsnd.add_route(1, "speaker", 0.40, 0); + ymsnd.add_route(0, "speaker", 0.40, 1); MULTIPCM(config, m_multipcm, MULTI32_CLOCK/4); m_multipcm->set_addrmap(0, &sega_multi32_state::multipcm_map); - m_multipcm->add_route(1, "lspeaker", 1.0); - m_multipcm->add_route(0, "rspeaker", 1.0); + m_multipcm->add_route(1, "speaker", 1.0, 0); + m_multipcm->add_route(0, "speaker", 1.0, 1); S32COMM(config, m_s32comm, 0); } diff --git a/src/mame/sega/segasm1.cpp b/src/mame/sega/segasm1.cpp index 1559c4cb9f1..22ed734ce46 100644 --- a/src/mame/sega/segasm1.cpp +++ b/src/mame/sega/segasm1.cpp @@ -615,12 +615,11 @@ void systemm1_state::m1base(machine_config &config) NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM3438(config, m_ym, XTAL(8'000'000)); - m_ym->add_route(0, "lspeaker", 0.40); - m_ym->add_route(1, "rspeaker", 0.40); + m_ym->add_route(0, "speaker", 0.40, 0); + m_ym->add_route(1, "speaker", 0.40, 1); SEGA_315_5296(config, m_io1, XTAL(16'000'000)); m_io1->in_pa_callback().set_ioport("IN1_PA"); diff --git a/src/mame/sega/segausb.cpp b/src/mame/sega/segausb.cpp index e8e45d4cd79..66c5ff94fa0 100644 --- a/src/mame/sega/segausb.cpp +++ b/src/mame/sega/segausb.cpp @@ -454,12 +454,10 @@ void usb_sound_device::env_w(int which, u8 offset, u8 data) // sound_stream_update - handle a stream update //------------------------------------------------- -void usb_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void usb_sound_device::sound_stream_update(sound_stream &stream) { - auto &dest = outputs[0]; - // iterate over samples - for (int sampindex = 0; sampindex < dest.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { /*---------------- Noise Source @@ -590,7 +588,7 @@ void usb_sound_device::sound_stream_update(sound_stream &stream, std::vector<rea WEIGHT */ - dest.put(sampindex, 0.1 * m_final_filter.step_cr(sample)); + stream.put(0, sampindex, 0.1 * m_final_filter.step_cr(sample)); } } diff --git a/src/mame/sega/segausb.h b/src/mame/sega/segausb.h index 598fb9a96d4..1791f2142c9 100644 --- a/src/mame/sega/segausb.h +++ b/src/mame/sega/segausb.h @@ -62,7 +62,7 @@ protected: #if (!ENABLE_SEGAUSB_NETLIST) // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; #endif private: diff --git a/src/mame/sega/segaxbd.cpp b/src/mame/sega/segaxbd.cpp index 9e6f246b2b8..1dfa93eba58 100644 --- a/src/mame/sega/segaxbd.cpp +++ b/src/mame/sega/segaxbd.cpp @@ -1753,18 +1753,17 @@ void segaxbd_state::xboard_base_mconfig(machine_config &config) SEGAIC16_ROAD(config, m_segaic16road, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", SOUND_CLOCK/4)); ymsnd.irq_handler().set_inputline(m_soundcpu, 0); - ymsnd.add_route(0, "lspeaker", 0.43); - ymsnd.add_route(1, "rspeaker", 0.43); + ymsnd.add_route(0, "speaker", 0.43, 0); + ymsnd.add_route(1, "speaker", 0.43, 1); segapcm_device &pcm(SEGAPCM(config, "pcm", SOUND_CLOCK/4)); pcm.set_bank(segapcm_device::BANK_512); - pcm.add_route(0, "lspeaker", 1.0); - pcm.add_route(1, "rspeaker", 1.0); + pcm.add_route(0, "speaker", 1.0, 0); + pcm.add_route(1, "speaker", 1.0, 1); } @@ -1866,8 +1865,8 @@ void segaxbd_lastsurv_fd1094_state::device_add_mconfig(machine_config &config) // sound hardware - ym2151 stereo is reversed subdevice<ym2151_device>("ymsnd")->reset_routes(); - subdevice<ym2151_device>("ymsnd")->add_route(0, "rspeaker", 0.43); - subdevice<ym2151_device>("ymsnd")->add_route(1, "lspeaker", 0.43); + subdevice<ym2151_device>("ymsnd")->add_route(0, "speaker", 0.43, 1); + subdevice<ym2151_device>("ymsnd")->add_route(1, "speaker", 0.43, 0); } void segaxbd_new_state::sega_lastsurv_fd1094(machine_config &config) @@ -1895,8 +1894,8 @@ void segaxbd_lastsurv_state::device_add_mconfig(machine_config &config) // sound hardware - ym2151 stereo is reversed subdevice<ym2151_device>("ymsnd")->reset_routes(); - subdevice<ym2151_device>("ymsnd")->add_route(0, "rspeaker", 0.43); - subdevice<ym2151_device>("ymsnd")->add_route(1, "lspeaker", 0.43); + subdevice<ym2151_device>("ymsnd")->add_route(0, "speaker", 0.43, 1); + subdevice<ym2151_device>("ymsnd")->add_route(1, "speaker", 0.43, 0); } void segaxbd_new_state::sega_lastsurv(machine_config &config) @@ -2019,8 +2018,7 @@ void segaxbd_rascot_state::device_add_mconfig(machine_config &config) config.device_remove("soundcpu"); config.device_remove("ymsnd"); config.device_remove("pcm"); - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); m_cmptimer_1->zint_callback().set_nop(); cpu_device &commcpu(Z80(config, "commcpu", 8'000'000)); // clock unknown diff --git a/src/mame/sega/segaybd.cpp b/src/mame/sega/segaybd.cpp index 1325d5e72a0..30d5fb419e6 100644 --- a/src/mame/sega/segaybd.cpp +++ b/src/mame/sega/segaybd.cpp @@ -1487,20 +1487,19 @@ void segaybd_state::yboard(machine_config &config) PALETTE(config, m_palette).set_entries(8192*2); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_soundcpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", SOUND_CLOCK/8)); ymsnd.irq_handler().set_inputline(m_soundcpu, 0); - ymsnd.add_route(0, "lspeaker", 0.43); - ymsnd.add_route(1, "rspeaker", 0.43); + ymsnd.add_route(0, "speaker", 0.43, 0); + ymsnd.add_route(1, "speaker", 0.43, 1); segapcm_device &pcm(SEGAPCM(config, "pcm", SOUND_CLOCK/8)); pcm.set_bank(segapcm_device::BANK_12M | segapcm_device::BANK_MASKF8); - pcm.add_route(0, "lspeaker", 1.0); - pcm.add_route(1, "rspeaker", 1.0); + pcm.add_route(0, "speaker", 1.0, 0); + pcm.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/sega/sms.cpp b/src/mame/sega/sms.cpp index 83efcc78d90..e4de133d9d6 100644 --- a/src/mame/sega/sms.cpp +++ b/src/mame/sega/sms.cpp @@ -975,8 +975,7 @@ void gamegear_state::gamegear(machine_config &config) m_main_scr->set_screen_update(FUNC(gamegear_state::screen_update_gamegear)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); /* VDP chip of the Gamegear 2 ASIC version */ SEGA315_5377(config, m_vdp, MASTER_CLOCK_GG/3); @@ -984,8 +983,8 @@ void gamegear_state::gamegear(machine_config &config) m_vdp->set_is_pal(false); m_vdp->n_int().set_inputline(m_maincpu, 0); m_vdp->vblank().set(FUNC(gamegear_state::gg_pause_callback)); - m_vdp->add_route(0, "lspeaker", 1.00); - m_vdp->add_route(1, "rspeaker", 1.00); + m_vdp->add_route(0, "speaker", 1.00, 0); + m_vdp->add_route(1, "speaker", 1.00, 1); /* cartridge */ GAMEGEAR_CART_SLOT(config, "slot", gg_cart, nullptr).set_must_be_loaded(true); diff --git a/src/mame/sega/stv.cpp b/src/mame/sega/stv.cpp index 63848660521..d884c03d418 100644 --- a/src/mame/sega/stv.cpp +++ b/src/mame/sega/stv.cpp @@ -1160,15 +1160,14 @@ void stv_state::stv(machine_config &config) MCFG_VIDEO_START_OVERRIDE(stv_state,stv_vdp2) - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SCSP(config, m_scsp, 22579200); // TODO : Unknown clock, divider m_scsp->set_addrmap(0, &stv_state::scsp_mem); m_scsp->irq_cb().set(FUNC(saturn_state::scsp_irq)); m_scsp->main_irq_cb().set(m_scu, FUNC(sega_scu_device::sound_req_w)); - m_scsp->add_route(0, "lspeaker", 1.0); - m_scsp->add_route(1, "rspeaker", 1.0); + m_scsp->add_route(0, "speaker", 1.0, 0); + m_scsp->add_route(1, "speaker", 1.0, 1); SEGA_BILLBOARD(config, m_billboard, 0); @@ -1253,8 +1252,8 @@ void stv_state::batmanfr(machine_config &config) stv(config); ACCLAIM_RAX(config, m_rax, 0); // TODO: RAX output connected to SCSP? - m_rax->add_route(0, "lspeaker", 1.0); - m_rax->add_route(1, "rspeaker", 1.0); + m_rax->add_route(0, "speaker", 1.0, 0); + m_rax->add_route(1, "speaker", 1.0, 1); } void stv_state::shienryu(machine_config &config) diff --git a/src/mame/sega/stvcd.cpp b/src/mame/sega/stvcd.cpp index ff6f8e0d9b6..ad6dc32e767 100644 --- a/src/mame/sega/stvcd.cpp +++ b/src/mame/sega/stvcd.cpp @@ -101,7 +101,7 @@ DEFINE_DEVICE_TYPE(STVCD, stvcd_device, "stvcd", "Sega Saturn/ST-V CD Block HLE" stvcd_device::stvcd_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, STVCD, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , device_memory_interface(mconfig, *this) , m_space_config("regs", ENDIANNESS_LITTLE, 32, 20, 0, address_map_constructor(FUNC(stvcd_device::io_regs), this)) , m_cdrom_image(*this, "cdrom") @@ -120,8 +120,8 @@ void stvcd_device::device_add_mconfig(machine_config &config) TIMER(config, m_sh1_timer).configure_generic(FUNC(stvcd_device::stv_sh1_sim)); CDDA(config, m_cdda); - m_cdda->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_cdda->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_cdda->add_route(0, *this, 1.0, 0); + m_cdda->add_route(1, *this, 1.0, 1); m_cdda->set_cdrom_tag("cdrom"); } diff --git a/src/mame/sega/system16.cpp b/src/mame/sega/system16.cpp index ea22399b411..7c93915bc78 100644 --- a/src/mame/sega/system16.cpp +++ b/src/mame/sega/system16.cpp @@ -2078,10 +2078,9 @@ void segas1x_bootleg_state::z80_ym2151(machine_config &config) m_soundcpu->set_addrmap(AS_IO, &segas1x_bootleg_state::sound_io_map); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 4000000).add_route(0, "lspeaker", 0.32).add_route(1, "rspeaker", 0.32); + YM2151(config, "ymsnd", 4000000).add_route(0, "speaker", 0.32, 0).add_route(1, "speaker", 0.32, 1); } void segas1x_bootleg_state::sound_cause_nmi(int state) @@ -2097,15 +2096,14 @@ void segas1x_bootleg_state::z80_ym2151_upd7759(machine_config &config) m_soundcpu->set_addrmap(AS_IO, &segas1x_bootleg_state::sound_7759_io_map); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 4000000).add_route(0, "lspeaker", 0.32).add_route(1, "rspeaker", 0.32); + YM2151(config, "ymsnd", 4000000).add_route(0, "speaker", 0.32, 0).add_route(1, "speaker", 0.32, 1); UPD7759(config, m_upd7759); m_upd7759->drq().set(FUNC(segas1x_bootleg_state::sound_cause_nmi)); - m_upd7759->add_route(ALL_OUTPUTS, "lspeaker", 0.48); - m_upd7759->add_route(ALL_OUTPUTS, "rspeaker", 0.48); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.48, 0); + m_upd7759->add_route(ALL_OUTPUTS, "speaker", 0.48, 1); } void segas1x_bootleg_state::datsu_ym2151_msm5205(machine_config &config) @@ -2119,16 +2117,15 @@ void segas1x_bootleg_state::datsu_ym2151_msm5205(machine_config &config) m_soundcpu->set_addrmap(AS_PROGRAM, &segas1x_bootleg_state::tturfbl_sound_map); m_soundcpu->set_addrmap(AS_IO, &segas1x_bootleg_state::tturfbl_sound_io_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 4000000).add_route(0, "lspeaker", 0.32).add_route(1, "rspeaker", 0.32); + YM2151(config, "ymsnd", 4000000).add_route(0, "speaker", 0.32, 0).add_route(1, "speaker", 0.32, 1); MSM5205(config, m_msm, 220000); m_msm->vck_legacy_callback().set(FUNC(segas1x_bootleg_state::tturfbl_msm5205_callback)); m_msm->set_prescaler_selector(msm5205_device::S48_4B); - m_msm->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_msm->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } void segas1x_bootleg_state::datsu_2x_ym2203_msm5205(machine_config &config) @@ -2458,22 +2455,21 @@ void segas1x_bootleg_state::system18(machine_config &config) m_sprites->set_local_originx(64); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym3438_device &ym3438_0(YM3438(config, "3438.0", 8000000)); - ym3438_0.add_route(0, "lspeaker", 0.40); - ym3438_0.add_route(1, "rspeaker", 0.40); + ym3438_0.add_route(0, "speaker", 0.40, 0); + ym3438_0.add_route(1, "speaker", 0.40, 1); ym3438_device &ym3438_1(YM3438(config, "3438.1", 8000000)); - ym3438_1.add_route(0, "lspeaker", 0.40); - ym3438_1.add_route(1, "rspeaker", 0.40); + ym3438_1.add_route(0, "speaker", 0.40, 0); + ym3438_1.add_route(1, "speaker", 0.40, 1); rf5c68_device &rf5c68(RF5C68(config, "5c68", 8000000)); - rf5c68.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - rf5c68.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + rf5c68.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + rf5c68.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); rf5c68.set_addrmap(0, &segas1x_bootleg_state::pcm_map); } @@ -2530,8 +2526,8 @@ void segas1x_bootleg_state::shdancbl(machine_config &config) MSM5205(config, m_msm, 200000); m_msm->vck_legacy_callback().set(FUNC(segas1x_bootleg_state::shdancbl_msm5205_callback)); m_msm->set_prescaler_selector(msm5205_device::S48_4B); - m_msm->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_msm->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } void segas1x_bootleg_state::shdancbla(machine_config &config) @@ -2549,8 +2545,8 @@ void segas1x_bootleg_state::shdancbla(machine_config &config) MSM5205(config, m_msm, 200000); m_msm->vck_legacy_callback().set(FUNC(segas1x_bootleg_state::shdancbl_msm5205_callback)); m_msm->set_prescaler_selector(msm5205_device::S48_4B); - m_msm->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_msm->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } diff --git a/src/mame/sega/turbo_a.cpp b/src/mame/sega/turbo_a.cpp index db99ba87673..f49e176958c 100644 --- a/src/mame/sega/turbo_a.cpp +++ b/src/mame/sega/turbo_a.cpp @@ -193,49 +193,46 @@ static const char *const turbo_sample_names[] = void turbo_state::turbo_samples(machine_config &config) { // this is the cockpit speaker configuration - SPEAKER(config, "fspeaker", 0.0, 0.0, 1.0); // front - SPEAKER(config, "bspeaker", 0.0, 0.0, -0.5); // back - SPEAKER(config, "lspeaker", -0.2, 0.0, 1.0); // left - SPEAKER(config, "rspeaker", 0.2, 0.0, 1.0); // right + SPEAKER(config, "speaker", 4).front().front_center(2).rear_center(3); SAMPLES(config, m_samples); m_samples->set_channels(10); m_samples->set_samples_names(turbo_sample_names); // channel 0 = CRASH.S -> CRASH.S/SM - m_samples->add_route(0, "fspeaker", 0.25); + m_samples->add_route(0, "speaker", 0.25, 2); // channel 1 = TRIG1-4 -> ALARM.M/F/R/L - m_samples->add_route(1, "fspeaker", 0.25); - m_samples->add_route(1, "rspeaker", 0.25); - m_samples->add_route(1, "lspeaker", 0.25); + m_samples->add_route(1, "speaker", 0.25, 2); + m_samples->add_route(1, "speaker", 0.25, 1); + m_samples->add_route(1, "speaker", 0.25, 0); // channel 2 = SLIP/SPIN -> SKID.F/R/L/M - m_samples->add_route(2, "fspeaker", 0.25); - m_samples->add_route(2, "rspeaker", 0.25); - m_samples->add_route(2, "lspeaker", 0.25); + m_samples->add_route(2, "speaker", 0.25, 2); + m_samples->add_route(2, "speaker", 0.25, 1); + m_samples->add_route(2, "speaker", 0.25, 0); // channel 3 = CRASH.L -> CRASH.L/LM - m_samples->add_route(3, "bspeaker", 0.25); + m_samples->add_route(3, "speaker", 0.25, 3); // channel 4 = AMBU -> AMBULANCE/AMBULANCE.M - m_samples->add_route(4, "fspeaker", 0.25); + m_samples->add_route(4, "speaker", 0.25, 2); // channel 5 = ACCEL+BSEL -> MYCAR.F/W/M + MYCAR0.F/M + MYCAR1.F/M - m_samples->add_route(5, "fspeaker", 0.25); - m_samples->add_route(5, "bspeaker", 0.25); + m_samples->add_route(5, "speaker", 0.25, 2); + m_samples->add_route(5, "speaker", 0.25, 3); // channel 6 = OSEL -> OCAR.F/FM - m_samples->add_route(6, "fspeaker", 0.25); + m_samples->add_route(6, "speaker", 0.25, 2); // channel 7 = OSEL -> OCAR.L/LM - m_samples->add_route(7, "lspeaker", 0.25); + m_samples->add_route(7, "speaker", 0.25, 0); // channel 8 = OSEL -> OCAR.R/RM - m_samples->add_route(8, "rspeaker", 0.25); + m_samples->add_route(8, "speaker", 0.25, 1); // channel 9 = OSEL -> OCAR.W/WM - m_samples->add_route(9, "bspeaker", 0.25); + m_samples->add_route(9, "speaker", 0.25, 3); } /* @@ -438,44 +435,43 @@ static const char *const subroc3d_sample_names[] = void subroc3d_state::subroc3d_samples(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAMPLES(config, m_samples); m_samples->set_channels(12); m_samples->set_samples_names(subroc3d_sample_names); // MISSILE in channels 0 and 1 - m_samples->add_route(0, "lspeaker", 0.25); - m_samples->add_route(1, "rspeaker", 0.25); + m_samples->add_route(0, "speaker", 0.25, 0); + m_samples->add_route(1, "speaker", 0.25, 1); // TORPEDO in channels 2 and 3 - m_samples->add_route(2, "lspeaker", 0.25); - m_samples->add_route(3, "rspeaker", 0.25); + m_samples->add_route(2, "speaker", 0.25, 0); + m_samples->add_route(3, "speaker", 0.25, 1); // FIGHTER in channels 4 and 5 - m_samples->add_route(4, "lspeaker", 0.25); - m_samples->add_route(5, "rspeaker", 0.25); + m_samples->add_route(4, "speaker", 0.25, 0); + m_samples->add_route(5, "speaker", 0.25, 1); // HIT in channels 6 and 7 - m_samples->add_route(6, "lspeaker", 0.25); - m_samples->add_route(7, "rspeaker", 0.25); + m_samples->add_route(6, "speaker", 0.25, 0); + m_samples->add_route(7, "speaker", 0.25, 1); // FIRE sound in channel 8 - m_samples->add_route(8, "lspeaker", 0.25); - m_samples->add_route(8, "rspeaker", 0.25); + m_samples->add_route(8, "speaker", 0.25, 0); + m_samples->add_route(8, "speaker", 0.25, 1); // SHIP EXP sound in channel 9 - m_samples->add_route(9, "lspeaker", 0.25); - m_samples->add_route(9, "rspeaker", 0.25); + m_samples->add_route(9, "speaker", 0.25, 0); + m_samples->add_route(9, "speaker", 0.25, 1); // ALARM TRIG sound in channel 10 - m_samples->add_route(10, "lspeaker", 0.25); - m_samples->add_route(10, "rspeaker", 0.25); + m_samples->add_route(10, "speaker", 0.25, 0); + m_samples->add_route(10, "speaker", 0.25, 1); // PROLOGUE sound in channel 11 - m_samples->add_route(11, "lspeaker", 0.25); - m_samples->add_route(11, "rspeaker", 0.25); + m_samples->add_route(11, "speaker", 0.25, 0); + m_samples->add_route(11, "speaker", 0.25, 1); } diff --git a/src/mame/sega/winclub.cpp b/src/mame/sega/winclub.cpp index 8edb0f2e56f..28413060a93 100644 --- a/src/mame/sega/winclub.cpp +++ b/src/mame/sega/winclub.cpp @@ -101,12 +101,11 @@ void winclub_state::winclub(machine_config &config) screen.set_screen_update(FUNC(winclub_state::screen_update)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz770_device &ymz770(YMZ770(config, "ymz", 16'384'000)); // internal clock? - ymz770.add_route(0, "lspeaker", 1.0); - ymz770.add_route(1, "rspeaker", 1.0); + ymz770.add_route(0, "speaker", 1.0, 0); + ymz770.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/seibu/seibucats.cpp b/src/mame/seibu/seibucats.cpp index 89ef9b6bce1..8e18612f46a 100644 --- a/src/mame/seibu/seibucats.cpp +++ b/src/mame/seibu/seibucats.cpp @@ -337,12 +337,11 @@ void seibucats_state::seibucats(machine_config &config) PALETTE(config, m_palette, palette_device::BLACK, 8192); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'384'000))); - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/seibu/seibuspi.cpp b/src/mame/seibu/seibuspi.cpp index 1108752b18c..2bb6907a258 100644 --- a/src/mame/seibu/seibuspi.cpp +++ b/src/mame/seibu/seibuspi.cpp @@ -1793,17 +1793,16 @@ void seibuspi_state::spi(machine_config &config) crtc.layer_scroll_callback().set(FUNC(seibuspi_state::scroll_w)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymf271_device &ymf(YMF271(config, "ymf", 16.9344_MHz_XTAL)); ymf.irq_handler().set(FUNC(seibuspi_state::ymf_irqhandler)); ymf.set_addrmap(0, &seibuspi_state::spi_ymf271_map); - ymf.add_route(0, "lspeaker", 1.0); - ymf.add_route(1, "rspeaker", 1.0); -// ymf.add_route(2, "lspeaker", 1.0); Output 2/3 not used? -// ymf.add_route(3, "rspeaker", 1.0); + ymf.add_route(0, "speaker", 1.0, 0); + ymf.add_route(1, "speaker", 1.0, 1); +// ymf.add_route(2, "speaker", 1.0); Output 2/3 not used? +// ymf.add_route(3, "speaker", 1.0); } void seibuspi_state::ejanhs(machine_config &config) @@ -1848,8 +1847,7 @@ void seibuspi_state::sxx2e(machine_config &config) /* sound hardware */ // Single PCBs only output mono sound, SXX2E : unverified - config.device_remove("lspeaker"); - config.device_remove("rspeaker"); + config.device_remove("speaker"); SPEAKER(config, "mono").front_center(); ymf271_device &ymf(YMF271(config.replace(), "ymf", 16.9344_MHz_XTAL)); diff --git a/src/mame/seta/champbwl.cpp b/src/mame/seta/champbwl.cpp index dae7b4def64..269bcb680f1 100644 --- a/src/mame/seta/champbwl.cpp +++ b/src/mame/seta/champbwl.cpp @@ -571,12 +571,11 @@ void champbwl_state::champbwl(machine_config &config) PALETTE(config, "palette", FUNC(champbwl_state::palette), 512); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); x1_010_device &x1snd(X1_010(config, "x1snd", 16_MHz_XTAL)); - x1snd.add_route(0, "lspeaker", 1.0); - x1snd.add_route(1, "rspeaker", 1.0); + x1snd.add_route(0, "speaker", 1.0, 0); + x1snd.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/seta/jclub2.cpp b/src/mame/seta/jclub2.cpp index db8a6cbdacd..9eee5dccd0a 100644 --- a/src/mame/seta/jclub2.cpp +++ b/src/mame/seta/jclub2.cpp @@ -1190,11 +1190,10 @@ void jclub2o_state::jclub2o(machine_config &config) config.set_default_layout(layout_jclub2o); // TODO: Mono? - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_soundcpu->add_route(0, "lspeaker", 1.0); - m_soundcpu->add_route(1, "rspeaker", 1.0); + m_soundcpu->add_route(0, "speaker", 1.0, 0); + m_soundcpu->add_route(1, "speaker", 1.0, 1); } @@ -1234,12 +1233,11 @@ void jclub2_state::jclub2(machine_config &config) // sound hardware // TODO: Mono? - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); st0032_sound_device &st0032_snd(ST0032_SOUND(config, "st0032_snd", XTAL(42'954'545) / 3)); // 14.318181MHz (42.954545MHz / 3) - st0032_snd.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - st0032_snd.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + st0032_snd.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + st0032_snd.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/seta/kiwame.cpp b/src/mame/seta/kiwame.cpp index 4d4991c70b9..3ed0a808317 100644 --- a/src/mame/seta/kiwame.cpp +++ b/src/mame/seta/kiwame.cpp @@ -292,12 +292,11 @@ void kiwame_state::kiwame(machine_config &config) PALETTE(config, "palette").set_format(palette_device::xRGB_555, 512); // sprites only /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); x1_010_device &x1snd(X1_010(config, "x1snd", 16000000)); - x1snd.add_route(0, "lspeaker", 1.0); - x1snd.add_route(1, "rspeaker", 1.0); + x1snd.add_route(0, "speaker", 1.0, 0); + x1snd.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/seta/namcoeva.cpp b/src/mame/seta/namcoeva.cpp index 86aedea0aff..226784c7021 100644 --- a/src/mame/seta/namcoeva.cpp +++ b/src/mame/seta/namcoeva.cpp @@ -409,14 +409,13 @@ void namcoeva_state::hammerch(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x8000+0xf0); // extra 0xf0 because we might draw 256-color object with 16-color granularity // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); c352_device &c352(C352(config, "c352", 50_MHz_XTAL / 2, 288)); // TODO: clock and divider not verified - c352.add_route(0, "lspeaker", 1.00); - c352.add_route(1, "rspeaker", 1.00); - c352.add_route(2, "lspeaker", 1.00); - c352.add_route(3, "rspeaker", 1.00); + c352.add_route(0, "speaker", 1.00, 0); + c352.add_route(1, "speaker", 1.00, 1); + c352.add_route(2, "speaker", 1.00, 0); + c352.add_route(3, "speaker", 1.00, 1); } diff --git a/src/mame/seta/seta.cpp b/src/mame/seta/seta.cpp index 1764747ef23..1ed94028d5f 100644 --- a/src/mame/seta/seta.cpp +++ b/src/mame/seta/seta.cpp @@ -7827,12 +7827,11 @@ void setaroul_state::setaroul(machine_config &config) PALETTE(config, m_palette, FUNC(setaroul_state::setaroul_palette), 512); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); X1_010(config, m_x1snd, 16_MHz_XTAL); // 16 MHz - m_x1snd->add_route(0, "lspeaker", 1.0); - m_x1snd->add_route(1, "rspeaker", 1.0); + m_x1snd->add_route(0, "speaker", 1.0, 0); + m_x1snd->add_route(1, "speaker", 1.0, 1); // layout config.set_default_layout(layout_setaroul); @@ -7931,12 +7930,11 @@ void seta_state::extdwnhl(machine_config &config) PALETTE(config, m_palette, FUNC(seta_state::zingzip_palette), 16*32 + 16*32 + 64*32*2, 0x600); // sprites, layer2, layer1 - layer 1 gfx is 6 planes deep // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); X1_010(config, m_x1snd, 16000000); // 16 MHz - m_x1snd->add_route(0, "lspeaker", 1.0); - m_x1snd->add_route(1, "rspeaker", 1.0); + m_x1snd->add_route(0, "speaker", 1.0, 0); + m_x1snd->add_route(1, "speaker", 1.0, 1); } @@ -8186,12 +8184,11 @@ void seta_state::orbs(machine_config &config) PALETTE(config, m_palette).set_entries(512); // sprites only // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); X1_010(config, m_x1snd, 14.318181_MHz_XTAL); // 14.318180 MHz - m_x1snd->add_route(0, "lspeaker", 1.0); - m_x1snd->add_route(1, "rspeaker", 1.0); + m_x1snd->add_route(0, "speaker", 1.0, 0); + m_x1snd->add_route(1, "speaker", 1.0, 1); } @@ -8225,12 +8222,11 @@ void keroppi_state::keroppi(machine_config &config) PALETTE(config, m_palette).set_entries(512); // sprites only // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); X1_010(config, m_x1snd, 14318180); // 14.318180 MHz - m_x1snd->add_route(0, "lspeaker", 1.0); - m_x1snd->add_route(1, "rspeaker", 1.0); + m_x1snd->add_route(0, "speaker", 1.0, 0); + m_x1snd->add_route(1, "speaker", 1.0, 1); } @@ -8510,12 +8506,11 @@ void seta_state::oisipuzl(machine_config &config) set_tilemaps_flip(1); // flip is inverted for the tilemaps // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); X1_010(config, m_x1snd, 16000000); // 16 MHz - m_x1snd->add_route(0, "lspeaker", 1.0); - m_x1snd->add_route(1, "rspeaker", 1.0); + m_x1snd->add_route(0, "speaker", 1.0, 0); + m_x1snd->add_route(1, "speaker", 1.0, 1); } @@ -8557,12 +8552,11 @@ void seta_state::triplfun(machine_config &config) set_tilemaps_flip(1); // flip is inverted for the tilemaps // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", 792000, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } @@ -9126,12 +9120,11 @@ void jockeyc_state::jockeyc(machine_config &config) PALETTE(config, m_palette, FUNC(seta_state::palette_init_RRRRRGGGGGBBBBB_proms), 512 * 1); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); X1_010(config, m_x1snd, 16000000); - m_x1snd->add_route(0, "lspeaker", 1.0); - m_x1snd->add_route(1, "rspeaker", 1.0); + m_x1snd->add_route(0, "speaker", 1.0, 0); + m_x1snd->add_route(1, "speaker", 1.0, 1); // layout config.set_default_layout(layout_jockeyc); diff --git a/src/mame/seta/seta2.cpp b/src/mame/seta/seta2.cpp index 66e5873b89c..4c95669bada 100644 --- a/src/mame/seta/seta2.cpp +++ b/src/mame/seta/seta2.cpp @@ -2498,12 +2498,11 @@ void funcube_state::funcube(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x8000+0xf0); // extra 0xf0 because we might draw 256-color object with 16-color granularity // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM9810(config, m_oki, XTAL(4'096'000)); - m_oki->add_route(0, "lspeaker", 0.80); - m_oki->add_route(1, "rspeaker", 0.80); + m_oki->add_route(0, "speaker", 0.80, 0); + m_oki->add_route(1, "speaker", 0.80, 1); } @@ -2542,12 +2541,11 @@ void seta2_state::namcostr(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x8000+0xf0); // extra 0xf0 because we might draw 256-color object with 16-color granularity // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM9810(config, m_oki, XTAL(4'096'000)); - m_oki->add_route(0, "lspeaker", 0.80); - m_oki->add_route(1, "rspeaker", 0.80); + m_oki->add_route(0, "speaker", 0.80, 0); + m_oki->add_route(1, "speaker", 0.80, 1); } diff --git a/src/mame/seta/simple_st0016.cpp b/src/mame/seta/simple_st0016.cpp index d0a1d8e5d6f..7ddb0755102 100644 --- a/src/mame/seta/simple_st0016.cpp +++ b/src/mame/seta/simple_st0016.cpp @@ -578,11 +578,10 @@ void st0016_state::st0016(machine_config &config) m_screen->set_palette("maincpu:palette"); // TODO: Mono? - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); } void st0016_state::mayjinsn(machine_config &config) diff --git a/src/mame/seta/speglsht.cpp b/src/mame/seta/speglsht.cpp index d967f023ed7..7a924e0dae0 100644 --- a/src/mame/seta/speglsht.cpp +++ b/src/mame/seta/speglsht.cpp @@ -444,11 +444,10 @@ void speglsht_state::speglsht(machine_config &config) screen.set_screen_update(FUNC(speglsht_state::screen_update)); // TODO: Mono? - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); } ROM_START( speglsht ) diff --git a/src/mame/seta/srmp5.cpp b/src/mame/seta/srmp5.cpp index 2e78563f45c..aca1fffb654 100644 --- a/src/mame/seta/srmp5.cpp +++ b/src/mame/seta/srmp5.cpp @@ -599,11 +599,10 @@ void srmp5_state::srmp5(machine_config &config) #endif // TODO: Mono? - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - m_soundcpu->add_route(0, "lspeaker", 1.0); - m_soundcpu->add_route(1, "rspeaker", 1.0); + m_soundcpu->add_route(0, "speaker", 1.0, 0); + m_soundcpu->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/seta/srmp6.cpp b/src/mame/seta/srmp6.cpp index b7e2b1bcea4..bc976023a83 100644 --- a/src/mame/seta/srmp6.cpp +++ b/src/mame/seta/srmp6.cpp @@ -703,13 +703,12 @@ void srmp6_state::srmp6(machine_config &config) BUFFERED_SPRITERAM16(config, m_sprram); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // matches video, needs to verified; playback rate: (42.9545Mhz / 7) / 160 or (42.9545Mhz / 5) / 224 or (42.9545Mhz / 4) / 280? nile_sound_device &nile(NILE_SOUND(config, "nile", XTAL(42'954'545) / 7)); - nile.add_route(0, "lspeaker", 1.0); - nile.add_route(1, "rspeaker", 1.0); + nile.add_route(0, "speaker", 1.0, 0); + nile.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/seta/ssv.cpp b/src/mame/seta/ssv.cpp index f660ffb3058..7704c7f6869 100644 --- a/src/mame/seta/ssv.cpp +++ b/src/mame/seta/ssv.cpp @@ -2477,8 +2477,7 @@ void ssv_state::ssv(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_888, 0x8000); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ES5506(config, m_ensoniq, SSV_MASTER_CLOCK); m_ensoniq->set_region0("ensoniq.0"); @@ -2486,8 +2485,8 @@ void ssv_state::ssv(machine_config &config) m_ensoniq->set_region2("ensoniq.2"); m_ensoniq->set_region3("ensoniq.3"); m_ensoniq->set_channels(1); - m_ensoniq->add_route(0, "lspeaker", 0.075); - m_ensoniq->add_route(1, "rspeaker", 0.075); + m_ensoniq->add_route(0, "speaker", 0.075, 0); + m_ensoniq->add_route(1, "speaker", 0.075, 1); } void drifto94_state::drifto94(machine_config &config) diff --git a/src/mame/seta/st0016.cpp b/src/mame/seta/st0016.cpp index c50e5940e47..b38796057c7 100644 --- a/src/mame/seta/st0016.cpp +++ b/src/mame/seta/st0016.cpp @@ -48,7 +48,7 @@ st0016_cpu_device::st0016_cpu_device(const machine_config &mconfig, const char * : z80_device(mconfig, ST0016_CPU, tag, owner, clock) , device_gfx_interface(mconfig, *this, nullptr, "palette") , device_video_interface(mconfig, *this, false) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_io_space_config("io", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(st0016_cpu_device::cpu_internal_io_map), this)) , m_space_config("regs", ENDIANNESS_LITTLE, 8, 16, 0, address_map_constructor(FUNC(st0016_cpu_device::cpu_internal_map), this)) , m_charam_space_config("charam", ENDIANNESS_LITTLE, 8, 21, 0, address_map_constructor(FUNC(st0016_cpu_device::charam_map), this)) @@ -150,8 +150,8 @@ void st0016_cpu_device::device_add_mconfig(machine_config &config) st0016_device &stsnd(ST0016(config, "stsnd", DERIVED_CLOCK(1,1))); stsnd.set_addrmap(0, &st0016_cpu_device::charam_map); - stsnd.add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - stsnd.add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + stsnd.add_route(0, *this, 1.0, 0); + stsnd.add_route(1, *this, 1.0, 1); } diff --git a/src/mame/sgi/hal2.cpp b/src/mame/sgi/hal2.cpp index 7c0d25e4f52..28bd7e3f05f 100644 --- a/src/mame/sgi/hal2.cpp +++ b/src/mame/sgi/hal2.cpp @@ -379,12 +379,11 @@ void hal2_device::dma_write(uint32_t channel, int16_t data) void hal2_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_ldac, 0); - m_ldac->add_route(ALL_OUTPUTS, "lspeaker", 0.25); + m_ldac->add_route(ALL_OUTPUTS, "speaker", 0.25, 0); DAC_16BIT_R2R_TWOS_COMPLEMENT(config, m_rdac, 0); - m_rdac->add_route(ALL_OUTPUTS, "rspeaker", 0.25); + m_rdac->add_route(ALL_OUTPUTS, "speaker", 0.25, 1); } diff --git a/src/mame/sgi/ip4.cpp b/src/mame/sgi/ip4.cpp index 50345d578cd..b546316df3f 100644 --- a/src/mame/sgi/ip4.cpp +++ b/src/mame/sgi/ip4.cpp @@ -323,12 +323,11 @@ void sgi_ip4_device::device_add_mconfig(machine_config &config) m_serial[3]->dcd_handler().set(m_duart[2], FUNC(scn2681_device::ip2_w)); // TODO: move speakers to host - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SAA1099(config, m_saa, 8_MHz_XTAL); - m_saa->add_route(0, "lspeaker", 0.5); - m_saa->add_route(1, "rspeaker", 0.5); + m_saa->add_route(0, "speaker", 0.5, 0); + m_saa->add_route(1, "speaker", 0.5, 1); // TODO: ACFAIL -> vme_irq<0> device_vme_card_interface::vme_irq<1>().set(*this, FUNC(sgi_ip4_device::vme_irq<1>)); diff --git a/src/mame/sgi/kbd.cpp b/src/mame/sgi/kbd.cpp index 9cd59afb8b0..d78c7c242e8 100644 --- a/src/mame/sgi/kbd.cpp +++ b/src/mame/sgi/kbd.cpp @@ -123,7 +123,8 @@ enum p3_mask : u8 void sgi_kbd_device::device_add_mconfig(machine_config &config) { - speaker_device &speaker(SPEAKER(config, "speaker").front_center()); + speaker_device &speaker(SPEAKER(config, "speaker")); + speaker.front_center(); beep_device &beeper(BEEP(config, "beeper", 480)); beeper.add_route(ALL_OUTPUTS, speaker, 0.25); diff --git a/src/mame/shared/ballysound.cpp b/src/mame/shared/ballysound.cpp index 466c61769c2..167304b5bc2 100644 --- a/src/mame/shared/ballysound.cpp +++ b/src/mame/shared/ballysound.cpp @@ -125,7 +125,7 @@ TIMER_CALLBACK_MEMBER(bally_as2888_device::sound_int_sync) void bally_as2888_device::device_add_mconfig(machine_config &config) { DISCRETE(config, m_discrete, as2888_discrete); - m_discrete->add_route(ALL_OUTPUTS, *this, 1.00, AUTO_ALLOC_INPUT, 0); + m_discrete->add_route(ALL_OUTPUTS, *this, 1.00, 0); TIMER(config, "timer_s_freq").configure_periodic(FUNC(bally_as2888_device::timer_s), attotime::from_hz(353000)); // Inverter clock on AS-2888 sound board TIMER(config, m_snd_sustain_timer).configure_generic(FUNC(bally_as2888_device::timer_as2888)); @@ -270,7 +270,7 @@ void bally_as3022_device::device_add_mconfig(machine_config &config) m_ay->add_route(1, "ay_filter1", 0.33); m_ay->add_route(2, "ay_filter2", 0.33); m_ay->port_a_read_callback().set(FUNC(bally_as3022_device::ay_io_r)); - m_ay->add_route(ALL_OUTPUTS, *this, 0.33, AUTO_ALLOC_INPUT, 0); + m_ay->add_route(ALL_OUTPUTS, *this, 0.33, 0); } @@ -528,7 +528,7 @@ void bally_cheap_squeak_device::device_add_mconfig(machine_config &config) m_cpu->in_p2_cb().set(FUNC(bally_cheap_squeak_device::in_p2_cb)); m_cpu->out_p2_cb().set(FUNC(bally_cheap_squeak_device::out_p2_cb)); - ZN429E(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 1.00, AUTO_ALLOC_INPUT, 0); + ZN429E(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 1.00, 0); } //------------------------------------------------- diff --git a/src/mame/shared/cage.cpp b/src/mame/shared/cage.cpp index e87188361ee..3d7703a8b79 100644 --- a/src/mame/shared/cage.cpp +++ b/src/mame/shared/cage.cpp @@ -194,7 +194,7 @@ atari_cage_device::atari_cage_device(const machine_config &mconfig, const char * atari_cage_device::atari_cage_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock), - device_mixer_interface(mconfig, *this, 5), // 5 output routines in JSPKR + device_mixer_interface(mconfig, *this), m_cpu(*this, "cpu"), m_cageram(*this, "cageram"), m_soundlatch(*this, "soundlatch"), @@ -693,19 +693,19 @@ void atari_cage_device::device_add_mconfig(machine_config &config) GENERIC_LATCH_16(config, m_soundlatch); #if (DAC_BUFFER_CHANNELS == 4) - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 0); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, *this, 0.50, 0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 1); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, *this, 0.50, 1); - DMADAC(config, m_dmadac[2]).add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 2); + DMADAC(config, m_dmadac[2]).add_route(ALL_OUTPUTS, *this, 0.50, 2); - DMADAC(config, m_dmadac[3]).add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 3); + DMADAC(config, m_dmadac[3]).add_route(ALL_OUTPUTS, *this, 0.50, 3); #else - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, *this, 1.0, 0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, *this, 1.0, 1); #endif - //add_route(ALL_OUTPUTS, *this, 0.50, AUTO_ALLOC_INPUT, 4); Subwoofer output + //add_route(ALL_OUTPUTS, *this, 0.50, 4); Subwoofer output } // Embedded in San francisco Rush Motherboard, 4 channel output connected to Quad Amp PCB and expanded to 5 channel (4 channel + subwoofer) diff --git a/src/mame/shared/dcs.cpp b/src/mame/shared/dcs.cpp index f206dca836a..1c5bd615716 100644 --- a/src/mame/shared/dcs.cpp +++ b/src/mame/shared/dcs.cpp @@ -682,9 +682,9 @@ void dcs_audio_device::denver_postload() // dcs_audio_device - constructor //------------------------------------------------- -dcs_audio_device::dcs_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rev, int outputs) : +dcs_audio_device::dcs_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rev) : device_t(mconfig, type, tag, owner, clock), - device_mixer_interface(mconfig, *this, outputs), + device_mixer_interface(mconfig, *this), m_maincpu(*this, finder_base::DUMMY_TAG), m_reg_timer(*this, "dcs_reg_timer"), m_sport0_timer(*this, "dcs_sport0_timer"), @@ -2462,7 +2462,7 @@ void dcs_audio_device::add_mconfig_dcs(machine_config &config) TIMER(config, m_reg_timer).configure_generic(FUNC(dcs_audio_device::dcs_irq)); TIMER(config, m_internal_timer).configure_generic(FUNC(dcs_audio_device::internal_timer_callback)); - DMADAC(config, "dac").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); // AD-1851 16bit mono + DMADAC(config, "dac").add_route(ALL_OUTPUTS, *this, 1.0, 0); // AD-1851 16bit mono } DEFINE_DEVICE_TYPE(DCS_AUDIO_2K, dcs_audio_2k_device, "dcs_audio_2k", "DCS Audio 2K") @@ -2472,7 +2472,7 @@ DEFINE_DEVICE_TYPE(DCS_AUDIO_2K, dcs_audio_2k_device, "dcs_audio_2k", "DCS Audio //------------------------------------------------- dcs_audio_2k_device::dcs_audio_2k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs_audio_device(mconfig, DCS_AUDIO_2K, tag, owner, clock, REV_DCS1, 1) + dcs_audio_device(mconfig, DCS_AUDIO_2K, tag, owner, clock, REV_DCS1) { } @@ -2488,7 +2488,7 @@ DEFINE_DEVICE_TYPE(DCS_AUDIO_2K_UART, dcs_audio_2k_uart_device, "dcs_audio_2k_ua //------------------------------------------------- dcs_audio_2k_uart_device::dcs_audio_2k_uart_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs_audio_device(mconfig, DCS_AUDIO_2K_UART, tag, owner, clock, REV_DCS1, 1) + dcs_audio_device(mconfig, DCS_AUDIO_2K_UART, tag, owner, clock, REV_DCS1) { } @@ -2506,7 +2506,7 @@ DEFINE_DEVICE_TYPE(DCS_AUDIO_8K, dcs_audio_8k_device, "dcs_audio_8k", "DCS Audio //------------------------------------------------- dcs_audio_8k_device::dcs_audio_8k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs_audio_device(mconfig, DCS_AUDIO_8K, tag, owner, clock, REV_DCS1, 1) + dcs_audio_device(mconfig, DCS_AUDIO_8K, tag, owner, clock, REV_DCS1) { } @@ -2525,7 +2525,7 @@ DEFINE_DEVICE_TYPE(DCS_AUDIO_WPC, dcs_audio_wpc_device, "dcs_audio_wpc", "DCS Au //------------------------------------------------- dcs_audio_wpc_device::dcs_audio_wpc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs_audio_device(mconfig, DCS_AUDIO_WPC, tag, owner, clock, REV_DCS1P5, 1) + dcs_audio_device(mconfig, DCS_AUDIO_WPC, tag, owner, clock, REV_DCS1P5) { } @@ -2541,8 +2541,8 @@ void dcs_audio_wpc_device::device_add_mconfig(machine_config &config) // dcs2_audio_device - constructor //------------------------------------------------- -dcs2_audio_device::dcs2_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int outputs) : - dcs_audio_device(mconfig, type, tag, owner, clock, REV_DCS1, outputs) +dcs2_audio_device::dcs2_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + dcs_audio_device(mconfig, type, tag, owner, clock, REV_DCS1) { } @@ -2559,8 +2559,8 @@ void dcs2_audio_device::add_mconfig_dcs2(machine_config &config) TIMER(config, m_internal_timer).configure_generic(FUNC(dcs2_audio_device::internal_timer_callback)); TIMER(config, "dcs_hle_timer").configure_generic(FUNC(dcs2_audio_device::transfer_watchdog_callback)); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, 0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, 1); } DEFINE_DEVICE_TYPE(DCS2_AUDIO_2115, dcs2_audio_2115_device, "dcs2_audio_2115", "DCS2 Audio 2115") @@ -2570,7 +2570,7 @@ DEFINE_DEVICE_TYPE(DCS2_AUDIO_2115, dcs2_audio_2115_device, "dcs2_audio_2115", " //------------------------------------------------- dcs2_audio_2115_device::dcs2_audio_2115_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs2_audio_device(mconfig, DCS2_AUDIO_2115, tag, owner, clock, 2) + dcs2_audio_device(mconfig, DCS2_AUDIO_2115, tag, owner, clock) { } @@ -2587,7 +2587,7 @@ DEFINE_DEVICE_TYPE(DCS2_AUDIO_2104, dcs2_audio_2104_device, "dcs2_audio_2104", " dcs2_audio_2104_device::dcs2_audio_2104_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs2_audio_device(mconfig, DCS2_AUDIO_2104, tag, owner, clock, 2) + dcs2_audio_device(mconfig, DCS2_AUDIO_2104, tag, owner, clock) { } @@ -2609,7 +2609,7 @@ DEFINE_DEVICE_TYPE(DCS2_AUDIO_DSIO, dcs2_audio_dsio_device, "dcs2_audio_dsio", " //------------------------------------------------- dcs2_audio_dsio_device::dcs2_audio_dsio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs2_audio_device(mconfig, DCS2_AUDIO_DSIO, tag, owner, clock, 2) + dcs2_audio_device(mconfig, DCS2_AUDIO_DSIO, tag, owner, clock) { } @@ -2629,16 +2629,16 @@ void dcs2_audio_dsio_device::device_add_mconfig(machine_config &config) TIMER(config, m_internal_timer).configure_generic(FUNC(dcs2_audio_dsio_device::internal_timer_callback)); TIMER(config, m_sport0_timer).configure_generic(FUNC(dcs2_audio_dsio_device::sport0_irq)); // roadburn needs this to pass hardware test - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, 0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, 1); } //------------------------------------------------- // dcs2_audio_denver_device - constructor //------------------------------------------------- -dcs2_audio_denver_device::dcs2_audio_denver_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int outputs) : - dcs2_audio_device(mconfig, type, tag, owner, clock, outputs) +dcs2_audio_denver_device::dcs2_audio_denver_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : + dcs2_audio_device(mconfig, type, tag, owner, clock) { } @@ -2660,7 +2660,7 @@ void dcs2_audio_denver_device::device_add_mconfig(machine_config &config) } dcs2_audio_denver_5ch_device::dcs2_audio_denver_5ch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs2_audio_denver_device(mconfig, DCS2_AUDIO_DENVER_5CH, tag, owner, clock, 5) + dcs2_audio_denver_device(mconfig, DCS2_AUDIO_DENVER_5CH, tag, owner, clock) { } @@ -2668,18 +2668,18 @@ void dcs2_audio_denver_5ch_device::device_add_mconfig(machine_config &config) { dcs2_audio_denver_device::device_add_mconfig(config); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); - DMADAC(config, "dac3").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 2); - DMADAC(config, "dac4").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 3); - DMADAC(config, "dac5").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 4); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, 0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, 1); + DMADAC(config, "dac3").add_route(ALL_OUTPUTS, *this, 1.0, 2); + DMADAC(config, "dac4").add_route(ALL_OUTPUTS, *this, 1.0, 3); + DMADAC(config, "dac5").add_route(ALL_OUTPUTS, *this, 1.0, 4); DMADAC(config, "dac6"); // Does not produce sound } DEFINE_DEVICE_TYPE(DCS2_AUDIO_DENVER_5CH, dcs2_audio_denver_5ch_device, "dcs2_audio_denver_5ch", "DCS2 Audio Denver 5 Channel") dcs2_audio_denver_2ch_device::dcs2_audio_denver_2ch_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : - dcs2_audio_denver_device(mconfig, DCS2_AUDIO_DENVER_2CH, tag, owner, clock, 2) + dcs2_audio_denver_device(mconfig, DCS2_AUDIO_DENVER_2CH, tag, owner, clock) { } @@ -2687,8 +2687,8 @@ void dcs2_audio_denver_2ch_device::device_add_mconfig(machine_config &config) { dcs2_audio_denver_device::device_add_mconfig(config); - DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); - DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); + DMADAC(config, "dac1").add_route(ALL_OUTPUTS, *this, 1.0, 0); + DMADAC(config, "dac2").add_route(ALL_OUTPUTS, *this, 1.0, 1); } DEFINE_DEVICE_TYPE(DCS2_AUDIO_DENVER_2CH, dcs2_audio_denver_2ch_device, "dcs2_audio_denver_2ch", "DCS2 Audio Denver 2 Channel") diff --git a/src/mame/shared/dcs.h b/src/mame/shared/dcs.h index 41583d966ee..9c1125cb25b 100644 --- a/src/mame/shared/dcs.h +++ b/src/mame/shared/dcs.h @@ -55,7 +55,7 @@ public: protected: // construction/destruction - dcs_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rev, int outputs); + dcs_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int rev); // device_t implementation virtual void device_start() override ATTR_COLD; @@ -317,7 +317,7 @@ class dcs2_audio_device : public dcs_audio_device { protected: // construction/destruction - dcs2_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int outputs); + dcs2_audio_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); // device_t implementation virtual void device_start() override ATTR_COLD; @@ -374,7 +374,7 @@ class dcs2_audio_denver_device : public dcs2_audio_device { protected: // construction/destruction - dcs2_audio_denver_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock, int outputs); + dcs2_audio_denver_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); // device_t implementation virtual void device_add_mconfig(machine_config &config) override ATTR_COLD; diff --git a/src/mame/shared/decobsmt.cpp b/src/mame/shared/decobsmt.cpp index b787358d8e2..2846bdaebcf 100644 --- a/src/mame/shared/decobsmt.cpp +++ b/src/mame/shared/decobsmt.cpp @@ -54,8 +54,8 @@ void decobsmt_device::device_add_mconfig(machine_config &config) BSMT2000(config, m_bsmt, XTAL(24'000'000)); m_bsmt->set_addrmap(0, &decobsmt_device::bsmt_map); m_bsmt->set_ready_callback(FUNC(decobsmt_device::bsmt_ready_callback)); - m_bsmt->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_bsmt->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_bsmt->add_route(0, *this, 1.0, 0); + m_bsmt->add_route(1, *this, 1.0, 1); } //************************************************************************** @@ -68,7 +68,7 @@ void decobsmt_device::device_add_mconfig(machine_config &config) decobsmt_device::decobsmt_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, DECOBSMT, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_ourcpu(*this, "soundcpu") , m_bsmt(*this, "bsmt") , m_bsmt_latch(0) diff --git a/src/mame/shared/exidysound.cpp b/src/mame/shared/exidysound.cpp index 4bfea5e6463..0d13158c9c7 100644 --- a/src/mame/shared/exidysound.cpp +++ b/src/mame/shared/exidysound.cpp @@ -242,16 +242,15 @@ void exidy_sound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void exidy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void exidy_sound_device::sound_stream_update(sound_stream &stream) { sh6840_timer_channel *sh6840_timer = m_sh6840_timer; // hack to skip the expensive lfsr noise generation unless at least one of the 3 channels actually depends on it being generated bool noisy = ((sh6840_timer[0].cr & sh6840_timer[1].cr & sh6840_timer[2].cr & 0x02) == 0); - auto &buffer = outputs[0]; // loop over samples - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { sh6840_timer_channel *t; int clocks; @@ -311,7 +310,7 @@ void exidy_sound_device::sound_stream_update(sound_stream &stream, std::vector<r sample += generate_music_sample(); // stash - buffer.put_int(sampindex, sample, 32768); + stream.put_int(0, sampindex, sample, 32768); } } diff --git a/src/mame/shared/exidysound.h b/src/mame/shared/exidysound.h index e7c74b0b7df..e5312b2b154 100644 --- a/src/mame/shared/exidysound.h +++ b/src/mame/shared/exidysound.h @@ -55,7 +55,7 @@ protected: void sh6840_register_state_globals(); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual s32 generate_music_sample() { return 0; } static inline void sh6840_apply_clock(sh6840_timer_channel *t, int clocks); diff --git a/src/mame/shared/mega32x.cpp b/src/mame/shared/mega32x.cpp index 277d2d9c102..2983c96af22 100644 --- a/src/mame/shared/mega32x.cpp +++ b/src/mame/shared/mega32x.cpp @@ -935,10 +935,10 @@ void sega_32x_device::m68k_pwm_w(offs_t offset, uint16_t data) pwm_w(offset,data); } -void sega_32x_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void sega_32x_device::sound_stream_update(sound_stream &stream) { - outputs[0] = inputs[0]; - outputs[1] = inputs[1]; + stream.copy(0, 0); + stream.copy(1, 1); } /**********************************************************************************************/ diff --git a/src/mame/shared/mega32x.h b/src/mame/shared/mega32x.h index 5c447ddc841..81c1e0066f9 100644 --- a/src/mame/shared/mega32x.h +++ b/src/mame/shared/mega32x.h @@ -111,7 +111,7 @@ protected: virtual uint32_t palette_entries() const noexcept override { return 32*32*32/**2*/; } // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void update_total_scanlines(bool mode3) { m_total_scanlines = mode3 ? (m_base_total_scanlines * 2) : m_base_total_scanlines; } // this gets set at each EOF diff --git a/src/mame/shared/megacdcd.cpp b/src/mame/shared/megacdcd.cpp index 35c64e9386a..a1245dfc59b 100644 --- a/src/mame/shared/megacdcd.cpp +++ b/src/mame/shared/megacdcd.cpp @@ -1161,8 +1161,8 @@ void lc89510_temp_device::device_add_mconfig(machine_config &config) TIMER(config, "hock_timer").configure_periodic(FUNC(lc89510_temp_device::segacd_access_timer_callback), attotime::from_hz(75)); cdda_device &cdda(CDDA(config, "cdda")); - cdda.add_route(0, ":lspeaker", 0.50); // TODO: accurate volume balance - cdda.add_route(1, ":rspeaker", 0.50); + cdda.add_route(0, ":speaker", 0.50, 0); // TODO: accurate volume balance + cdda.add_route(1, ":speaker", 0.50, 1); cdda.set_cdrom_tag(m_cdrom); } diff --git a/src/mame/shared/rax.cpp b/src/mame/shared/rax.cpp index 5dbf32aef55..076f09bd5db 100644 --- a/src/mame/shared/rax.cpp +++ b/src/mame/shared/rax.cpp @@ -494,7 +494,7 @@ DEFINE_DEVICE_TYPE(ACCLAIM_RAX, acclaim_rax_device, "rax_audio", "Acclaim RAX") acclaim_rax_device::acclaim_rax_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, ACCLAIM_RAX, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_cpu(*this, "adsp") , m_dmadac(*this, { "dacl", "dacr" }) , m_reg_timer(*this, "adsp_reg_timer") @@ -527,9 +527,8 @@ void acclaim_rax_device::device_add_mconfig(machine_config &config) GENERIC_LATCH_16(config, m_data_in); GENERIC_LATCH_16(config, m_data_out); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); - DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 1); + DMADAC(config, m_dmadac[0]).add_route(ALL_OUTPUTS, *this, 1.0, 0); + DMADAC(config, m_dmadac[1]).add_route(ALL_OUTPUTS, *this, 1.0, 1); } diff --git a/src/mame/shared/segam1audio.cpp b/src/mame/shared/segam1audio.cpp index a486eb15343..e8971ea58d9 100644 --- a/src/mame/shared/segam1audio.cpp +++ b/src/mame/shared/segam1audio.cpp @@ -55,22 +55,21 @@ void segam1audio_device::device_add_mconfig(machine_config &config) M68000(config, m_audiocpu, 20_MHz_XTAL / 2); // verified on real h/w m_audiocpu->set_addrmap(AS_PROGRAM, &segam1audio_device::segam1audio_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM3438(config, m_ym, 16_MHz_XTAL / 2); - m_ym->add_route(0, "lspeaker", 0.30); - m_ym->add_route(1, "rspeaker", 0.30); + m_ym->add_route(0, "speaker", 0.30, 0); + m_ym->add_route(1, "speaker", 0.30, 1); MULTIPCM(config, m_multipcm_1, 20_MHz_XTAL / 2); m_multipcm_1->set_addrmap(0, &segam1audio_device::mpcm1_map); - m_multipcm_1->add_route(0, "lspeaker", 0.5); - m_multipcm_1->add_route(1, "rspeaker", 0.5); + m_multipcm_1->add_route(0, "speaker", 0.5, 0); + m_multipcm_1->add_route(1, "speaker", 0.5, 1); MULTIPCM(config, m_multipcm_2, 20_MHz_XTAL / 2); m_multipcm_2->set_addrmap(0, &segam1audio_device::mpcm2_map); - m_multipcm_2->add_route(0, "lspeaker", 0.5); - m_multipcm_2->add_route(1, "rspeaker", 0.5); + m_multipcm_2->add_route(0, "speaker", 0.5, 0); + m_multipcm_2->add_route(1, "speaker", 0.5, 1); I8251(config, m_uart, 16_MHz_XTAL / 2); // T82C51 m_uart->rxrdy_handler().set_inputline(m_audiocpu, M68K_IRQ_2); diff --git a/src/mame/shared/vboysound.cpp b/src/mame/shared/vboysound.cpp index a4c39921dcf..59cd1f27c62 100644 --- a/src/mame/shared/vboysound.cpp +++ b/src/mame/shared/vboysound.cpp @@ -269,14 +269,11 @@ TIMER_CALLBACK_MEMBER(vboysnd_device::delayed_stream_update) // our sound stream //------------------------------------------------- -void vboysnd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void vboysnd_device::sound_stream_update(sound_stream &stream) { int len, i, j, channel; - auto &outL = outputs[0]; - auto &outR = outputs[1]; - - len = outL.samples(); + len = stream.samples(); // if (mgetb(m_aram+SST0P) & 0x1) // Sound Stop Reg // goto end; @@ -384,8 +381,8 @@ void vboysnd_device::sound_stream_update(sound_stream &stream, std::vector<read_ note_left = (note_left << 5) | ((note_left >> 6) & 0x1f); note_right = (note_right << 5) | ((note_right >> 6) & 0x1f); - outL.put_int_clamp(j, note_left, 32768); - outR.put_int_clamp(j, note_right, 32768); + stream.put_int_clamp(0, j, note_left, 32768); + stream.put_int_clamp(1, j, note_right, 32768); } } diff --git a/src/mame/shared/vboysound.h b/src/mame/shared/vboysound.h index 73210dc8fe8..d9f62f55fd0 100644 --- a/src/mame/shared/vboysound.h +++ b/src/mame/shared/vboysound.h @@ -71,7 +71,7 @@ protected: virtual void device_clock_changed() override; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(delayed_stream_update); diff --git a/src/mame/shared/wswansound.cpp b/src/mame/shared/wswansound.cpp index 73c42b7d520..6f250241988 100644 --- a/src/mame/shared/wswansound.cpp +++ b/src/mame/shared/wswansound.cpp @@ -158,11 +158,9 @@ u8 wswan_sound_device::fetch_sample(int channel, int offset) // sound_stream_update - handle a stream update //------------------------------------------------- -void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void wswan_sound_device::sound_stream_update(sound_stream &stream) { - auto &outputl = outputs[0]; - auto &outputr = outputs[1]; - for (int sampindex = 0; sampindex < outputl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { m_loutput = m_routput = 0; if (m_headphone_connected ? m_headphone_enable : m_speaker_enable) @@ -270,20 +268,20 @@ void wswan_sound_device::sound_stream_update(sound_stream &stream, std::vector<r } } // TODO: clamped? - outputl.put_int_clamp(sampindex, left, 32768); - outputr.put_int_clamp(sampindex, right, 32768); + stream.put_int_clamp(0, sampindex, left, 32768); + stream.put_int_clamp(1, sampindex, right, 32768); } else { u8 const mono = (((m_loutput & 0x3ff) + (m_routput & 0x3ff)) >> m_speaker_volume) & 0xff; - outputl.put_int(sampindex, mono, 256); - outputr.put_int(sampindex, mono, 256); + stream.put_int(0, sampindex, mono, 256); + stream.put_int(1, sampindex, mono, 256); } } else { - outputl.put(sampindex, 0.0); - outputr.put(sampindex, 0.0); + stream.put(0, sampindex, 0.0); + stream.put(1, sampindex, 0.0); } } } diff --git a/src/mame/shared/wswansound.h b/src/mame/shared/wswansound.h index f300a597b29..cdce7b8aeff 100644 --- a/src/mame/shared/wswansound.h +++ b/src/mame/shared/wswansound.h @@ -40,7 +40,7 @@ protected: virtual void rom_bank_pre_change() override; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct channel_t diff --git a/src/mame/sharp/x1.cpp b/src/mame/sharp/x1.cpp index 03eaf413078..2dd18d0f93e 100644 --- a/src/mame/sharp/x1.cpp +++ b/src/mame/sharp/x1.cpp @@ -2237,20 +2237,19 @@ void x1_state::x1(machine_config &config) GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "x1_cart", "bin,rom"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: fix thru schematics (formation of resistors tied to ABC outputs) ay8910_device &ay(AY8910(config, "ay", MAIN_CLOCK/8)); ay.port_a_read_callback().set_ioport("P1"); ay.port_b_read_callback().set_ioport("P2"); - ay.add_route(ALL_OUTPUTS, "lspeaker", 0.25); - ay.add_route(ALL_OUTPUTS, "rspeaker", 0.25); + ay.add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + ay.add_route(ALL_OUTPUTS, "speaker", 0.25, 1); CASSETTE(config, m_cassette); m_cassette->set_formats(x1_cassette_formats); m_cassette->set_default_state(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_ENABLED); - m_cassette->add_route(ALL_OUTPUTS, "lspeaker", 0.25).add_route(ALL_OUTPUTS, "rspeaker", 0.10); + m_cassette->add_route(ALL_OUTPUTS, "speaker", 0.25, 0).add_route(ALL_OUTPUTS, "speaker", 0.10, 1); m_cassette->set_interface("x1_cass"); SOFTWARE_LIST(config, "cass_list").set_original("x1_cass"); @@ -2289,8 +2288,8 @@ void x1turbo_state::x1turbo(machine_config &config) m_ctc_ym->zc_callback<0>().set(m_ctc_ym, FUNC(z80ctc_device::trg3)); YM2151(config, m_ym, MAIN_CLOCK/8); - m_ym->add_route(0, "lspeaker", 0.50); - m_ym->add_route(1, "rspeaker", 0.50); + m_ym->add_route(0, "speaker", 0.50, 0); + m_ym->add_route(1, "speaker", 0.50, 1); } /************************************* diff --git a/src/mame/sharp/x1twin.cpp b/src/mame/sharp/x1twin.cpp index 4a4c8f3419e..a8a4a747fe2 100644 --- a/src/mame/sharp/x1twin.cpp +++ b/src/mame/sharp/x1twin.cpp @@ -496,8 +496,7 @@ void x1twin_state::x1twin(machine_config &config) SPEAKER(config, "pce_l").front_left(); SPEAKER(config, "pce_r").front_right(); -// SPEAKER(config, "lspeaker").front_left(); -// SPEAKER(config, "rspeaker").front_right(); +// SPEAKER(config, "speaker", 2).front(); /* TODO:is the AY mono or stereo? Also volume balance isn't right. */ ay8910_device &ay(AY8910(config, "ay", MAIN_CLOCK/8)); diff --git a/src/mame/sharp/x68k.cpp b/src/mame/sharp/x68k.cpp index e702030c437..0f4d8efe2bd 100644 --- a/src/mame/sharp/x68k.cpp +++ b/src/mame/sharp/x68k.cpp @@ -1075,13 +1075,12 @@ void x68k_state::x68000_base(machine_config &config) config.set_default_layout(layout_x68000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, 16_MHz_XTAL / 4); m_ym2151->irq_handler().set(FUNC(x68k_state::fm_irq)); m_ym2151->port_write_handler().set(FUNC(x68k_state::ct_w)); // CT1, CT2 from YM2151 port 0x1b - m_ym2151->add_route(0, "lspeaker", 0.50); - m_ym2151->add_route(1, "rspeaker", 0.50); + m_ym2151->add_route(0, "speaker", 0.50, 0); + m_ym2151->add_route(1, "speaker", 0.50, 1); OKIM6258(config, m_okim6258, 16_MHz_XTAL / 4); m_okim6258->set_start_div(okim6258_device::FOSC_DIV_BY_512); @@ -1090,8 +1089,8 @@ void x68k_state::x68000_base(machine_config &config) m_okim6258->add_route(ALL_OUTPUTS, "adpcm_outl", 0.50); m_okim6258->add_route(ALL_OUTPUTS, "adpcm_outr", 0.50); - FILTER_VOLUME(config, m_adpcm_out[0]).add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, m_adpcm_out[1]).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, m_adpcm_out[0]).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, m_adpcm_out[1]).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); UPD72065(config, m_upd72065, 16_MHz_XTAL / 2, true, false); // clocked through SED9420CAC m_upd72065->intrq_wr_callback().set(FUNC(x68k_state::ioc_irq<IOC_FDC_INT>)); diff --git a/src/mame/sigma/sigmab98.cpp b/src/mame/sigma/sigmab98.cpp index 45aaba3214c..c9c59105374 100644 --- a/src/mame/sigma/sigmab98.cpp +++ b/src/mame/sigma/sigmab98.cpp @@ -1464,12 +1464,11 @@ void sigmab98_state::sigmab98(machine_config &config) BUFFERED_SPRITERAM8(config, m_buffered_spriteram); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymz280b_device &ymz(YMZ280B(config, "ymz", 16934400)); // clock @X2? - ymz.add_route(0, "lspeaker", 1.0); - ymz.add_route(1, "rspeaker", 1.0); + ymz.add_route(0, "speaker", 1.0, 0); + ymz.add_route(1, "speaker", 1.0, 1); } void sigmab98_state::dodghero(machine_config &config) @@ -1545,11 +1544,10 @@ void lufykzku_state::lufykzku(machine_config &config) //BUFFERED_SPRITERAM8(config, m_buffered_spriteram); // same as sammymdl? // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", XTAL(4'096'000))); - oki.add_route(0, "lspeaker", 0.80); - oki.add_route(1, "rspeaker", 0.80); + oki.add_route(0, "speaker", 0.80, 0); + oki.add_route(1, "speaker", 0.80, 1); } void lufykzku_state::rockman(machine_config& config) @@ -1616,12 +1614,11 @@ void sammymdl_state::sammymdl(machine_config &config) //BUFFERED_SPRITERAM8(config, m_buffered_spriteram); // not on sammymdl? // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", XTAL(4'096'000))); - oki.add_route(0, "lspeaker", 0.80); - oki.add_route(1, "rspeaker", 0.80); + oki.add_route(0, "speaker", 0.80, 0); + oki.add_route(1, "speaker", 0.80, 1); } void sammymdl_state::animalc(machine_config &config) diff --git a/src/mame/sinclair/chloe.cpp b/src/mame/sinclair/chloe.cpp index c8af1e9d9e5..03f7a44fdb1 100644 --- a/src/mame/sinclair/chloe.cpp +++ b/src/mame/sinclair/chloe.cpp @@ -955,24 +955,23 @@ void chloe_state::chloe(machine_config &config) PALETTE(config, m_palette, FUNC(chloe_state::spectrum_palette), 256); SCREEN_ULA_PLUS(config, m_ula, 0).set_raster_offset(SCR_256x192.left(), SCR_256x192.top()).set_palette(m_palette->device().tag(), 0x000, 0x000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.device_remove("ay8912"); AY8912(config, m_ay[0], 28_MHz_XTAL / 16) - .add_route(0, "lspeaker", 0.50) - .add_route(2, "lspeaker", 0.25) - .add_route(2, "rspeaker", 0.25) - .add_route(1, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(2, "speaker", 0.25, 0) + .add_route(2, "speaker", 0.25, 1) + .add_route(1, "speaker", 0.50, 1); AY8912(config, m_ay[1], 28_MHz_XTAL / 16) - .add_route(0, "lspeaker", 0.50) - .add_route(2, "lspeaker", 0.25) - .add_route(2, "rspeaker", 0.25) - .add_route(1, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(2, "speaker", 0.25, 0) + .add_route(2, "speaker", 0.25, 1) + .add_route(1, "speaker", 0.50, 1); DAC_8BIT_R2R(config, m_covox, 0) - .add_route(ALL_OUTPUTS, "lspeaker", 0.75) - .add_route(ALL_OUTPUTS, "rspeaker", 0.75); + .add_route(ALL_OUTPUTS, "speaker", 0.75, 0) + .add_route(ALL_OUTPUTS, "speaker", 0.75, 1); KBDC8042(config, m_kbdc); m_kbdc->set_keyboard_type(kbdc8042_device::KBDC8042_STANDARD); diff --git a/src/mame/sinclair/pentagon.cpp b/src/mame/sinclair/pentagon.cpp index 8cbc4e7daa5..ec529442e6f 100644 --- a/src/mame/sinclair/pentagon.cpp +++ b/src/mame/sinclair/pentagon.cpp @@ -203,14 +203,13 @@ void pentagon_state::pentagon(machine_config &config) BETA_DISK(config, m_beta, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ay8912_device &ay8912(AY8912(config.replace(), "ay8912", 14_MHz_XTAL / 8)); - ay8912.add_route(0, "lspeaker", 0.50); - ay8912.add_route(1, "lspeaker", 0.25); - ay8912.add_route(1, "rspeaker", 0.25); - ay8912.add_route(2, "rspeaker", 0.50); + ay8912.add_route(0, "speaker", 0.50, 0); + ay8912.add_route(1, "speaker", 0.25, 0); + ay8912.add_route(1, "speaker", 0.25, 1); + ay8912.add_route(2, "speaker", 0.50, 1); config.device_remove("exp"); diff --git a/src/mame/sinclair/pentevo.cpp b/src/mame/sinclair/pentevo.cpp index c1ac0017368..e77dc02efc5 100644 --- a/src/mame/sinclair/pentevo.cpp +++ b/src/mame/sinclair/pentevo.cpp @@ -768,20 +768,19 @@ void pentevo_state::pentevo(machine_config &config) m_sdcard->set_prefer_sdhc(); m_sdcard->spi_miso_callback().set(FUNC(pentevo_state::spi_miso_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.device_remove("ay8912"); YM2149(config, m_ay[0], 14_MHz_XTAL / 8) - .add_route(0, "lspeaker", 0.50) - .add_route(1, "lspeaker", 0.25) - .add_route(1, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(1, "speaker", 0.25, 0) + .add_route(1, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); YM2149(config, m_ay[1], 14_MHz_XTAL / 8) - .add_route(0, "lspeaker", 0.50) - .add_route(1, "lspeaker", 0.25) - .add_route(1, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(1, "speaker", 0.25, 0) + .add_route(1, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); AT_KEYB(config, m_keyboard, pc_keyboard_device::KEYBOARD_TYPE::AT, 3); diff --git a/src/mame/sinclair/scorpion.cpp b/src/mame/sinclair/scorpion.cpp index 901f420beb1..ce568a30a33 100644 --- a/src/mame/sinclair/scorpion.cpp +++ b/src/mame/sinclair/scorpion.cpp @@ -509,19 +509,18 @@ void scorpion_state::scorpion(machine_config &config) subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_scorpion); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); AY8912(config, m_ay[0], 14_MHz_XTAL / 8) // BAC - .add_route(1, "lspeaker", 0.50) - .add_route(0, "lspeaker", 0.25) - .add_route(0, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(1, "speaker", 0.50, 0) + .add_route(0, "speaker", 0.25, 0) + .add_route(0, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); AY8912(config, m_ay[1], 14_MHz_XTAL / 8) - .add_route(1, "lspeaker", 0.50) - .add_route(0, "lspeaker", 0.25) - .add_route(0, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(1, "speaker", 0.50, 0) + .add_route(0, "speaker", 0.25, 0) + .add_route(0, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); BETA_DISK(config, m_beta, 0); diff --git a/src/mame/sinclair/specnext.cpp b/src/mame/sinclair/specnext.cpp index 9bfd6a11207..12af744711b 100644 --- a/src/mame/sinclair/specnext.cpp +++ b/src/mame/sinclair/specnext.cpp @@ -3467,22 +3467,21 @@ void specnext_state::tbblue(machine_config &config) m_sdcard->set_prefer_sdhc(); m_sdcard->spi_miso_callback().set(FUNC(specnext_state::spi_miso_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_8BIT_R2R(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.75); - DAC_8BIT_R2R(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "lspeaker", 0.75); - DAC_8BIT_R2R(config, m_dac[2], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.75); - DAC_8BIT_R2R(config, m_dac[3], 0).add_route(ALL_OUTPUTS, "rspeaker", 0.75); + DAC_8BIT_R2R(config, m_dac[0], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + DAC_8BIT_R2R(config, m_dac[1], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + DAC_8BIT_R2R(config, m_dac[2], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 1); + DAC_8BIT_R2R(config, m_dac[3], 0).add_route(ALL_OUTPUTS, "speaker", 0.75, 1); config.device_remove("ay8912"); for (auto i = 0; i < 3; ++i) { YM2149(config, m_ay[i], 14_MHz_XTAL / 8) - .add_route(0, "lspeaker", 0.50) - .add_route(1, "lspeaker", 0.25) - .add_route(1, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(1, "speaker", 0.25, 0) + .add_route(1, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); } SPECNEXT_MULTIFACE(config, m_mf, 0); diff --git a/src/mame/sinclair/sprinter.cpp b/src/mame/sinclair/sprinter.cpp index a01a35d525b..6d431614c2f 100644 --- a/src/mame/sinclair/sprinter.cpp +++ b/src/mame/sinclair/sprinter.cpp @@ -1933,17 +1933,16 @@ void sprinter_state::sprinter(machine_config &config) m_maincpu->zc_callback<0>().append(m_maincpu, FUNC(z84c015_device::txcb_w)); m_maincpu->zc_callback<2>().set(m_maincpu, FUNC(z84c015_device::trg3)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ay8910_device &ay8910(AY8910(config.replace(), "ay8912", X_SP / 24)); - ay8910.add_route(0, "lspeaker", 0.50); - ay8910.add_route(1, "lspeaker", 0.25); - ay8910.add_route(1, "rspeaker", 0.25); - ay8910.add_route(2, "rspeaker", 0.50); + ay8910.add_route(0, "speaker", 0.50, 0); + ay8910.add_route(1, "speaker", 0.25, 0); + ay8910.add_route(1, "speaker", 0.25, 1); + ay8910.add_route(2, "speaker", 0.50, 1); - DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); - DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); + DAC_16BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + DAC_16BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); subdevice<gfxdecode_device>("gfxdecode")->set_info(gfx_sprinter); } diff --git a/src/mame/sinclair/tsconf.cpp b/src/mame/sinclair/tsconf.cpp index cc6f12dd4c0..7321e147334 100644 --- a/src/mame/sinclair/tsconf.cpp +++ b/src/mame/sinclair/tsconf.cpp @@ -299,20 +299,23 @@ void tsconf_state::tsconf(machine_config &config) m_dma->on_ready_callback().set(FUNC(tsconf_state::dma_ready)); BETA_DISK(config, m_beta, 0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); + + SPI_SDCARD(config, m_sdcard, 0); + m_sdcard->set_prefer_sdhc(); + m_sdcard->spi_miso_callback().set(FUNC(tsconf_state::tsconf_spi_miso_w)); config.device_remove("ay8912"); YM2149(config, m_ay[0], 14_MHz_XTAL / 8) - .add_route(0, "lspeaker", 0.50) - .add_route(1, "lspeaker", 0.25) - .add_route(1, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(1, "speaker", 0.25, 0) + .add_route(1, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); YM2149(config, m_ay[1], 14_MHz_XTAL / 8) - .add_route(0, "lspeaker", 0.50) - .add_route(1, "lspeaker", 0.25) - .add_route(1, "rspeaker", 0.25) - .add_route(2, "rspeaker", 0.50); + .add_route(0, "speaker", 0.50, 0) + .add_route(1, "speaker", 0.25, 0) + .add_route(1, "speaker", 0.25, 1) + .add_route(2, "speaker", 0.50, 1); DAC_8BIT_R2R(config, m_dac, 0).add_route(ALL_OUTPUTS, "mono", 0.75);; diff --git a/src/mame/skeleton/banpresto_tomy_h8s.cpp b/src/mame/skeleton/banpresto_tomy_h8s.cpp index 9be16bb0592..09d4ac67c69 100644 --- a/src/mame/skeleton/banpresto_tomy_h8s.cpp +++ b/src/mame/skeleton/banpresto_tomy_h8s.cpp @@ -116,12 +116,11 @@ void banpresto_tomy_h8s_state::base(machine_config &config) PALETTE(config, "palette").set_entries(65536); // TODO - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", 4.096_MHz_XTAL)); // M9810B or M9811 - oki.add_route(0, "lspeaker", 0.80); - oki.add_route(1, "rspeaker", 0.80); + oki.add_route(0, "speaker", 0.80, 0); + oki.add_route(1, "speaker", 0.80, 1); } diff --git a/src/mame/skeleton/ct909e_segadvd.cpp b/src/mame/skeleton/ct909e_segadvd.cpp index c90c50476a7..67c8452cc32 100644 --- a/src/mame/skeleton/ct909e_segadvd.cpp +++ b/src/mame/skeleton/ct909e_segadvd.cpp @@ -104,8 +104,7 @@ void ct909e_megatrix_state::megatrix(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(ct909e_megatrix_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START( megatrix ) diff --git a/src/mame/skeleton/easy_karaoke.cpp b/src/mame/skeleton/easy_karaoke.cpp index a69b987f4e1..3f2a60ad2a3 100644 --- a/src/mame/skeleton/easy_karaoke.cpp +++ b/src/mame/skeleton/easy_karaoke.cpp @@ -212,8 +212,7 @@ void ivl_karaoke_state::ivl_karaoke_base(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(ivl_karaoke_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void easy_karaoke_cartslot_state::easy_karaoke(machine_config &config) diff --git a/src/mame/skeleton/epoch_tv_globe.cpp b/src/mame/skeleton/epoch_tv_globe.cpp index e8dde4bf09d..569761c456b 100644 --- a/src/mame/skeleton/epoch_tv_globe.cpp +++ b/src/mame/skeleton/epoch_tv_globe.cpp @@ -89,8 +89,7 @@ void epoch_tv_globe_state::epoch_tv_globe(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(epoch_tv_globe_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START( eptvglob ) diff --git a/src/mame/skeleton/koto_zevio.cpp b/src/mame/skeleton/koto_zevio.cpp index 2fdeecae0a1..44d6213e984 100644 --- a/src/mame/skeleton/koto_zevio.cpp +++ b/src/mame/skeleton/koto_zevio.cpp @@ -92,8 +92,7 @@ void zevio_state::zevio(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(zevio_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/skeleton/leadsinger2.cpp b/src/mame/skeleton/leadsinger2.cpp index 9fb032b84f9..77fdc2bf420 100644 --- a/src/mame/skeleton/leadsinger2.cpp +++ b/src/mame/skeleton/leadsinger2.cpp @@ -109,8 +109,7 @@ void leadsng2_state::leadsng2(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(leadsng2_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START( leadsng2 ) diff --git a/src/mame/skeleton/mini2440.cpp b/src/mame/skeleton/mini2440.cpp index 923b58dfbb4..b01ec5b1073 100644 --- a/src/mame/skeleton/mini2440.cpp +++ b/src/mame/skeleton/mini2440.cpp @@ -241,10 +241,9 @@ void mini2440_state::mini2440(machine_config &config) screen.set_visarea(0, 239, 0, 319); screen.set_screen_update("s3c2440", FUNC(s3c2440_device::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - UDA1341TS(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // uda1341ts.u12 - UDA1341TS(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // uda1341ts.u12 + SPEAKER(config, "speaker", 2).front(); + UDA1341TS(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // uda1341ts.u12 + UDA1341TS(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // uda1341ts.u12 S3C2440(config, m_s3c2440, 12000000); m_s3c2440->set_palette_tag("palette"); diff --git a/src/mame/skeleton/picno.cpp b/src/mame/skeleton/picno.cpp index 1d559e87841..44387bcaf1c 100644 --- a/src/mame/skeleton/picno.cpp +++ b/src/mame/skeleton/picno.cpp @@ -70,10 +70,9 @@ void picno_state::picno(machine_config &config) HD6435328(config, m_maincpu, 20'000'000); // TODO: clock is a guess, divided by 2 in the cpu m_maincpu->set_addrmap(AS_PROGRAM, &picno_state::mem_map); - //SPEAKER(config, "lspeaker").front_left(); // no speaker in the unit, but there's a couple of sockets on the back - //SPEAKER(config, "rspeaker").front_right(); - //sound.add_route(0, "lspeaker", 1.0); - //sound.add_route(1, "rspeaker", 1.0); + //SPEAKER(config, "speaker", 2).front(); // no speaker in the unit, but there's a couple of sockets on the back + //sound.add_route(0, "speaker", 1.0, 0); + //sound.add_route(1, "speaker", 1.0, 1); GENERIC_CARTSLOT(config, "cartslot", generic_linear_slot, "picno_cart"); diff --git a/src/mame/snk/bbusters.cpp b/src/mame/snk/bbusters.cpp index 52020c6bd93..114fab322f6 100644 --- a/src/mame/snk/bbusters.cpp +++ b/src/mame/snk/bbusters.cpp @@ -517,18 +517,17 @@ void bbusters_state::bbusters(machine_config &config) BUFFERED_SPRITERAM16(config, m_spriteram[1]); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch[0]); GENERIC_LATCH_8(config, m_soundlatch[1]); ym2610_device &ymsnd(YM2610(config, "ymsnd", 8000000)); ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(0, "lspeaker", 1.0); - ymsnd.add_route(0, "rspeaker", 1.0); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 1.0, 0); + ymsnd.add_route(0, "speaker", 1.0, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } /******************************************************************************/ diff --git a/src/mame/snk/hng64_a.cpp b/src/mame/snk/hng64_a.cpp index d17d840cbc6..37ea9fa31d3 100644 --- a/src/mame/snk/hng64_a.cpp +++ b/src/mame/snk/hng64_a.cpp @@ -399,10 +399,9 @@ void hng64_state::hng64_audio(machine_config &config) m_audiocpu->tout_handler<1>().set(FUNC(hng64_state::tcu_tm1_cb)); m_audiocpu->tout_handler<2>().set(FUNC(hng64_state::tcu_tm2_cb)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); L7A1045(config, m_dsp, 32000000/2); // ?? - m_dsp->add_route(0, "lspeaker", 0.1); - m_dsp->add_route(1, "rspeaker", 0.1); + m_dsp->add_route(0, "speaker", 0.1, 0); + m_dsp->add_route(1, "speaker", 0.1, 1); } diff --git a/src/mame/snk/mechatt.cpp b/src/mame/snk/mechatt.cpp index 3c41ea4117c..fcf8c362fc5 100644 --- a/src/mame/snk/mechatt.cpp +++ b/src/mame/snk/mechatt.cpp @@ -516,18 +516,17 @@ void mechatt_state::mechatt(machine_config &config) m_sprites->set_spriteram_tag("spriteram"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch[0]); GENERIC_LATCH_8(config, m_soundlatch[1]); ym2608_device &ymsnd(YM2608(config, "ymsnd", 8000000)); ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(0, "lspeaker", 0.15); - ymsnd.add_route(0, "rspeaker", 0.15); - ymsnd.add_route(1, "lspeaker", 0.80); - ymsnd.add_route(2, "rspeaker", 0.80); + ymsnd.add_route(0, "speaker", 0.15, 0); + ymsnd.add_route(0, "speaker", 0.15, 1); + ymsnd.add_route(1, "speaker", 0.80, 0); + ymsnd.add_route(2, "speaker", 0.80, 1); } /******************************************************************************/ diff --git a/src/mame/snk/ngp.cpp b/src/mame/snk/ngp.cpp index 4573a5bceb9..2a02f528ff5 100644 --- a/src/mame/snk/ngp.cpp +++ b/src/mame/snk/ngp.cpp @@ -865,15 +865,14 @@ void ngp_state::ngp_common(machine_config &config) m_screen->set_raw(6.144_MHz_XTAL, 515, 0, 160 /*480*/, 199, 0, 152); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); T6W28(config, m_t6w28, 6.144_MHz_XTAL/2); - m_t6w28->add_route(0, "lspeaker", 0.50); - m_t6w28->add_route(1, "rspeaker", 0.50); + m_t6w28->add_route(0, "speaker", 0.50, 0); + m_t6w28->add_route(1, "speaker", 0.50, 1); - DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); // unknown DAC - DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); // unknown DAC + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC } diff --git a/src/mame/snk/snk6502_a.cpp b/src/mame/snk/snk6502_a.cpp index 70c6618f09c..e6c847f9776 100644 --- a/src/mame/snk/snk6502_a.cpp +++ b/src/mame/snk/snk6502_a.cpp @@ -512,14 +512,12 @@ void snk6502_sound_device::speech_w(uint8_t data, const uint16_t *table, int sta // sound_stream_update - handle a stream update //------------------------------------------------- -void snk6502_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void snk6502_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - for (int i = 0; i < NUM_CHANNELS; i++) validate_tone_channel(i); - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int32_t data = 0; @@ -541,7 +539,7 @@ void snk6502_sound_device::sound_stream_update(sound_stream &stream, std::vector } } - buffer.put_int(sampindex, data, 3768); + stream.put_int(0, sampindex, data, 3768); m_tone_clock += FRAC_ONE; if (m_tone_clock >= m_tone_clock_expire) diff --git a/src/mame/snk/snk6502_a.h b/src/mame/snk/snk6502_a.h index 02b4c76b5b1..cbdeb03bbea 100644 --- a/src/mame/snk/snk6502_a.h +++ b/src/mame/snk/snk6502_a.h @@ -40,7 +40,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: static constexpr unsigned NUM_CHANNELS = 3; diff --git a/src/mame/sony/psx.cpp b/src/mame/sony/psx.cpp index 4ffed3c4216..dce49952c21 100644 --- a/src/mame/sony/psx.cpp +++ b/src/mame/sony/psx.cpp @@ -518,11 +518,10 @@ void psx1_state::psx_base(machine_config &config) SCREEN(config, "screen", SCREEN_TYPE_RASTER); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); spu_device &spu(SPU(config, "spu", XTAL(67'737'600)/2, m_maincpu.target())); - spu.add_route(0, "lspeaker", 1.00); - spu.add_route(1, "rspeaker", 1.00); + spu.add_route(0, "speaker", 1.00, 0); + spu.add_route(1, "speaker", 1.00, 1); QUICKLOAD(config, "quickload", "cpe,exe,psf,psx").set_load_callback(FUNC(psx1_state::quickload_exe)); diff --git a/src/mame/sony/taito_zm.cpp b/src/mame/sony/taito_zm.cpp index 762a3e9658f..4df10aa5e47 100644 --- a/src/mame/sony/taito_zm.cpp +++ b/src/mame/sony/taito_zm.cpp @@ -42,7 +42,7 @@ DEFINE_DEVICE_TYPE(TAITO_ZOOM, taito_zoom_device, "taito_zoom", "Taito Zoom Soun taito_zoom_device::taito_zoom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, TAITO_ZOOM, tag, owner, clock), - device_mixer_interface(mconfig, *this, 2), + device_mixer_interface(mconfig, *this), m_soundcpu(*this, "mn10200"), m_tms57002(*this, "tms57002"), m_zsg2(*this, "zsg2"), @@ -198,8 +198,8 @@ void taito_zoom_device::device_add_mconfig(machine_config &config) m_tms57002->empty_callback().set_inputline(m_soundcpu, MN10200_IRQ1).invert(); m_tms57002->set_addrmap(AS_DATA, &taito_zoom_device::tms57002_map); - m_tms57002->add_route(2, *this, 1.0, AUTO_ALLOC_INPUT, 0); - m_tms57002->add_route(3, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_tms57002->add_route(2, *this, 1.0, 0); + m_tms57002->add_route(3, *this, 1.0, 1); ZSG2(config, m_zsg2, XTAL(25'000'000)); m_zsg2->add_route(0, *m_tms57002, 0.5, 0); // reverb effect diff --git a/src/mame/sony/taitogn.cpp b/src/mame/sony/taitogn.cpp index f022cf346a3..8adbacf1168 100644 --- a/src/mame/sony/taitogn.cpp +++ b/src/mame/sony/taitogn.cpp @@ -435,13 +435,13 @@ protected: ADDRESS_MAP_BANK(config, m_flashbank).set_map(&taitogn_state::flashbank_map).set_options(ENDIANNESS_LITTLE, 16, 32, 0x8000000); m_spu->reset_routes(); - m_spu->add_route(0, "lspeaker", 0.3); - m_spu->add_route(1, "rspeaker", 0.3); + m_spu->add_route(0, "speaker", 0.3); + m_spu->add_route(1, "speaker", 0.3); TAITO_ZOOM(config, m_zoom); m_zoom->set_use_flash(); - m_zoom->add_route(0, "lspeaker", 1.0); - m_zoom->add_route(1, "rspeaker", 1.0); + m_zoom->add_route(0, "speaker", 1.0); + m_zoom->add_route(1, "speaker", 1.0); m_zoom->subdevice<zsg2_device>("zsg2")->ext_read().set(FUNC(taitogn_state::zsg2_ext_r)); } diff --git a/src/mame/sony/zn.cpp b/src/mame/sony/zn.cpp index e41b67f0dba..66d335c9749 100644 --- a/src/mame/sony/zn.cpp +++ b/src/mame/sony/zn.cpp @@ -54,7 +54,7 @@ zn_state::zn_state(const machine_config &mconfig, device_type type, const char * m_spu(*this, "spu"), m_gpu(*this, "gpu"), m_screen(*this, "screen"), - m_speaker(*this, { "lspeaker", "rspeaker" }), + m_speaker(*this, "speaker" ), m_at28c16(*this, "at28c16"), m_cat702(*this, "cat702_%u", 1), m_ram(*this, "maincpu:ram"), @@ -105,11 +105,10 @@ void zn_state::zn_base(machine_config &config) SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_spu->add_route(0, m_speaker[0], 0.35); - m_spu->add_route(1, m_speaker[1], 0.35); + m_spu->add_route(0, m_speaker, 0.35, 0); + m_spu->add_route(1, m_speaker, 0.35, 1); - SPEAKER(config, m_speaker[0]).front_left(); - SPEAKER(config, m_speaker[1]).front_right(); + SPEAKER(config, m_speaker).front(); AT28C16(config, m_at28c16, 0); @@ -579,8 +578,8 @@ protected: m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); QSOUND(config, m_qsound); - m_qsound->add_route(0, m_speaker[0], 1.0); - m_qsound->add_route(1, m_speaker[1], 1.0); + m_qsound->add_route(0, m_speaker, 1.0, 0); + m_qsound->add_route(1, m_speaker, 1.0, 1); } virtual void driver_start() override ATTR_COLD @@ -966,10 +965,10 @@ public: YM2610B(config, m_ym2610b, 16_MHz_XTAL / 2); m_ym2610b->irq_handler().set_inputline(m_audiocpu, 0); - m_ym2610b->add_route(0, m_speaker[0], 0.25); - m_ym2610b->add_route(0, m_speaker[1], 0.25); - m_ym2610b->add_route(1, m_speaker[0], 1.0); - m_ym2610b->add_route(2, m_speaker[1], 1.0); + m_ym2610b->add_route(0, m_speaker, 0.25, 0); + m_ym2610b->add_route(0, m_speaker, 0.25, 1); + m_ym2610b->add_route(1, m_speaker, 1.0, 0); + m_ym2610b->add_route(2, m_speaker, 1.0, 1); MB3773(config, m_mb3773); @@ -1060,12 +1059,12 @@ protected: MB3773(config, m_mb3773); m_spu->reset_routes(); - m_spu->add_route(0, m_speaker[0], 0.3); - m_spu->add_route(1, m_speaker[1], 0.3); + m_spu->add_route(0, m_speaker, 0.3, 0); + m_spu->add_route(1, m_speaker, 0.3, 1); TAITO_ZOOM(config, m_zoom); - m_zoom->add_route(0, m_speaker[0], 1.0); - m_zoom->add_route(1, m_speaker[1], 1.0); + m_zoom->add_route(0, m_speaker, 1.0, 0); + m_zoom->add_route(1, m_speaker, 1.0, 1); } virtual void driver_start() override ATTR_COLD @@ -1571,8 +1570,8 @@ public: GENERIC_LATCH_8(config, m_soundlatch); ymf271_device &ymf(YMF271(config, "ymf", XTAL(16'934'400))); - ymf.add_route(0, m_speaker[0], 1.0); - ymf.add_route(1, m_speaker[1], 1.0); + ymf.add_route(0, m_speaker, 1.0, 0); + ymf.add_route(1, m_speaker, 1.0, 1); } protected: @@ -1666,8 +1665,8 @@ public: GENERIC_LATCH_8(config, m_soundlatch); okim6295_device &oki(OKIM6295(config, "oki", 1000000, okim6295_device::PIN7_LOW)); // clock frequency & pin 7 not verified - oki.add_route(ALL_OUTPUTS, m_speaker[0], 1.0); - oki.add_route(ALL_OUTPUTS, m_speaker[1], 1.0); + oki.add_route(ALL_OUTPUTS, m_speaker, 1.0, 0); + oki.add_route(ALL_OUTPUTS, m_speaker, 1.0, 1); oki.set_addrmap(0, &beastrzrb_state::oki_map); } @@ -2242,8 +2241,8 @@ public: ADDRESS_MAP_BANK(config, m_bankmap).set_map(&nbajamex_state::bank_map).set_options(ENDIANNESS_LITTLE, 32, 24, 0x800000); ACCLAIM_RAX(config, m_rax, 0); - m_rax->add_route(0, m_speaker[0], 1.0); - m_rax->add_route(1, m_speaker[1], 1.0); + m_rax->add_route(0, m_speaker, 1.0, 0); + m_rax->add_route(1, m_speaker, 1.0, 1); } protected: @@ -2502,13 +2501,13 @@ public: m_soundlatch16->data_pending_callback().set_inputline(m_audiocpu, 3); m_spu->reset_routes(); - m_spu->add_route(0, m_speaker[0], 0.175); - m_spu->add_route(1, m_speaker[1], 0.175); + m_spu->add_route(0, m_speaker, 0.175, 0); + m_spu->add_route(1, m_speaker, 0.175, 1); YMZ280B(config, m_ymz280b, XTAL(16'934'400)); m_ymz280b->irq_handler().set_inputline(m_audiocpu, 2); - m_ymz280b->add_route(0, m_speaker[0], 0.35); - m_ymz280b->add_route(1, m_speaker[1], 0.35); + m_ymz280b->add_route(0, m_speaker, 0.35, 0); + m_ymz280b->add_route(1, m_speaker, 0.35, 1); } protected: @@ -2892,8 +2891,8 @@ public: config.set_maximum_quantum(attotime::from_hz(6000)); YMZ280B(config, m_ymz280b, XTAL(16'934'400)); - m_ymz280b->add_route(0, m_speaker[0], 0.35); - m_ymz280b->add_route(1, m_speaker[1], 0.35); + m_ymz280b->add_route(0, m_speaker, 0.35, 0); + m_ymz280b->add_route(1, m_speaker, 0.35, 1); } protected: diff --git a/src/mame/sony/zn.h b/src/mame/sony/zn.h index eb5704a18f6..c577011b853 100644 --- a/src/mame/sony/zn.h +++ b/src/mame/sony/zn.h @@ -52,7 +52,7 @@ protected: required_device<spu_device> m_spu; required_device<psxgpu_device> m_gpu; required_device<screen_device> m_screen; - required_device_array<speaker_device, 2> m_speaker; + required_device<speaker_device> m_speaker; required_device<at28c16_device> m_at28c16; optional_device_array<cat702_device, 2> m_cat702; required_device<ram_device> m_ram; diff --git a/src/mame/stern/cliffhgr.cpp b/src/mame/stern/cliffhgr.cpp index 8d4b55bf18a..452f960b7dc 100644 --- a/src/mame/stern/cliffhgr.cpp +++ b/src/mame/stern/cliffhgr.cpp @@ -703,8 +703,8 @@ void cliffhgr_state::cliffhgr(machine_config &config) PIONEER_PR8210(config, m_laserdisc, 0); m_laserdisc->set_overlay(tms9928a_device::TOTAL_HORZ, tms9928a_device::TOTAL_VERT_NTSC, "tms9928a", FUNC(tms9928a_device::screen_update)); m_laserdisc->set_overlay_clip(tms9928a_device::HORZ_DISPLAY_START-12, tms9928a_device::HORZ_DISPLAY_START+32*8+12-1, tms9928a_device::VERT_DISPLAY_START_NTSC - 12, tms9928a_device::VERT_DISPLAY_START_NTSC+24*8+12-1); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* start with the TMS9928a video configuration */ tms9128_device &vdp(TMS9128(config, "tms9928a", XTAL(10'738'635))); /* TMS9128NL on the board */ @@ -715,10 +715,9 @@ void cliffhgr_state::cliffhgr(machine_config &config) m_laserdisc->add_ntsc_screen(config, "screen"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DISCRETE(config, m_discrete, cliffhgr_discrete).add_route(ALL_OUTPUTS, "lspeaker", 1.0); + DISCRETE(config, m_discrete, cliffhgr_discrete).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); } diff --git a/src/mame/suna/suna16.cpp b/src/mame/suna/suna16.cpp index bae0c6936dc..0fdbd9b59b1 100644 --- a/src/mame/suna/suna16.cpp +++ b/src/mame/suna/suna16.cpp @@ -856,21 +856,20 @@ void suna16_state::bssoccer(machine_config &config) PALETTE(config, m_palette).set_entries(512); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); GENERIC_LATCH_8(config, "soundlatch2"); GENERIC_LATCH_8(config, "soundlatch3"); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181)/4)); /* 3.579545MHz */ - ymsnd.add_route(0, "lspeaker", 0.2); - ymsnd.add_route(1, "rspeaker", 0.2); + ymsnd.add_route(0, "speaker", 0.2, 0); + ymsnd.add_route(1, "speaker", 0.2, 1); - DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.2); // unknown DAC - DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.2); // unknown DAC - DAC_4BIT_R2R(config, "ldac2", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.2); // unknown DAC - DAC_4BIT_R2R(config, "rdac2", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.2); // unknown DAC + DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 0); // unknown DAC + DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 1); // unknown DAC + DAC_4BIT_R2R(config, "ldac2", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 0); // unknown DAC + DAC_4BIT_R2R(config, "rdac2", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 1); // unknown DAC } @@ -912,18 +911,17 @@ void suna16_state::uballoon(machine_config &config) PALETTE(config, m_palette).set_entries(512); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); GENERIC_LATCH_8(config, "soundlatch2"); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181)/4)); /* 3.579545MHz */ - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); - DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); // unknown DAC - DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); // unknown DAC + DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC } @@ -964,18 +962,17 @@ void suna16_state::sunaq(machine_config &config) PALETTE(config, m_palette).set_entries(512); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); GENERIC_LATCH_8(config, "soundlatch2"); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(14'318'181)/4)); /* 3.579545MHz */ - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); - DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.25); // unknown DAC - DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.25); // unknown DAC + DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 0); // unknown DAC + DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.25, 1); // unknown DAC } @@ -1021,26 +1018,25 @@ void suna16_state::bestbest(machine_config &config) PALETTE(config, m_palette).set_entries(256*8); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); GENERIC_LATCH_8(config, "soundlatch2"); ay8910_device &aysnd(AY8910(config, "aysnd", XTAL(24'000'000)/16)); /* 1.5MHz */ aysnd.port_a_write_callback().set(FUNC(suna16_state::bestbest_ay8910_port_a_w)); - aysnd.add_route(0, "lspeaker", 1.0); - aysnd.add_route(1, "rspeaker", 1.0); + aysnd.add_route(0, "speaker", 1.0, 0); + aysnd.add_route(1, "speaker", 1.0, 1); ym3526_device &ymsnd(YM3526(config, "ymsnd", XTAL(24'000'000)/8)); /* 3MHz */ ymsnd.irq_handler().set_inputline("audiocpu", INPUT_LINE_IRQ0); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); - DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.2); // unknown DAC - DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.2); // unknown DAC - DAC_4BIT_R2R(config, "ldac2", 0).add_route(ALL_OUTPUTS, "lspeaker", 0.2); // unknown DAC - DAC_4BIT_R2R(config, "rdac2", 0).add_route(ALL_OUTPUTS, "rspeaker", 0.2); // unknown DAC + DAC_4BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 0); // unknown DAC + DAC_4BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 1); // unknown DAC + DAC_4BIT_R2R(config, "ldac2", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 0); // unknown DAC + DAC_4BIT_R2R(config, "rdac2", 0).add_route(ALL_OUTPUTS, "speaker", 0.2, 1); // unknown DAC } /*************************************************************************** diff --git a/src/mame/svision/svis_snd.cpp b/src/mame/svision/svis_snd.cpp index 8a89e4e1880..587f4c28878 100644 --- a/src/mame/svision/svis_snd.cpp +++ b/src/mame/svision/svis_snd.cpp @@ -94,12 +94,9 @@ void svision_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void svision_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void svision_sound_device::sound_stream_update(sound_stream &stream) { - auto &left = outputs[0]; - auto &right = outputs[1]; - - for (int i = 0; i < left.samples(); i++) + for (int i = 0; i < stream.samples(); i++) { s32 lsum = 0; s32 rsum = 0; @@ -199,8 +196,8 @@ void svision_sound_device::sound_stream_update(sound_stream &stream, std::vector m_irq_cb(1); } } - left.put_int(i, lsum, 32768); - right.put_int(i, rsum, 32768); + stream.put_int(0, i, lsum, 32768); + stream.put_int(1, i, rsum, 32768); } } diff --git a/src/mame/svision/svis_snd.h b/src/mame/svision/svis_snd.h index 29634596b15..18bc67f4d55 100644 --- a/src/mame/svision/svis_snd.h +++ b/src/mame/svision/svis_snd.h @@ -41,7 +41,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct NOISE diff --git a/src/mame/svision/svision.cpp b/src/mame/svision/svision.cpp index 2f7c65dd373..16982425abb 100644 --- a/src/mame/svision/svision.cpp +++ b/src/mame/svision/svision.cpp @@ -693,12 +693,11 @@ void svision_state::svision_base(machine_config &config) { config.set_default_layout(layout_svision); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SVISION_SND(config, m_sound, 4'000'000, m_maincpu, m_bank[0]); - m_sound->add_route(0, "lspeaker", 0.50); - m_sound->add_route(1, "rspeaker", 0.50); + m_sound->add_route(0, "speaker", 0.50, 0); + m_sound->add_route(1, "speaker", 0.50, 1); m_sound->irq_cb().set(FUNC(svision_state::sound_irq_w)); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "svision_cart", "bin,ws,sv"); diff --git a/src/mame/taito/2mindril.cpp b/src/mame/taito/2mindril.cpp index 49e91152f61..1a25cb32905 100644 --- a/src/mame/taito/2mindril.cpp +++ b/src/mame/taito/2mindril.cpp @@ -374,15 +374,14 @@ void _2mindril_state::drill(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::RRRRGGGGBBBBRGBx, 0x2000); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610b_device &ymsnd(YM2610B(config, "ymsnd", 16000000/2)); ymsnd.irq_handler().set(FUNC(_2mindril_state::irqhandler)); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/taito/cpzodiac.cpp b/src/mame/taito/cpzodiac.cpp index 4fdcc0d2cfb..7a7129425e9 100644 --- a/src/mame/taito/cpzodiac.cpp +++ b/src/mame/taito/cpzodiac.cpp @@ -190,15 +190,14 @@ void cpzodiac_state::cpzodiac(machine_config &config) // TODO /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610b_device &ymsnd(YM2610B(config, "ymsnd", 16_MHz_XTAL/2)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); tc0140syt_device &syt(TC0140SYT(config, "syt", 0)); syt.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); diff --git a/src/mame/taito/darius.cpp b/src/mame/taito/darius.cpp index d24bdb426c2..97336d5aaf3 100644 --- a/src/mame/taito/darius.cpp +++ b/src/mame/taito/darius.cpp @@ -971,8 +971,7 @@ void darius_state::darius(machine_config &config) m_pc080sn->set_dblwidth(1); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2203_device &ym1(YM2203(config, "ym1", XTAL(8'000'000)/2)); /* 4 MHz */ ym1.irq_handler().set_inputline(m_audiocpu, 0); /* assumes Z80 sandwiched between 68Ks */ @@ -1009,13 +1008,13 @@ void darius_state::darius(machine_config &config) { for (int out = 0; out < 4; out++) { - FILTER_VOLUME(config, m_filter_l[chip][out]).add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, m_filter_r[chip][out]).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, m_filter_l[chip][out]).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, m_filter_r[chip][out]).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } } - FILTER_VOLUME(config, m_msm5205_l).add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, m_msm5205_r).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, m_msm5205_l).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, m_msm5205_r).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); pc060ha_device &ciu(PC060HA(config, "ciu", 0)); ciu.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); diff --git a/src/mame/taito/dinoking.cpp b/src/mame/taito/dinoking.cpp index 9879b779241..3e421a02abe 100644 --- a/src/mame/taito/dinoking.cpp +++ b/src/mame/taito/dinoking.cpp @@ -162,12 +162,11 @@ void dinoking_state::dinoking(machine_config &config) PALETTE(config, m_palette, palette_device::RGB_555); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", XTAL(4'096'000))); - oki.add_route(0, "lspeaker", 0.80); - oki.add_route(1, "rspeaker", 0.80); + oki.add_route(0, "speaker", 0.80, 0); + oki.add_route(1, "speaker", 0.80, 1); } diff --git a/src/mame/taito/galastrm.cpp b/src/mame/taito/galastrm.cpp index 7b0610b3a00..f61ee90982f 100644 --- a/src/mame/taito/galastrm.cpp +++ b/src/mame/taito/galastrm.cpp @@ -870,12 +870,11 @@ void galastrm_state::galastrm(machine_config &config) TC0110PCR(config, m_tc0110pcr, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/taito/groundfx.cpp b/src/mame/taito/groundfx.cpp index 8c54c18ef5a..64e8e6ed0b6 100644 --- a/src/mame/taito/groundfx.cpp +++ b/src/mame/taito/groundfx.cpp @@ -587,12 +587,11 @@ void groundfx_state::groundfx(machine_config &config) m_tc0480scp->set_offsets_tx(-1, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } /*************************************************************************** diff --git a/src/mame/taito/gunbustr.cpp b/src/mame/taito/gunbustr.cpp index caee7ba8bd9..b036db2273a 100644 --- a/src/mame/taito/gunbustr.cpp +++ b/src/mame/taito/gunbustr.cpp @@ -567,12 +567,11 @@ void gunbustr_state::gunbustr(machine_config &config) m_tc0480scp->set_offsets_flip(-1, 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } /***************************************************************************/ diff --git a/src/mame/taito/heromem.cpp b/src/mame/taito/heromem.cpp index 8e33486f2f7..a187fc84089 100644 --- a/src/mame/taito/heromem.cpp +++ b/src/mame/taito/heromem.cpp @@ -256,9 +256,7 @@ void heromem_state::heromem(machine_config &config) vdp_r.set_addrmap(AS_PROGRAM, &heromem_state::tc0091lvc_r_prg_map); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); tc0140syt_device &syt_l(TC0140SYT(config, "tc0140syt_l", 0)); syt_l.nmi_callback().set_inputline("audiocpu_l", INPUT_LINE_NMI); @@ -270,17 +268,17 @@ void heromem_state::heromem(machine_config &config) ym2610b_device &ym_l(YM2610B(config, "ym_l", 16000000 / 2)); ym_l.irq_handler().set_inputline("audiocpu_l", 0); - ym_l.add_route(0, "lspeaker", 0.25); - ym_l.add_route(0, "lspeaker", 0.25); - ym_l.add_route(1, "lspeaker", 1.0); - ym_l.add_route(2, "lspeaker", 1.0); + ym_l.add_route(0, "speaker", 0.25, 0); + ym_l.add_route(0, "speaker", 0.25, 0); + ym_l.add_route(1, "speaker", 1.0, 0); + ym_l.add_route(2, "speaker", 1.0, 0); ym2610b_device &ym_r(YM2610B(config, "ym_r", 16000000 / 2)); ym_r.irq_handler().set_inputline("audiocpu_r", 0); - ym_r.add_route(0, "rspeaker", 0.25); - ym_r.add_route(0, "rspeaker", 0.25); - ym_r.add_route(1, "rspeaker", 1.0); - ym_r.add_route(2, "rspeaker", 1.0); + ym_r.add_route(0, "speaker", 0.25, 1); + ym_r.add_route(0, "speaker", 0.25, 1); + ym_r.add_route(1, "speaker", 1.0, 1); + ym_r.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/taito/invqix.cpp b/src/mame/taito/invqix.cpp index e12989f5b07..48c57d581be 100644 --- a/src/mame/taito/invqix.cpp +++ b/src/mame/taito/invqix.cpp @@ -321,12 +321,11 @@ void invqix_state::invqix(machine_config &config) screen.set_size(640, 480); screen.set_visarea(0, 256-1, 0, 240-1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim9810_device &oki(OKIM9810(config, "oki", XTAL(4'096'000))); - oki.add_route(0, "lspeaker", 0.80); - oki.add_route(1, "rspeaker", 0.80); + oki.add_route(0, "speaker", 0.80, 0); + oki.add_route(1, "speaker", 0.80, 1); EEPROM_93C46_16BIT(config, "eeprom").default_value(0); } diff --git a/src/mame/taito/lgp.cpp b/src/mame/taito/lgp.cpp index e530b3f102c..f84430f8be0 100644 --- a/src/mame/taito/lgp.cpp +++ b/src/mame/taito/lgp.cpp @@ -418,8 +418,8 @@ void lgp_state::lgp(machine_config &config) PIONEER_LDV1000(config, m_laserdisc, 0); m_laserdisc->command_strobe_callback().set(FUNC(lgp_state::ld_command_strobe_cb)); m_laserdisc->set_overlay(256, 256, FUNC(lgp_state::screen_update_lgp)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_laserdisc->add_ntsc_screen(config, "screen"); @@ -429,8 +429,7 @@ void lgp_state::lgp(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_lgp); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/taito/ninjaw.cpp b/src/mame/taito/ninjaw.cpp index fbe7c62df0a..b158aaed5a5 100644 --- a/src/mame/taito/ninjaw.cpp +++ b/src/mame/taito/ninjaw.cpp @@ -419,7 +419,7 @@ protected: virtual void device_start(); // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; }; extern const device_type SUBWOOFER; @@ -454,9 +454,8 @@ void subwoofer_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void subwoofer_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void subwoofer_device::sound_stream_update(sound_stream &stream) { - outputs[0].fill(0); } #endif @@ -974,8 +973,7 @@ void ninjaw_state::ninjaw(machine_config &config) TC0110PCR(config, m_tc0110pcr[2], 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SPEAKER(config, "subwoofer").seat(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16000000/2)); @@ -986,10 +984,10 @@ void ninjaw_state::ninjaw(machine_config &config) ymsnd.add_route(2, "2610.2.l", 1.0); ymsnd.add_route(2, "2610.2.r", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // SUBWOOFER(config, "subwoofer", 0); @@ -1080,8 +1078,7 @@ void ninjaw_state::darius2(machine_config &config) TC0110PCR(config, m_tc0110pcr[2], 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SPEAKER(config, "subwoofer").seat(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16000000/2)); @@ -1092,10 +1089,10 @@ void ninjaw_state::darius2(machine_config &config) ymsnd.add_route(2, "2610.2.l", 1.0); ymsnd.add_route(2, "2610.2.r", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // SUBWOOFER(config, "subwoofer", 0); diff --git a/src/mame/taito/opwolf.cpp b/src/mame/taito/opwolf.cpp index 7164cbe330a..512892905b3 100644 --- a/src/mame/taito/opwolf.cpp +++ b/src/mame/taito/opwolf.cpp @@ -876,8 +876,7 @@ void opwolf_state::opwolf(machine_config &config) m_pc090oj->set_colpri_callback(FUNC(opwolf_state::colpri_cb)); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", 8_MHz_XTAL / 2)); /* 4 MHz */ ymsnd.irq_handler().set_inputline(m_audiocpu, 0); @@ -902,8 +901,8 @@ void opwolf_state::opwolf(machine_config &config) mixer.add_route(0, m_tc0060dca[1], 1.0, 1); TC0060DCA(config, m_tc0060dca[1]); - m_tc0060dca[1]->add_route(0, "lspeaker", 1.0); - m_tc0060dca[1]->add_route(1, "rspeaker", 1.0); + m_tc0060dca[1]->add_route(0, "speaker", 1.0, 0); + m_tc0060dca[1]->add_route(1, "speaker", 1.0, 1); } void opwolf_state::opwolfp(machine_config &config) diff --git a/src/mame/taito/qix_a.cpp b/src/mame/taito/qix_a.cpp index a45643ec408..260ca6b849b 100644 --- a/src/mame/taito/qix_a.cpp +++ b/src/mame/taito/qix_a.cpp @@ -176,12 +176,11 @@ void qix_state::qix_audio(machine_config &config) m_sndpia[2]->ca2_handler().set(FUNC(qix_state::sndpia_2_warning_w)); m_sndpia[2]->cb2_handler().set(FUNC(qix_state::sndpia_2_warning_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DISCRETE(config, m_discrete, qix_discrete); - m_discrete->add_route(0, "lspeaker", 1.0); - m_discrete->add_route(1, "rspeaker", 1.0); + m_discrete->add_route(0, "speaker", 1.0, 0); + m_discrete->add_route(1, "speaker", 1.0, 1); } void slither_state::audio(machine_config &config) diff --git a/src/mame/taito/rollrace.cpp b/src/mame/taito/rollrace.cpp index fe99ce69d6d..8f341c32258 100644 --- a/src/mame/taito/rollrace.cpp +++ b/src/mame/taito/rollrace.cpp @@ -573,14 +573,13 @@ void rollrace_state::rollace(machine_config &config) PALETTE(config, m_palette, FUNC(rollrace_state::palette), 256); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch"); - AY8910(config, "ay1", XTAL(24'000'000) / 16).add_route(ALL_OUTPUTS, "rspeaker", 0.10); // verified on PCB - AY8910(config, "ay2", XTAL(24'000'000) / 16).add_route(ALL_OUTPUTS, "rspeaker", 0.10); // verified on PCB - AY8910(config, "ay3", XTAL(24'000'000) / 16).add_route(ALL_OUTPUTS, "lspeaker", 0.10); // verified on PCB + AY8910(config, "ay1", XTAL(24'000'000) / 16).add_route(ALL_OUTPUTS, "speaker", 0.10, 1); // verified on PCB + AY8910(config, "ay2", XTAL(24'000'000) / 16).add_route(ALL_OUTPUTS, "speaker", 0.10, 1); // verified on PCB + AY8910(config, "ay3", XTAL(24'000'000) / 16).add_route(ALL_OUTPUTS, "speaker", 0.10, 0); // verified on PCB } void rollrace_state::rollace2(machine_config &config) diff --git a/src/mame/taito/slapshot.cpp b/src/mame/taito/slapshot.cpp index 8de396dde70..5e6f5e6c565 100644 --- a/src/mame/taito/slapshot.cpp +++ b/src/mame/taito/slapshot.cpp @@ -437,15 +437,14 @@ void slapshot_state::slapshot(machine_config &config) TC0360PRI(config, m_tc0360pri, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610b_device &ymsnd(YM2610B(config, "ymsnd", 32_MHz_XTAL/4)); /* 8 MHz */ ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); MK48T08(config, "mk48t08", 0); @@ -503,15 +502,14 @@ void slapshot_state::opwolf3(machine_config &config) TC0360PRI(config, m_tc0360pri, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610b_device &ymsnd(YM2610B(config, "ymsnd", 32_MHz_XTAL/4)); /* 8 MHz */ ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); MK48T08(config, "mk48t08", 0); diff --git a/src/mame/taito/superchs.cpp b/src/mame/taito/superchs.cpp index 09652827800..e930eccd750 100644 --- a/src/mame/taito/superchs.cpp +++ b/src/mame/taito/superchs.cpp @@ -249,12 +249,11 @@ void superchs_state::superchs(machine_config &config) m_tc0480scp->set_offsets_tx(-1, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } void superchs_state::chase3(machine_config &config) diff --git a/src/mame/taito/taito_en.cpp b/src/mame/taito/taito_en.cpp index 50e534d421a..35651d5b343 100644 --- a/src/mame/taito/taito_en.cpp +++ b/src/mame/taito/taito_en.cpp @@ -23,7 +23,7 @@ DEFINE_DEVICE_TYPE(TAITO_EN, taito_en_device, "taito_en", "Taito Ensoniq Sound S taito_en_device::taito_en_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, TAITO_EN, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 2) + , device_mixer_interface(mconfig, *this) , m_audiocpu(*this, "audiocpu") , m_ensoniq(*this, "ensoniq") , m_esp(*this, "esp") @@ -241,8 +241,8 @@ void taito_en_device::device_add_mconfig(machine_config &config) /* sound hardware */ ESQ_5505_5510_PUMP(config, m_pump, XTAL(30'476'180) / (2 * 16 * 32)); m_pump->set_esp(m_esp); - m_pump->add_route(0, *this, 0.5, AUTO_ALLOC_INPUT, 0); - m_pump->add_route(1, *this, 0.5, AUTO_ALLOC_INPUT, 1); + m_pump->add_route(0, *this, 0.5, 0); + m_pump->add_route(1, *this, 0.5, 1); ES5505(config, m_ensoniq, XTAL(30'476'180) / 2); m_ensoniq->sample_rate_changed().set(FUNC(taito_en_device::es5505_clock_changed)); diff --git a/src/mame/taito/taito_f2.cpp b/src/mame/taito/taito_f2.cpp index 18535603f9a..1bf60ae7876 100644 --- a/src/mame/taito/taito_f2.cpp +++ b/src/mame/taito/taito_f2.cpp @@ -2826,15 +2826,14 @@ void taitof2_state::taito_f2(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::RGBx_444, 4096); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 24000000/3)); /* Was 16000000/2, but only a 24Mhz OSC */ ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); tc0140syt_device &tc0140syt(TC0140SYT(config, "tc0140syt", 0)); tc0140syt.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); diff --git a/src/mame/taito/taito_f3.cpp b/src/mame/taito/taito_f3.cpp index 826947467b4..fe6c7e39cb6 100644 --- a/src/mame/taito/taito_f3.cpp +++ b/src/mame/taito/taito_f3.cpp @@ -460,12 +460,11 @@ void taito_f3_state::f3(machine_config &config) PALETTE(config, m_palette).set_entries(0x2000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); TAITO_EN(config, m_taito_en, 0); - m_taito_en->add_route(0, "lspeaker", 1.0); - m_taito_en->add_route(1, "rspeaker", 1.0); + m_taito_en->add_route(0, "speaker", 1.0, 0); + m_taito_en->add_route(1, "speaker", 1.0, 1); } /* These games reprogram the video output registers to display different scanlines, diff --git a/src/mame/taito/taito_x.cpp b/src/mame/taito/taito_x.cpp index 99b90a04b05..b26c86edd9c 100644 --- a/src/mame/taito/taito_x.cpp +++ b/src/mame/taito/taito_x.cpp @@ -1049,15 +1049,14 @@ void taitox_cchip_state::superman(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 2048); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16_MHz_XTAL / 2)); // verified on PCB ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); tc0140syt_device &tc0140syt(TC0140SYT(config, "tc0140syt", 0)); tc0140syt.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -1093,13 +1092,12 @@ void taitox_state::daisenpu(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 2048); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", 16_MHz_XTAL / 4)); // verified on PCB ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.45); - ymsnd.add_route(1, "rspeaker", 0.45); + ymsnd.add_route(0, "speaker", 0.45, 0); + ymsnd.add_route(1, "speaker", 0.45, 1); pc060ha_device &ciu(PC060HA(config, "ciu", 0)); ciu.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -1134,15 +1132,14 @@ void taitox_state::gigandes(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 2048); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 8000000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); tc0140syt_device &tc0140syt(TC0140SYT(config, "tc0140syt", 0)); tc0140syt.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -1178,15 +1175,14 @@ void taitox_state::ballbros(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 2048); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 8000000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); tc0140syt_device &tc0140syt(TC0140SYT(config, "tc0140syt", 0)); tc0140syt.nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); diff --git a/src/mame/taito/taito_z.cpp b/src/mame/taito/taito_z.cpp index 90a8f529a9f..429b76e62e5 100644 --- a/src/mame/taito/taito_z.cpp +++ b/src/mame/taito/taito_z.cpp @@ -3221,7 +3221,7 @@ void contcirc_state::contcirc(machine_config &config) //OSC: 26.686, 24.000, 16. /* sound hardware */ SPEAKER(config, "front").front_center(); SPEAKER(config, "rear").rear_center(); - SPEAKER(config, "subwoofer").set_position(0.0, 0.0, 0.0); // FIXME: where is this speaker located? + SPEAKER(config, "subwoofer").set_position(0, 0.0, 0.0, 0.0); // FIXME: where is this speaker located? ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(16'000'000)/2)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); @@ -3280,7 +3280,7 @@ void chasehq_state::chasehq(machine_config &config) //OSC: 26.686, 24.000, 16.00 /* sound hardware */ SPEAKER(config, "front").front_center(); SPEAKER(config, "rear").rear_center(); - SPEAKER(config, "subwoofer").set_position(0.0, 0.0, 0.0); // FIXME: where is this speaker located? + SPEAKER(config, "subwoofer").set_position(0, 0.0, 0.0, 0.0); // FIXME: where is this speaker located? ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(16'000'000)/2)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); @@ -3340,22 +3340,21 @@ void contcirc_state::enforce(machine_config &config) TC0110PCR(config, m_tc0110pcr, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(16'000'000)/2)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 20.0); ymsnd.add_route(1, "2610.1.r", 20.0); ymsnd.add_route(2, "2610.2.l", 20.0); ymsnd.add_route(2, "2610.2.r", 20.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -3396,22 +3395,21 @@ void taitoz_state::bshark_base(machine_config &config) TC0150ROD(config, m_tc0150rod, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16000000/2)); //ymsnd.irq_handler().set_inputline(m_audiocpu, 0); // DG: this is probably specific to Z80 and wrong? - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 28.0); ymsnd.add_route(1, "2610.1.r", 28.0); ymsnd.add_route(2, "2610.2.l", 28.0); ymsnd.add_route(2, "2610.2.r", 28.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); } void taitoz_state::bshark(machine_config &config) @@ -3471,22 +3469,21 @@ void sci_state::sci(machine_config &config) TC0150ROD(config, m_tc0150rod, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(32'000'000)/4)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 2.0); ymsnd.add_route(1, "2610.1.r", 2.0); ymsnd.add_route(2, "2610.2.l", 2.0); ymsnd.add_route(2, "2610.2.r", 2.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -3542,7 +3539,7 @@ void nightstr_state::nightstr(machine_config &config) //OSC: 26.686, 24.000, 16. /* sound hardware */ SPEAKER(config, "front").front_center(); SPEAKER(config, "rear").rear_center(); - SPEAKER(config, "subwoofer").set_position(0.0, 0.0, 0.0); // FIXME: where is this located in the cabinet? + SPEAKER(config, "subwoofer").set_position(0, 0.0, 0.0, 0.0); // FIXME: where is this located in the cabinet? ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(16'000'000)/2)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); @@ -3601,22 +3598,21 @@ void taitoz_z80_sound_state::aquajack(machine_config &config) //OSC: 26.686, 24. TC0110PCR(config, m_tc0110pcr, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(16'000'000)/2)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 2.0); ymsnd.add_route(1, "2610.1.r", 2.0); ymsnd.add_route(2, "2610.2.l", 2.0); ymsnd.add_route(2, "2610.2.r", 2.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -3668,22 +3664,21 @@ void spacegun_state::spacegun(machine_config &config) //OSC: 26.686, 24.000, 16. TC0110PCR(config, m_tc0110pcr, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(16'000'000)/2)); // 8 MHz //ymsnd.irq_handler().set_inputline(m_audiocpu, 0); // DG: this is probably specific to Z80 and wrong? - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 8.0); ymsnd.add_route(1, "2610.1.r", 8.0); ymsnd.add_route(2, "2610.2.l", 8.0); ymsnd.add_route(2, "2610.2.r", 8.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); } void taitoz_z80_sound_state::dblaxle(machine_config &config) @@ -3726,22 +3721,21 @@ void taitoz_z80_sound_state::dblaxle(machine_config &config) TC0150ROD(config, m_tc0150rod, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(32'000'000)/4)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 8.0); ymsnd.add_route(1, "2610.1.r", 8.0); ymsnd.add_route(2, "2610.2.l", 8.0); ymsnd.add_route(2, "2610.2.r", 8.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -3787,22 +3781,21 @@ void sci_state::racingb(machine_config &config) TC0150ROD(config, m_tc0150rod, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(32'000'000)/4)); // 8 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 8.0); ymsnd.add_route(1, "2610.1.r", 8.0); ymsnd.add_route(2, "2610.2.l", 8.0); ymsnd.add_route(2, "2610.2.r", 8.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); diff --git a/src/mame/taito/taitojc.cpp b/src/mame/taito/taitojc.cpp index 6562c6ee10e..dad6ca5f292 100644 --- a/src/mame/taito/taitojc.cpp +++ b/src/mame/taito/taitojc.cpp @@ -1137,12 +1137,11 @@ void taitojc_state::taitojc(machine_config &config) TC0780FPA(config, m_tc0780fpa, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } void dendego_state::dendego(machine_config &config) diff --git a/src/mame/taito/tc0060dca.cpp b/src/mame/taito/tc0060dca.cpp index c5496ac0903..b740e50d3d8 100755 --- a/src/mame/taito/tc0060dca.cpp +++ b/src/mame/taito/tc0060dca.cpp @@ -44,13 +44,11 @@ void tc0060dca_device::device_start() save_item(NAME(m_gain)); } -void tc0060dca_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tc0060dca_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { - const stream_buffer::sample_t l = inputs[0].get(i); - const stream_buffer::sample_t r = inputs[1].get(i); - outputs[0].put(i, l * m_gain[0]); - outputs[1].put(i, r * m_gain[1]); + stream.put(0, i, stream.get(0, i) * m_gain[0]); + stream.put(1, i, stream.get(1, i) * m_gain[1]); } } diff --git a/src/mame/taito/tc0060dca.h b/src/mame/taito/tc0060dca.h index d2c00fa9732..c9dc68a13d1 100755 --- a/src/mame/taito/tc0060dca.h +++ b/src/mame/taito/tc0060dca.h @@ -18,7 +18,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface override - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream; diff --git a/src/mame/taito/topspeed.cpp b/src/mame/taito/topspeed.cpp index 7e7ccfcf3c8..9f2fb25d657 100644 --- a/src/mame/taito/topspeed.cpp +++ b/src/mame/taito/topspeed.cpp @@ -993,8 +993,7 @@ void topspeed_state::topspeed(machine_config &config) PALETTE(config, "palette").set_format(palette_device::xBGR_555, 8192); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2151_device &ymsnd(YM2151(config, "ymsnd", 16_MHz_XTAL / 4)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); @@ -1011,12 +1010,12 @@ void topspeed_state::topspeed(machine_config &config) m_msm[1]->set_prescaler_selector(msm5205_device::SEX_4B); // Slave mode, 4-bit m_msm[1]->add_route(ALL_OUTPUTS, "filter3", 1.0); - FILTER_VOLUME(config, "filter1l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "filter1r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "filter1l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "filter1r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); - FILTER_VOLUME(config, "filter2").add_route(ALL_OUTPUTS, "lspeaker", 1.0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "filter2").add_route(ALL_OUTPUTS, "speaker", 1.0, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); - FILTER_VOLUME(config, "filter3").add_route(ALL_OUTPUTS, "lspeaker", 1.0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "filter3").add_route(ALL_OUTPUTS, "speaker", 1.0, 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/taito/undrfire.cpp b/src/mame/taito/undrfire.cpp index 397e0ffeabb..54b4764f205 100644 --- a/src/mame/taito/undrfire.cpp +++ b/src/mame/taito/undrfire.cpp @@ -551,12 +551,11 @@ void undrfire_state::undrfire(machine_config &config) m_tc0480scp->set_offsets_tx(-1, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } @@ -616,12 +615,11 @@ void undrfire_state::cbombers(machine_config &config) TC0360PRI(config, m_tc0360pri, 0); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); taito_en_device &taito_en(TAITO_EN(config, "taito_en", 0)); - taito_en.add_route(0, "lspeaker", 1.0); - taito_en.add_route(1, "rspeaker", 1.0); + taito_en.add_route(0, "speaker", 1.0, 0); + taito_en.add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/taito/warriorb.cpp b/src/mame/taito/warriorb.cpp index 2a0fd4d6c23..b9de57df76c 100644 --- a/src/mame/taito/warriorb.cpp +++ b/src/mame/taito/warriorb.cpp @@ -629,8 +629,7 @@ void warriorb_state::darius2d(machine_config &config) TC0110PCR(config, m_tc0110pcr[1], 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SPEAKER(config, "subwoofer").seat(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16_MHz_XTAL / 2)); @@ -641,10 +640,10 @@ void warriorb_state::darius2d(machine_config &config) ymsnd.add_route(2, "2610.2.l", 1.0); ymsnd.add_route(2, "2610.2.r", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline("audiocpu", INPUT_LINE_NMI); @@ -706,23 +705,22 @@ void warriorb_state::warriorb(machine_config &config) TC0110PCR(config, m_tc0110pcr[1], 0); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // is there a subwoofer under the seat like other Taito multiscreen games? ym2610b_device &ymsnd(YM2610B(config, "ymsnd", 16_MHz_XTAL / 2)); ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); ymsnd.add_route(1, "2610.1.l", 1.0); ymsnd.add_route(1, "2610.1.r", 1.0); ymsnd.add_route(2, "2610.2.l", 1.0); ymsnd.add_route(2, "2610.2.r", 1.0); - FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "2610.1.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.1.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "2610.2.l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "2610.2.r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline("audiocpu", INPUT_LINE_NMI); diff --git a/src/mame/taito/wgp.cpp b/src/mame/taito/wgp.cpp index 367b69d60f1..d3d8785b259 100644 --- a/src/mame/taito/wgp.cpp +++ b/src/mame/taito/wgp.cpp @@ -895,15 +895,14 @@ void wgp_state::wgp(machine_config &config) m_tc0100scn->set_palette(m_palette); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2610_device &ymsnd(YM2610(config, "ymsnd", 16000000/2)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); // assumes Z80 sandwiched between 68Ks - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); TC0140SYT(config, m_tc0140syt, 0); m_tc0140syt->nmi_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); diff --git a/src/mame/tatsumi/apache3.cpp b/src/mame/tatsumi/apache3.cpp index a601747a319..72538ad4c21 100644 --- a/src/mame/tatsumi/apache3.cpp +++ b/src/mame/tatsumi/apache3.cpp @@ -488,17 +488,16 @@ void apache3_state::apache3(machine_config &config) */ /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, apache3_state::CLOCK_1 / 4); m_ym2151->irq_handler().set_inputline(m_audiocpu, INPUT_LINE_IRQ0); - m_ym2151->add_route(0, "lspeaker", 0.45); - m_ym2151->add_route(1, "rspeaker", 0.45); + m_ym2151->add_route(0, "speaker", 0.45, 0); + m_ym2151->add_route(1, "speaker", 0.45, 1); OKIM6295(config, m_oki, apache3_state::CLOCK_1 / 4 / 2, okim6295_device::PIN7_HIGH); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.75); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.75); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } diff --git a/src/mame/tatsumi/cyclwarr.cpp b/src/mame/tatsumi/cyclwarr.cpp index fad8486349f..04ed7732c11 100644 --- a/src/mame/tatsumi/cyclwarr.cpp +++ b/src/mame/tatsumi/cyclwarr.cpp @@ -974,20 +974,19 @@ void cyclwarr_state::cyclwarr(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 8192); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); // m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); YM2151(config, m_ym2151, cyclwarr_state::CLOCK_1 / 4); m_ym2151->irq_handler().set_inputline(m_audiocpu, INPUT_LINE_IRQ0); - m_ym2151->add_route(0, "lspeaker", 0.45); - m_ym2151->add_route(1, "rspeaker", 0.45); + m_ym2151->add_route(0, "speaker", 0.45, 0); + m_ym2151->add_route(1, "speaker", 0.45, 1); OKIM6295(config, m_oki, cyclwarr_state::CLOCK_1 / 8, okim6295_device::PIN7_HIGH); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.75); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.75); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } void bigfight_state::bigfight(machine_config &config) diff --git a/src/mame/tatsumi/lockon.cpp b/src/mame/tatsumi/lockon.cpp index b9a78d3432d..27c6afc54cf 100644 --- a/src/mame/tatsumi/lockon.cpp +++ b/src/mame/tatsumi/lockon.cpp @@ -496,15 +496,14 @@ void lockon_state::lockon(machine_config &config) GFXDECODE(config, m_gfxdecode, m_palette, gfx_lockon); PALETTE(config, m_palette, FUNC(lockon_state::lockon_palette), 1024 + 2048); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2203_device &ymsnd(YM2203(config, "ymsnd", 16_MHz_XTAL / 4)); ymsnd.irq_handler().set(FUNC(lockon_state::ym2203_irq)); ymsnd.port_a_read_callback().set_ioport("YM2203"); ymsnd.port_b_write_callback().set(FUNC(lockon_state::ym2203_out_b)); - ymsnd.add_route(0, "lspeaker", 0.40); - ymsnd.add_route(0, "rspeaker", 0.40); + ymsnd.add_route(0, "speaker", 0.40, 0); + ymsnd.add_route(0, "speaker", 0.40, 1); ymsnd.add_route(1, "f2203.1l", 1.0); ymsnd.add_route(1, "f2203.1r", 1.0); ymsnd.add_route(2, "f2203.2l", 1.0); @@ -512,12 +511,12 @@ void lockon_state::lockon(machine_config &config) ymsnd.add_route(3, "f2203.3l", 1.0); ymsnd.add_route(3, "f2203.3r", 1.0); - FILTER_VOLUME(config, "f2203.1l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "f2203.1r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "f2203.2l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "f2203.2r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); - FILTER_VOLUME(config, "f2203.3l").add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_VOLUME(config, "f2203.3r").add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_VOLUME(config, "f2203.1l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "f2203.1r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "f2203.2l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "f2203.2r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); + FILTER_VOLUME(config, "f2203.3l").add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_VOLUME(config, "f2203.3r").add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/tatsumi/roundup5.cpp b/src/mame/tatsumi/roundup5.cpp index 2d0fae361be..017fa486148 100644 --- a/src/mame/tatsumi/roundup5.cpp +++ b/src/mame/tatsumi/roundup5.cpp @@ -719,17 +719,16 @@ void roundup5_state::roundup5(machine_config &config) m_palette->set_membits(8).set_endianness(ENDIANNESS_BIG); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2151(config, m_ym2151, roundup5_state::CLOCK_1 / 4); m_ym2151->irq_handler().set_inputline(m_audiocpu, INPUT_LINE_IRQ0); - m_ym2151->add_route(0, "lspeaker", 0.45); - m_ym2151->add_route(1, "rspeaker", 0.45); + m_ym2151->add_route(0, "speaker", 0.45, 0); + m_ym2151->add_route(1, "speaker", 0.45, 1); OKIM6295(config, m_oki, roundup5_state::CLOCK_1 / 4 / 2, okim6295_device::PIN7_HIGH); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.75); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.75); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.75, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.75, 1); } diff --git a/src/mame/tatsumi/tx1_a.cpp b/src/mame/tatsumi/tx1_a.cpp index 036e37bad79..aa442fba2fd 100644 --- a/src/mame/tatsumi/tx1_a.cpp +++ b/src/mame/tatsumi/tx1_a.cpp @@ -365,14 +365,11 @@ static inline void update_engine(int eng[4]) // sound_stream_update - handle a stream update //------------------------------------------------- -void tx1_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tx1_sound_device::sound_stream_update(sound_stream &stream) { uint32_t step_0, step_1, step_2; double /*gain_0, gain_1,*/ gain_2, gain_3; - auto &fl = outputs[0]; - auto &fr = outputs[1]; - /* 8253 outputs for the player/opponent engine sounds. */ step_0 = m_pit8253.counts[0].val ? (TX1_PIT_CLOCK / m_pit8253.counts[0].val * m_freq_to_step) : 0; step_1 = m_pit8253.counts[1].val ? (TX1_PIT_CLOCK / m_pit8253.counts[1].val * m_freq_to_step) : 0; @@ -383,7 +380,7 @@ void tx1_sound_device::sound_stream_update(sound_stream &stream, std::vector<rea gain_2 = tx1_engine_gains[m_ay_outputb & 0xf]; gain_3 = BIT(m_ay_outputb, 5) ? 1.0f : 1.5f; - for (int sampindex = 0; sampindex < fl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { if (m_step0 & ((1 << TX1_FRAC))) { @@ -406,8 +403,8 @@ void tx1_sound_device::sound_stream_update(sound_stream &stream, std::vector<rea m_step2 &= ((1 << TX1_FRAC) - 1); } - fl.put_int(sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768); - fr.put_int(sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768); + stream.put_int(0, sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768); + stream.put_int(1, sampindex, (m_pit0 + m_pit1)*gain_3 + 2*m_pit2*gain_2, 32768); m_step0 += step_0; m_step1 += step_1; @@ -761,7 +758,7 @@ void buggyboyjr_sound_device::ym2_b_w(uint8_t data) // sound_stream_update - handle a stream update //------------------------------------------------- -void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void buggyboy_sound_device::sound_stream_update(sound_stream &stream) { /* This is admittedly a bit of a hack job... */ @@ -769,9 +766,6 @@ void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vecto int n1_en, n2_en; double gain0, gain1_l, gain1_r; - auto &fl = outputs[0]; - auto &fr = outputs[1]; - /* 8253 outputs for the player/opponent buggy engine sounds. */ step_0 = m_pit8253.counts[0].val ? (BUGGYBOY_PIT_CLOCK / m_pit8253.counts[0].val * m_freq_to_step) : 0; step_1 = m_pit8253.counts[1].val ? (BUGGYBOY_PIT_CLOCK / m_pit8253.counts[1].val * m_freq_to_step) : 0; @@ -787,7 +781,7 @@ void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vecto gain1_l = bb_engine_gains[m_ym2_outputa >> 4] * 5; gain1_r = bb_engine_gains[m_ym2_outputa & 0xf] * 5; - for (int sampindex = 0; sampindex < fl.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { s32 pit0, pit1, n1, n2; pit0 = m_eng_voltages[(m_step0 >> 24) & 0xf]; @@ -829,8 +823,8 @@ void buggyboy_sound_device::sound_stream_update(sound_stream &stream, std::vecto else n2 = 8192; - fl.put_int(sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_l), 32768); - fr.put_int(sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_r), 32768); + stream.put_int(0, sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_l), 32768); + stream.put_int(1, sampindex, n1 + n2 + (pit0 * gain0) + (pit1 * gain1_r), 32768); m_step0 += step_0; m_step1 += step_1; diff --git a/src/mame/tatsumi/tx1_a.h b/src/mame/tatsumi/tx1_a.h index 3c630f090ee..6129392bd72 100644 --- a/src/mame/tatsumi/tx1_a.h +++ b/src/mame/tatsumi/tx1_a.h @@ -72,7 +72,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void tx1_sound_io(address_map &map) ATTR_COLD; void tx1_sound_prg(address_map &map) ATTR_COLD; @@ -149,7 +149,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; void ym1_a_w(uint8_t data); void ym2_a_w(uint8_t data); diff --git a/src/mame/tch/littlerb.cpp b/src/mame/tch/littlerb.cpp index 98bfae49e21..f1a74b205dc 100644 --- a/src/mame/tch/littlerb.cpp +++ b/src/mame/tch/littlerb.cpp @@ -310,11 +310,10 @@ void littlerb_state::littlerb(machine_config &config) TIMER(config, "step_timer").configure_periodic(FUNC(littlerb_state::sound_step_cb), attotime::from_hz(7500/150)); TIMER(config, "sound_timer").configure_periodic(FUNC(littlerb_state::sound_cb), attotime::from_hz(7500)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5); // unknown DAC - DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC_8BIT_R2R(config, m_ldac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); // unknown DAC + DAC_8BIT_R2R(config, m_rdac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } ROM_START( littlerb ) diff --git a/src/mame/tch/wheelfir.cpp b/src/mame/tch/wheelfir.cpp index 8ae5de6b7a7..20dfb0dc9e5 100644 --- a/src/mame/tch/wheelfir.cpp +++ b/src/mame/tch/wheelfir.cpp @@ -819,10 +819,9 @@ void wheelfir_state::wheelfir(machine_config &config) GENERIC_LATCH_16(config, "soundlatch"); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - DAC_10BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "lspeaker", 1.0); // unknown DAC - DAC_10BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "rspeaker", 1.0); // unknown DAC + SPEAKER(config, "speaker", 2).front(); + DAC_10BIT_R2R(config, "ldac", 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // unknown DAC + DAC_10BIT_R2R(config, "rdac", 0).add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // unknown DAC } diff --git a/src/mame/technos/blockout.cpp b/src/mame/technos/blockout.cpp index 0f6ac210064..0199eb8449a 100644 --- a/src/mame/technos/blockout.cpp +++ b/src/mame/technos/blockout.cpp @@ -456,20 +456,19 @@ void blockout_state::blockout(machine_config &config) PALETTE(config, m_palette).set_format(2, &blockout_state::xBGR_444, 513); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", AUDIO_CLOCK)); ymsnd.irq_handler().set(FUNC(blockout_state::irq_handler)); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); okim6295_device &oki(OKIM6295(config, "oki", 1'056'000, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.50); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.50); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } diff --git a/src/mame/technos/ddragon3.cpp b/src/mame/technos/ddragon3.cpp index 7734aee2f43..306e0ea7235 100644 --- a/src/mame/technos/ddragon3.cpp +++ b/src/mame/technos/ddragon3.cpp @@ -842,20 +842,19 @@ void ddragon3_state::ddragon3(machine_config &config) BUFFERED_SPRITERAM16(config, m_spriteram); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ym2151(YM2151(config, "ym2151", XTAL(3'579'545))); ym2151.irq_handler().set_inputline(m_audiocpu, 0); - ym2151.add_route(0, "lspeaker", 0.50); - ym2151.add_route(1, "rspeaker", 0.50); + ym2151.add_route(0, "speaker", 0.50, 0); + ym2151.add_route(1, "speaker", 0.50, 1); OKIM6295(config, m_oki, 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 1.50); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 1.50); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.50, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 1.50, 1); } void ddragon3_state::ddragon3b(machine_config &config) @@ -882,12 +881,12 @@ void ddragon3_state::ctribe(machine_config &config) ym2151_device &ym2151(*subdevice<ym2151_device>("ym2151")); ym2151.reset_routes(); - ym2151.add_route(0, "lspeaker", 1.20); - ym2151.add_route(1, "rspeaker", 1.20); + ym2151.add_route(0, "speaker", 1.20, 0); + ym2151.add_route(1, "speaker", 1.20, 1); m_oki->reset_routes(); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } diff --git a/src/mame/technos/shadfrce.cpp b/src/mame/technos/shadfrce.cpp index 76fcbcbf023..d166e7158b6 100644 --- a/src/mame/technos/shadfrce.cpp +++ b/src/mame/technos/shadfrce.cpp @@ -795,20 +795,19 @@ void shadfrce_state::shadfrce(machine_config &config) BUFFERED_SPRITERAM16(config, m_spvideoram); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", XTAL(3'579'545))); // verified on PCB ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.50); - ymsnd.add_route(1, "rspeaker", 0.50); + ymsnd.add_route(0, "speaker", 0.50, 0); + ymsnd.add_route(1, "speaker", 0.50, 1); OKIM6295(config, m_oki, XTAL(13'495'200) / 8, okim6295_device::PIN7_HIGH); // verified on PCB - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } // Rom Defs. diff --git a/src/mame/technos/spdodgeb.cpp b/src/mame/technos/spdodgeb.cpp index d66a8e2396a..8cdc7bfc48a 100644 --- a/src/mame/technos/spdodgeb.cpp +++ b/src/mame/technos/spdodgeb.cpp @@ -590,28 +590,27 @@ void spdodgeb_state::spdodgeb(machine_config &config) PALETTE(config, m_palette, FUNC(spdodgeb_state::palette), 1024); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, M6809_IRQ_LINE); ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(12'000'000) / 4)); ymsnd.irq_handler().set_inputline(m_audiocpu, M6809_FIRQ_LINE); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); MSM5205(config, m_msm[0], 384000); m_msm[0]->vck_legacy_callback().set(FUNC(spdodgeb_state::adpcm_int<0>)); // interrupt function m_msm[0]->set_prescaler_selector(msm5205_device::S48_4B); // 8kHz? - m_msm[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_msm[0]->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_msm[0]->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_msm[0]->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); MSM5205(config, m_msm[1], 384000); m_msm[1]->vck_legacy_callback().set(FUNC(spdodgeb_state::adpcm_int<1>)); // interrupt function m_msm[1]->set_prescaler_selector(msm5205_device::S48_4B); // 8kHz? - m_msm[1]->add_route(ALL_OUTPUTS, "lspeaker", 0.50); - m_msm[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.50); + m_msm[1]->add_route(ALL_OUTPUTS, "speaker", 0.50, 0); + m_msm[1]->add_route(ALL_OUTPUTS, "speaker", 0.50, 1); } diff --git a/src/mame/technos/vball.cpp b/src/mame/technos/vball.cpp index 21552ab0e47..b6c99f7cad0 100644 --- a/src/mame/technos/vball.cpp +++ b/src/mame/technos/vball.cpp @@ -639,20 +639,19 @@ void vball_state::vball(machine_config &config) PALETTE(config, m_palette).set_entries(256); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // The sound system comes all but verbatim from Double Dragon GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3.579545_MHz_XTAL)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); okim6295_device &oki(OKIM6295(config, "oki", 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); } diff --git a/src/mame/technos/wwfsstar.cpp b/src/mame/technos/wwfsstar.cpp index 31fb88cb6a8..9a483b79d61 100644 --- a/src/mame/technos/wwfsstar.cpp +++ b/src/mame/technos/wwfsstar.cpp @@ -637,20 +637,19 @@ void wwfsstar_state::wwfsstar(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_444, 384); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", 3.579545_MHz_XTAL)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.45); - ymsnd.add_route(1, "rspeaker", 0.45); + ymsnd.add_route(0, "speaker", 0.45, 0); + ymsnd.add_route(1, "speaker", 0.45, 1); okim6295_device &oki(OKIM6295(config, "oki", 1.056_MHz_XTAL, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.47); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.47); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.47, 1); } void wwfsstar_state::wwfsstarb2(machine_config &config) diff --git a/src/mame/tecmo/tecmo16.cpp b/src/mame/tecmo/tecmo16.cpp index 87595fcd819..b225b6e0677 100644 --- a/src/mame/tecmo/tecmo16.cpp +++ b/src/mame/tecmo/tecmo16.cpp @@ -698,19 +698,18 @@ void tecmo16_state::base(machine_config &config) m_mixer->set_bgpen(0x000 + 0x300, 0x400 + 0x300); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); ym2151_device &ymsnd(YM2151(config, "ymsnd", MASTER_CLOCK/6)); // 4 MHz ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); okim6295_device &oki(OKIM6295(config, "oki", OKI_CLOCK / 8, okim6295_device::PIN7_HIGH)); // sample rate 1 MHz / 132 - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.40); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.40); + oki.add_route(ALL_OUTPUTS, "speaker", 0.40, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.40, 1); } void tecmo16_state::ginkun(machine_config &config) diff --git a/src/mame/tecmo/tecmosys.cpp b/src/mame/tecmo/tecmosys.cpp index c9e03f2f2e3..5370cb9a5e5 100644 --- a/src/mame/tecmo/tecmosys.cpp +++ b/src/mame/tecmo/tecmosys.cpp @@ -469,8 +469,7 @@ void tecmosys_state::tecmosys(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xGRB_555, 0x4000+0x800); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set("soundnmi", FUNC(input_merger_device::in_w<0>)); @@ -480,19 +479,19 @@ void tecmosys_state::tecmosys(machine_config &config) ymf262_device &ymf(YMF262(config, "ymf", XTAL(14'318'181))); ymf.irq_handler().set_inputline("audiocpu", 0); - ymf.add_route(0, "lspeaker", 0.50); - ymf.add_route(1, "rspeaker", 0.50); - ymf.add_route(2, "lspeaker", 0.50); - ymf.add_route(3, "rspeaker", 0.50); + ymf.add_route(0, "speaker", 0.50, 0); + ymf.add_route(1, "speaker", 0.50, 1); + ymf.add_route(2, "speaker", 0.50, 0); + ymf.add_route(3, "speaker", 0.50, 1); okim6295_device &oki(OKIM6295(config, "oki", XTAL(16'000'000)/8, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.25); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.25); + oki.add_route(ALL_OUTPUTS, "speaker", 0.25, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.25, 1); oki.set_addrmap(0, &tecmosys_state::oki_map); ymz280b_device &ymz(YMZ280B(config, "ymz", XTAL(16'934'400))); - ymz.add_route(0, "lspeaker", 0.30); - ymz.add_route(1, "rspeaker", 0.30); + ymz.add_route(0, "speaker", 0.30, 0); + ymz.add_route(1, "speaker", 0.30, 1); } ROM_START( deroon ) diff --git a/src/mame/toaplan/dt7.cpp b/src/mame/toaplan/dt7.cpp index a78b1933f60..749b7db1e16 100644 --- a/src/mame/toaplan/dt7.cpp +++ b/src/mame/toaplan/dt7.cpp @@ -446,18 +446,17 @@ void dt7_state::dt7(machine_config &config) GFXDECODE(config, m_gfxdecode[1], m_palette[1], gfx_textrom_double_1); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 27_MHz_XTAL/8).add_route(ALL_OUTPUTS, "lspeaker", 0.5); + YM2151(config, "ymsnd", 27_MHz_XTAL/8).add_route(ALL_OUTPUTS, "speaker", 0.5, 0); OKIM6295(config, m_oki[0], 27_MHz_XTAL / 24, okim6295_device::PIN7_HIGH); - m_oki[0]->add_route(ALL_OUTPUTS, "lspeaker", 0.5); + m_oki[0]->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); - YM2151(config, "ymsnd2", 27_MHz_XTAL/8).add_route(ALL_OUTPUTS, "rspeaker", 0.5); + YM2151(config, "ymsnd2", 27_MHz_XTAL/8).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); OKIM6295(config, m_oki[1], 27_MHz_XTAL/24, okim6295_device::PIN7_HIGH); - m_oki[1]->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_oki[1]->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } diff --git a/src/mame/toaplan/truxton2.cpp b/src/mame/toaplan/truxton2.cpp index 01885e62dbc..af68dea56bd 100644 --- a/src/mame/toaplan/truxton2.cpp +++ b/src/mame/toaplan/truxton2.cpp @@ -339,14 +339,13 @@ void truxton2_state::truxton2(machine_config &config) /* sound hardware */ #ifdef TRUXTON2_STEREO // music data is stereo... - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", 27_MHz_XTAL/8).add_route(0, "lspeaker", 0.5).add_route(1, "rspeaker", 0.5); + YM2151(config, "ymsnd", 27_MHz_XTAL/8).add_route(0, "speaker", 0.5, 0).add_route(1, "speaker", 0.5, 1); OKIM6295(config, m_oki, 16_MHz_XTAL/4, okim6295_device::PIN7_LOW); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); #else // ...but the hardware is mono SPEAKER(config, "mono").front_center(); diff --git a/src/mame/trs/vis.cpp b/src/mame/trs/vis.cpp index 88deec374b5..ebf46d981f6 100644 --- a/src/mame/trs/vis.cpp +++ b/src/mame/trs/vis.cpp @@ -134,19 +134,18 @@ TIMER_CALLBACK_MEMBER(vis_audio_device::pcm_update) void vis_audio_device::device_add_mconfig(machine_config &config) { - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ymf262_device &ymf262(YMF262(config, "ymf262", XTAL(14'318'181))); - ymf262.add_route(0, "lspeaker", 1.00); - ymf262.add_route(1, "rspeaker", 1.00); - ymf262.add_route(2, "lspeaker", 1.00); - ymf262.add_route(3, "rspeaker", 1.00); + ymf262.add_route(0, "speaker", 1.00, 0); + ymf262.add_route(1, "speaker", 1.00, 1); + ymf262.add_route(2, "speaker", 1.00, 0); + ymf262.add_route(3, "speaker", 1.00, 1); DAC_16BIT_R2R(config, m_ldac, 0); DAC_16BIT_R2R(config, m_rdac, 0); - m_ldac->add_route(ALL_OUTPUTS, "lspeaker", 1.0); // sanyo lc7883k - m_rdac->add_route(ALL_OUTPUTS, "rspeaker", 1.0); // sanyo lc7883k + m_ldac->add_route(ALL_OUTPUTS, "speaker", 1.0, 0); // sanyo lc7883k + m_rdac->add_route(ALL_OUTPUTS, "speaker", 1.0, 1); // sanyo lc7883k } uint8_t vis_audio_device::pcm_r(offs_t offset) diff --git a/src/mame/tvgames/actions_atj2279b.cpp b/src/mame/tvgames/actions_atj2279b.cpp index 89d3e3d50f2..69325f2508b 100644 --- a/src/mame/tvgames/actions_atj2279b.cpp +++ b/src/mame/tvgames/actions_atj2279b.cpp @@ -89,8 +89,7 @@ void actions_atj2279b_state::actions_atj2279b(machine_config &config) screen.set_visarea(0, 1280-1, 0, 720-1); // resolution unconfirmed (possibly 1080p as well, but this is unlikely) screen.set_screen_update(FUNC(actions_atj2279b_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START( rbitgen ) diff --git a/src/mame/tvgames/elan_eu3a05_a.cpp b/src/mame/tvgames/elan_eu3a05_a.cpp index fcdaed8a003..13fa89e0334 100644 --- a/src/mame/tvgames/elan_eu3a05_a.cpp +++ b/src/mame/tvgames/elan_eu3a05_a.cpp @@ -92,16 +92,13 @@ void elan_eu3a05_sound_device::device_reset() // sound_stream_update - handle a stream update //------------------------------------------------- -void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - int volume = m_volumes[0] | (m_volumes[1] << 8); int outpos = 0; // loop while we still have samples to generate - int samples = outputs[0].samples(); + int samples = stream.samples(); while (samples-- != 0) { int total = 0; @@ -140,7 +137,7 @@ void elan_eu3a05_sound_device::sound_stream_update(sound_stream &stream, std::ve //LOGMASKED( LOG_AUDIO, "m_isstopped %02x channel %d is NOT active %08x %06x\n", m_isstopped, channel, m_sound_byte_address[channel], m_sound_current_nib_pos[channel]); } } - outputs[0].put_int(outpos, total, 32768 * 6); + stream.put_int(0, outpos, total, 32768 * 6); outpos++; } } diff --git a/src/mame/tvgames/elan_eu3a05_a.h b/src/mame/tvgames/elan_eu3a05_a.h index 13e8bfc86ec..5c9cf303379 100644 --- a/src/mame/tvgames/elan_eu3a05_a.h +++ b/src/mame/tvgames/elan_eu3a05_a.h @@ -30,7 +30,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; virtual space_config_vector memory_space_config() const override; const address_space_config m_space_config; diff --git a/src/mame/tvgames/generalplus_gpl16250.cpp b/src/mame/tvgames/generalplus_gpl16250.cpp index 0cecae9e5d3..b4059ea7b79 100644 --- a/src/mame/tvgames/generalplus_gpl16250.cpp +++ b/src/mame/tvgames/generalplus_gpl16250.cpp @@ -144,8 +144,8 @@ void gcm394_game_state::base(machine_config &config) m_maincpu->space_read_callback().set(FUNC(gcm394_game_state::read_external_space)); m_maincpu->space_write_callback().set(FUNC(gcm394_game_state::write_external_space)); m_maincpu->set_irq_acknowledge_callback(m_maincpu, FUNC(sunplus_gcm394_base_device::irq_vector_cb)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); m_maincpu->set_bootmode(1); // boot from external ROM / CS mirror m_maincpu->set_cs_config_callback(FUNC(gcm394_game_state::cs_callback)); @@ -158,8 +158,7 @@ void gcm394_game_state::base(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(sunplus_gcm394_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(sunplus_gcm394_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } diff --git a/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp b/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp index 5d77132e9e8..6d398a4827b 100644 --- a/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_mobigo.cpp @@ -109,8 +109,8 @@ void mobigo2_state::mobigo2(machine_config &config) m_maincpu->space_read_callback().set(FUNC(mobigo2_state::read_external_space)); m_maincpu->space_write_callback().set(FUNC(mobigo2_state::write_external_space)); m_maincpu->set_irq_acknowledge_callback(m_maincpu, FUNC(sunplus_gcm394_base_device::irq_vector_cb)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); m_maincpu->set_bootmode(0); // boot from internal ROM (NAND bootstrap) m_maincpu->set_cs_config_callback(FUNC(mobigo2_state::cs_callback)); @@ -125,8 +125,7 @@ void mobigo2_state::mobigo2(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(sunplus_gcm394_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(sunplus_gcm394_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "mobigo_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/tvgames/generalplus_gpl16250_nand.cpp b/src/mame/tvgames/generalplus_gpl16250_nand.cpp index e3c2dccae1d..311e471a532 100644 --- a/src/mame/tvgames/generalplus_gpl16250_nand.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_nand.cpp @@ -81,8 +81,8 @@ void generalplus_gpac800_game_state::generalplus_gpac800(machine_config &config) m_maincpu->space_read_callback().set(FUNC(generalplus_gpac800_game_state::read_external_space)); m_maincpu->space_write_callback().set(FUNC(generalplus_gpac800_game_state::write_external_space)); m_maincpu->set_irq_acknowledge_callback(m_maincpu, FUNC(sunplus_gcm394_base_device::irq_vector_cb)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); m_maincpu->set_bootmode(0); // boot from internal ROM (NAND bootstrap) m_maincpu->set_cs_config_callback(FUNC(gcm394_game_state::cs_callback)); @@ -97,8 +97,7 @@ void generalplus_gpac800_game_state::generalplus_gpac800(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(sunplus_gcm394_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(sunplus_gcm394_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } DEVICE_IMAGE_LOAD_MEMBER(generalplus_gpac800_vbaby_game_state::cart_load) diff --git a/src/mame/tvgames/generalplus_gpl16250_spi.cpp b/src/mame/tvgames/generalplus_gpl16250_spi.cpp index 8479625cbaf..81d0e81bdc0 100644 --- a/src/mame/tvgames/generalplus_gpl16250_spi.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_spi.cpp @@ -83,8 +83,8 @@ void generalplus_gpspispi_game_state::generalplus_gpspispi(machine_config &confi m_maincpu->space_read_callback().set(FUNC(generalplus_gpspispi_game_state::read_external_space)); m_maincpu->space_write_callback().set(FUNC(generalplus_gpspispi_game_state::write_external_space)); m_maincpu->set_irq_acknowledge_callback(m_maincpu, FUNC(sunplus_gcm394_base_device::irq_vector_cb)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); m_maincpu->set_bootmode(0); // boot from internal ROM (SPI bootstrap) m_maincpu->set_cs_config_callback(FUNC(gcm394_game_state::cs_callback)); @@ -97,8 +97,7 @@ void generalplus_gpspispi_game_state::generalplus_gpspispi(machine_config &confi m_screen->set_screen_update("maincpu", FUNC(sunplus_gcm394_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(sunplus_gcm394_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } DEVICE_IMAGE_LOAD_MEMBER(generalplus_gpspispi_bkrankp_game_state::cart_load) diff --git a/src/mame/tvgames/generalplus_gpl16250_spi_direct.cpp b/src/mame/tvgames/generalplus_gpl16250_spi_direct.cpp index 00b8c13b12d..b3eb8e7207d 100644 --- a/src/mame/tvgames/generalplus_gpl16250_spi_direct.cpp +++ b/src/mame/tvgames/generalplus_gpl16250_spi_direct.cpp @@ -119,8 +119,8 @@ void generalplus_gpspi_direct_game_state::generalplus_gpspi_direct(machine_confi m_maincpu->space_read_callback().set(FUNC(generalplus_gpspi_direct_game_state::read_external_space)); m_maincpu->space_write_callback().set(FUNC(generalplus_gpspi_direct_game_state::write_external_space)); m_maincpu->set_irq_acknowledge_callback(m_maincpu, FUNC(sunplus_gcm394_base_device::irq_vector_cb)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); m_maincpu->set_bootmode(0); m_maincpu->set_cs_config_callback(FUNC(gcm394_game_state::cs_callback)); @@ -134,8 +134,7 @@ void generalplus_gpspi_direct_game_state::generalplus_gpspi_direct(machine_confi m_screen->set_screen_update("maincpu", FUNC(sunplus_gcm394_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(sunplus_gcm394_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } // Is there an internal ROM that gets mapped out or can this type really execute directly from scrambled SPI? diff --git a/src/mame/tvgames/generalplus_gpl32612.cpp b/src/mame/tvgames/generalplus_gpl32612.cpp index 09a99e015ad..ce0c261ffe3 100644 --- a/src/mame/tvgames/generalplus_gpl32612.cpp +++ b/src/mame/tvgames/generalplus_gpl32612.cpp @@ -184,8 +184,7 @@ void generalplus_gpl32612_game_state::gpl32612(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(generalplus_gpl32612_game_state::screen_update_gpl32612)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void generalplus_zippity_game_state::machine_start() @@ -224,8 +223,7 @@ void generalplus_zippity_game_state::zippity(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(generalplus_zippity_game_state::screen_update_gpl32612)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "leapfrog_zippity_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/tvgames/gpm4530a_lexibook_jg7420.cpp b/src/mame/tvgames/gpm4530a_lexibook_jg7420.cpp index 6782cfcb1cf..9234e75625e 100644 --- a/src/mame/tvgames/gpm4530a_lexibook_jg7420.cpp +++ b/src/mame/tvgames/gpm4530a_lexibook_jg7420.cpp @@ -76,8 +76,7 @@ void gpm4530a_lexibook_state::gpm4530a_lexibook(machine_config &config) SPI_SDCARD(config, m_sdcard, 0); m_sdcard->set_prefer_sdhc(); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START( lx_jg7420 ) diff --git a/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp b/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp index fa4a9cf48f8..24354842dc0 100644 --- a/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp +++ b/src/mame/tvgames/magiceyes_pollux_vr3520f.cpp @@ -100,8 +100,7 @@ void magiceyes_vr3520f_game_state::leapfrog_didj(machine_config &config) screen.set_visarea(0, 640-1, 0, 480-1); screen.set_screen_update(FUNC(magiceyes_vr3520f_game_state::screen_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "leapfrog_didj_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/tvgames/spg110.cpp b/src/mame/tvgames/spg110.cpp index db1df9e3ecd..64f71934efc 100644 --- a/src/mame/tvgames/spg110.cpp +++ b/src/mame/tvgames/spg110.cpp @@ -527,10 +527,9 @@ void spg110_game_state::spg110_base(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(spg110_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(spg110_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + SPEAKER(config, "speaker", 2).front(); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } void spg110_game_state::spg110_base_pal(machine_config &config) diff --git a/src/mame/tvgames/spg2xx.cpp b/src/mame/tvgames/spg2xx.cpp index b587d6a54c5..ad8a60452b0 100644 --- a/src/mame/tvgames/spg2xx.cpp +++ b/src/mame/tvgames/spg2xx.cpp @@ -1476,10 +1476,9 @@ void spg2xx_game_state::spg2xx_base(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(spg2xx_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(spg2xx_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + SPEAKER(config, "speaker", 2).front(); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); } void spg2xx_game_state::non_spg_base(machine_config &config) diff --git a/src/mame/tvgames/xavix.cpp b/src/mame/tvgames/xavix.cpp index ca291e82eff..b12b8960625 100644 --- a/src/mame/tvgames/xavix.cpp +++ b/src/mame/tvgames/xavix.cpp @@ -1779,15 +1779,14 @@ void xavix_state::xavix(machine_config &config) /* sound hardware */ //SPEAKER(config, "mono").front_center(); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); XAVIX_SOUND(config, m_sound, MAIN_CLOCK); m_sound->read_regs_callback().set(FUNC(xavix_state::sound_regram_read_cb)); m_sound->read_samples_callback().set(FUNC(xavix_state::sample_read)); //m_sound->add_route(ALL_OUTPUTS, "mono", 1.0); - m_sound->add_route(0, "lspeaker", 1.0); - m_sound->add_route(1, "rspeaker", 1.0); + m_sound->add_route(0, "speaker", 1.0, 0); + m_sound->add_route(1, "speaker", 1.0, 1); } void xavix_state::xavix_4mb(machine_config &config) diff --git a/src/mame/tvgames/xavix.h b/src/mame/tvgames/xavix.h index 2a11c60d495..5102b0506e7 100644 --- a/src/mame/tvgames/xavix.h +++ b/src/mame/tvgames/xavix.h @@ -48,7 +48,7 @@ protected: virtual void device_reset() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_stream = nullptr; diff --git a/src/mame/tvgames/xavix2.cpp b/src/mame/tvgames/xavix2.cpp index da3571e58bd..c51ddebfe34 100644 --- a/src/mame/tvgames/xavix2.cpp +++ b/src/mame/tvgames/xavix2.cpp @@ -730,8 +730,7 @@ void xavix2_state::config(machine_config &config) m_screen->set_visarea(0, 639, 0, 399); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // unknown sound hardware } diff --git a/src/mame/tvgames/xavix_a.cpp b/src/mame/tvgames/xavix_a.cpp index ebddb577444..2baf87b1de6 100644 --- a/src/mame/tvgames/xavix_a.cpp +++ b/src/mame/tvgames/xavix_a.cpp @@ -40,15 +40,11 @@ void xavix_sound_device::device_reset() } -void xavix_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void xavix_sound_device::sound_stream_update(sound_stream &stream) { - // reset the output stream - outputs[0].fill(0); - outputs[1].fill(0); - int outpos = 0; // loop while we still have samples to generate - int samples = outputs[0].samples(); + int samples = stream.samples(); while (samples-- != 0) { for (int channel = 0; channel < 2; channel++) @@ -81,7 +77,7 @@ void xavix_sound_device::sound_stream_update(sound_stream &stream, std::vector<r */ } - outputs[channel].add_int(outpos, sample * (m_voice[v].vol + 1), 32768); + stream.add_int(channel, outpos, sample * (m_voice[v].vol + 1), 32768); m_voice[v].position[channel] += m_voice[v].rate; } else diff --git a/src/mame/unico/goori.cpp b/src/mame/unico/goori.cpp index 76888a82b30..1ca872b7a0d 100644 --- a/src/mame/unico/goori.cpp +++ b/src/mame/unico/goori.cpp @@ -290,14 +290,13 @@ void goori_state::goori(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x2000); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); OKIM6295(config, m_oki, 16_MHz_XTAL/16, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); - YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "lspeaker", 0.40).add_route(1, "rspeaker", 0.40); + YM2151(config, "ymsnd", 3.579545_MHz_XTAL).add_route(0, "speaker", 0.40, 0).add_route(1, "speaker", 0.40, 1); } ROM_START( goori ) diff --git a/src/mame/unico/silkroad.cpp b/src/mame/unico/silkroad.cpp index df60c211757..e52b65bd71b 100644 --- a/src/mame/unico/silkroad.cpp +++ b/src/mame/unico/silkroad.cpp @@ -459,19 +459,18 @@ void silkroad_state::silkroad(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 0x2000).set_membits(16); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "lspeaker", 1.0).add_route(1, "rspeaker", 1.0); + YM2151(config, "ymsnd", XTAL(3'579'545)).add_route(0, "speaker", 1.0, 0).add_route(1, "speaker", 1.0, 1); okim6295_device &oki1(OKIM6295(config, "oki1", XTAL(32'000'000) / 32, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified (was 1056000) oki1.set_addrmap(0, &silkroad_state::oki_map); - oki1.add_route(ALL_OUTPUTS, "lspeaker", 0.45); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 0.45); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.45, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.45, 1); okim6295_device &oki2(OKIM6295(config, "oki2", XTAL(32'000'000) / 16, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified (was 2112000) - oki2.add_route(ALL_OUTPUTS, "lspeaker", 0.45); - oki2.add_route(ALL_OUTPUTS, "rspeaker", 0.45); + oki2.add_route(ALL_OUTPUTS, "speaker", 0.45, 0); + oki2.add_route(ALL_OUTPUTS, "speaker", 0.45, 1); } diff --git a/src/mame/unico/unico.cpp b/src/mame/unico/unico.cpp index 6da4cc62eae..10d29fbe590 100644 --- a/src/mame/unico/unico.cpp +++ b/src/mame/unico/unico.cpp @@ -933,16 +933,15 @@ void burglarx_state::burglarx(machine_config &config) PALETTE(config, m_palette).set_format(4, &burglarx_state::unico_R6G6B6X, 8192); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(14'318'181) / 4)); // 3.579545 MHz - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.40); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.40); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.40, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.40, 1); OKIM6295(config, m_oki, 32_MHz_XTAL / 32, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 not verified - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } @@ -977,17 +976,16 @@ void zeropnt_state::zeropnt(machine_config &config) PALETTE(config, m_palette).set_format(4, &zeropnt_state::unico_R6G6B6X, 8192); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(14'318'181) / 4)); // 3.579545 MHz - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.40); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.40); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.40, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.40, 1); OKIM6295(config, m_oki, 32_MHz_XTAL / 32, okim6295_device::PIN7_HIGH); // clock frequency & pin 7 verified m_oki->set_addrmap(0, &zeropnt_state::oki_map); - m_oki->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_oki->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_oki->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } @@ -1024,19 +1022,18 @@ void zeropnt2_state::zeropnt2(machine_config &config) PALETTE(config, m_palette).set_format(4, &zeropnt2_state::unico_R6G6B6X, 8192); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - YM2151(config, "ymsnd", XTAL(14'318'181) / 4).add_route(0, "lspeaker", 0.70).add_route(1, "rspeaker", 0.70); // 3.579545 MHz + YM2151(config, "ymsnd", XTAL(14'318'181) / 4).add_route(0, "speaker", 0.70, 0).add_route(1, "speaker", 0.70, 1); // 3.579545 MHz okim6295_device &oki1(OKIM6295(config, "oki1", 32_MHz_XTAL/32, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified oki1.set_addrmap(0, &zeropnt2_state::oki_map); - oki1.add_route(ALL_OUTPUTS, "lspeaker", 0.40); - oki1.add_route(ALL_OUTPUTS, "rspeaker", 0.40); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.40, 0); + oki1.add_route(ALL_OUTPUTS, "speaker", 0.40, 1); okim6295_device &oki2(OKIM6295(config, "oki2", XTAL(14'318'181)/4, okim6295_device::PIN7_HIGH)); // clock frequency & pin 7 not verified - oki2.add_route(ALL_OUTPUTS, "lspeaker", 0.20); - oki2.add_route(ALL_OUTPUTS, "rspeaker", 0.20); + oki2.add_route(ALL_OUTPUTS, "speaker", 0.20, 0); + oki2.add_route(ALL_OUTPUTS, "speaker", 0.20, 1); } diff --git a/src/mame/unisonic/gic.cpp b/src/mame/unisonic/gic.cpp index b8597203001..d890a2a75ac 100644 --- a/src/mame/unisonic/gic.cpp +++ b/src/mame/unisonic/gic.cpp @@ -245,10 +245,8 @@ TIMER_CALLBACK_MEMBER(gic_device::vblank_tick) #define GIC_AUDIO_BYTE 0x96 -void gic_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void gic_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - //Audio is basic and badly implemented (doubt that was the intent) //The datasheet lists the 3 different frequencies the GIC can generate: 500,1000 and 2000Hz //but it is clear (for an audio guy at least) that the resulting spectrum @@ -291,8 +289,6 @@ void gic_device::sound_stream_update(sound_stream &stream, std::vector<read_stre uint8_t audioByte = m_ram(GIC_AUDIO_BYTE)*2; if(!audioByte){ - buffer.fill(0); - m_audioval = 0; m_audiocnt = 0; m_audioreset = 0; @@ -306,12 +302,12 @@ void gic_device::sound_stream_update(sound_stream &stream, std::vector<read_stre m_audioreset = 0; } - for(size_t i=0; i < buffer.samples(); i++){ + for(size_t i=0; i < stream.samples(); i++){ m_audiocnt++; if(m_audiocnt >= audioByte){ m_audioval = !m_audioval; m_audiocnt=0; } - buffer.put(i, m_audioval ? 1.0 : 0.0); + stream.put(0, i, m_audioval ? 1.0 : 0.0); } } diff --git a/src/mame/unisonic/gic.h b/src/mame/unisonic/gic.h index 3be5ed2d54a..0e4b3150ff5 100644 --- a/src/mame/unisonic/gic.h +++ b/src/mame/unisonic/gic.h @@ -73,7 +73,7 @@ protected: virtual const tiny_rom_entry *device_rom_region() const override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; /* timers */ TIMER_CALLBACK_MEMBER(vblank_tick); diff --git a/src/mame/universal/superdq.cpp b/src/mame/universal/superdq.cpp index fe9d485dfd1..dc83bebc58d 100644 --- a/src/mame/universal/superdq.cpp +++ b/src/mame/universal/superdq.cpp @@ -348,8 +348,8 @@ void superdq_state::superdq(machine_config &config) PIONEER_LDV1000(config, m_laserdisc, 0); m_laserdisc->set_overlay(256, 256, FUNC(superdq_state::screen_update_superdq)); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); /* video hardware */ m_laserdisc->add_ntsc_screen(config, "screen"); @@ -358,10 +358,9 @@ void superdq_state::superdq(machine_config &config) PALETTE(config, m_palette, FUNC(superdq_state::superdq_palette), 32); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); - SN76496(config, "snsnd", MASTER_CLOCK/8).add_route(ALL_OUTPUTS, "lspeaker", 0.8); + SN76496(config, "snsnd", MASTER_CLOCK/8).add_route(ALL_OUTPUTS, "speaker", 0.8, 0); } diff --git a/src/mame/ussr/istrebiteli.cpp b/src/mame/ussr/istrebiteli.cpp index 13177d1cecc..066b74b5b96 100644 --- a/src/mame/ussr/istrebiteli.cpp +++ b/src/mame/ussr/istrebiteli.cpp @@ -51,7 +51,7 @@ protected: virtual void device_start() override ATTR_COLD; // device_sound_interface overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: // internal state @@ -97,11 +97,9 @@ void istrebiteli_sound_device::device_start() save_item(NAME(m_prev_data)); } -void istrebiteli_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void istrebiteli_sound_device::sound_stream_update(sound_stream &stream) { - auto &buffer = outputs[0]; - - for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { int smpl = 0; if (m_rom_out_en) @@ -112,7 +110,7 @@ void istrebiteli_sound_device::sound_stream_update(sound_stream &stream, std::ve smpl &= machine().rand() & 1; smpl *= (m_prev_data & 0x80) ? 1000 : 4000; // b7 volume ? - buffer.put_int(sampindex, smpl, 32768); + stream.put_int(0, sampindex, smpl, 32768); m_rom_cnt = (m_rom_cnt + m_rom_incr) & 0x1ff; } } diff --git a/src/mame/ussr/specialsound.cpp b/src/mame/ussr/specialsound.cpp index c4d9665958e..4dac7c89708 100644 --- a/src/mame/ussr/specialsound.cpp +++ b/src/mame/ussr/specialsound.cpp @@ -49,16 +49,14 @@ void specimx_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void specimx_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void specimx_sound_device::sound_stream_update(sound_stream &stream) { - auto &sample_left = outputs[0]; + sound_stream::sample_t channel_0_signal = m_specimx_input[0] ? 0.1 : -0.1; + sound_stream::sample_t channel_1_signal = m_specimx_input[1] ? 0.1 : -0.1; + sound_stream::sample_t channel_2_signal = m_specimx_input[2] ? 0.1 : -0.1; + sound_stream::sample_t sum = channel_0_signal + channel_1_signal + channel_2_signal; - stream_buffer::sample_t channel_0_signal = m_specimx_input[0] ? 0.1 : -0.1; - stream_buffer::sample_t channel_1_signal = m_specimx_input[1] ? 0.1 : -0.1; - stream_buffer::sample_t channel_2_signal = m_specimx_input[2] ? 0.1 : -0.1; - stream_buffer::sample_t sum = channel_0_signal + channel_1_signal + channel_2_signal; - - sample_left.fill(sum); + stream.fill(0, sum); } diff --git a/src/mame/ussr/specialsound.h b/src/mame/ussr/specialsound.h index 8b2cdb309d0..acee90e252c 100644 --- a/src/mame/ussr/specialsound.h +++ b/src/mame/ussr/specialsound.h @@ -26,7 +26,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: sound_stream *m_mixer_channel; diff --git a/src/mame/ussr/tiamc1_a.cpp b/src/mame/ussr/tiamc1_a.cpp index a6c25479ab3..07342f95795 100644 --- a/src/mame/ussr/tiamc1_a.cpp +++ b/src/mame/ussr/tiamc1_a.cpp @@ -107,11 +107,11 @@ void tiamc1_sound_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void tiamc1_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tiamc1_sound_device::sound_stream_update(sound_stream &stream) { int count, o0, o1, o2, len, orval = 0; - len = outputs[0].samples() * CLOCK_DIVIDER; + len = stream.samples() * CLOCK_DIVIDER; for (count = 0; count < len; count++) { @@ -140,7 +140,7 @@ void tiamc1_sound_device::sound_stream_update(sound_stream &stream, std::vector< if ((count + 1) % CLOCK_DIVIDER == 0) { - outputs[0].put(count / CLOCK_DIVIDER, orval ? 0.3 : 0.0); + stream.put(0, count / CLOCK_DIVIDER, orval ? 0.3 : 0.0); orval = 0; } } diff --git a/src/mame/ussr/tiamc1_a.h b/src/mame/ussr/tiamc1_a.h index 48a7cebd90f..d1cea3c82df 100644 --- a/src/mame/ussr/tiamc1_a.h +++ b/src/mame/ussr/tiamc1_a.h @@ -25,7 +25,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: struct timer8253chan diff --git a/src/mame/videoton/tvc_a.cpp b/src/mame/videoton/tvc_a.cpp index 1537beb1922..1e5cce96c81 100644 --- a/src/mame/videoton/tvc_a.cpp +++ b/src/mame/videoton/tvc_a.cpp @@ -59,15 +59,14 @@ TIMER_CALLBACK_MEMBER(tvc_sound_device::trigger_int) // our sound stream //------------------------------------------------- -void tvc_sound_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void tvc_sound_device::sound_stream_update(sound_stream &stream) { - auto &output = outputs[0]; - int rate = output.sample_rate() / 2; + int rate = stream.sample_rate() / 2; if (m_enabled && m_freq) { - for (int sampindex = 0; sampindex < output.samples(); sampindex++) + for (int sampindex = 0; sampindex < stream.samples(); sampindex++) { - output.put_int(sampindex, m_signal * m_volume, 32768 / 0x0800); + stream.put_int(0, sampindex, m_signal * m_volume, 32768 / 0x0800); m_incr -= m_freq; while(m_incr < 0) { @@ -76,11 +75,6 @@ void tvc_sound_device::sound_stream_update(sound_stream &stream, std::vector<rea } } } - else - { - // fill output with 0 if the sound is disabled - output.fill(0); - } } diff --git a/src/mame/videoton/tvc_a.h b/src/mame/videoton/tvc_a.h index 36c62349281..5bd8e76795b 100644 --- a/src/mame/videoton/tvc_a.h +++ b/src/mame/videoton/tvc_a.h @@ -33,7 +33,7 @@ protected: // device-level overrides virtual void device_start() override ATTR_COLD; virtual void device_reset() override ATTR_COLD; - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; TIMER_CALLBACK_MEMBER(trigger_int); diff --git a/src/mame/virtual/ldplayer.cpp b/src/mame/virtual/ldplayer.cpp index 3e61d910029..91fd5fd144b 100644 --- a/src/mame/virtual/ldplayer.cpp +++ b/src/mame/virtual/ldplayer.cpp @@ -636,10 +636,9 @@ void ldv1000_state::ldv1000(machine_config &config) { ldplayer_ntsc(config, PIONEER_LDV1000, m_laserdisc); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); } @@ -647,10 +646,9 @@ void pr8210_state::pr8210(machine_config &config) { ldplayer_ntsc(config, PIONEER_PR8210, m_laserdisc); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); - m_laserdisc->add_route(0, "lspeaker", 1.0); - m_laserdisc->add_route(1, "rspeaker", 1.0); + SPEAKER(config, "speaker", 2).front(); + m_laserdisc->add_route(0, "speaker", 1.0, 0); + m_laserdisc->add_route(1, "speaker", 1.0, 1); } diff --git a/src/mame/virtual/vgmplay.cpp b/src/mame/virtual/vgmplay.cpp index b3180e56271..cabbcac1c75 100644 --- a/src/mame/virtual/vgmplay.cpp +++ b/src/mame/virtual/vgmplay.cpp @@ -480,9 +480,8 @@ private: uint32_t m_held_clock = 0; std::vector<uint8_t> m_file_data; required_device<vgmplay_device> m_vgmplay; - required_device<vgmviz_device> m_mixer; - required_device<speaker_device> m_lspeaker; - required_device<speaker_device> m_rspeaker; + required_device<vgmviz_device> m_viz; + required_device<speaker_device> m_speaker; required_device_array<sn76489_device, 2> m_sn76489; required_device_array<ym2413_device, 2> m_ym2413; required_device_array<ym2612_device, 2> m_ym2612; @@ -2668,9 +2667,8 @@ uint8_t vgmplay_device::ga20_rom_r(offs_t offset) vgmplay_state::vgmplay_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_vgmplay(*this, "vgmplay") - , m_mixer(*this, "mixer") - , m_lspeaker(*this, "lspeaker") - , m_rspeaker(*this, "rspeaker") + , m_viz(*this, "mixer") + , m_speaker(*this, "speaker") , m_sn76489(*this, "sn76489.%d", 0) , m_ym2413(*this, "ym2413.%d", 0) , m_ym2612(*this, "ym2612.%d", 0) @@ -3316,7 +3314,7 @@ INPUT_CHANGED_MEMBER(vgmplay_state::key_pressed) m_vgmplay->toggle_loop(); break; case VGMPLAY_VIZ: - m_mixer->cycle_viz_mode(); + m_viz->cycle_viz_mode(); break; case VGMPLAY_RATE_DOWN: m_vgmplay->set_unscaled_clock((uint32_t)(m_vgmplay->clock() * 0.95f)); @@ -3668,184 +3666,184 @@ void vgmplay_state::vgmplay(machine_config &config) config.set_default_layout(layout_vgmplay); SN76489(config, m_sn76489[0], 0); - m_sn76489[0]->add_route(0, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_sn76489[0]->add_route(0, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_sn76489[0]->add_route(0, m_viz, 0.5, 0); + m_sn76489[0]->add_route(0, m_viz, 0.5, 1); SN76489(config, m_sn76489[1], 0); - m_sn76489[1]->add_route(0, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_sn76489[1]->add_route(0, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_sn76489[1]->add_route(0, m_viz, 0.5, 0); + m_sn76489[1]->add_route(0, m_viz, 0.5, 1); YM2413(config, m_ym2413[0], 0); - m_ym2413[0]->add_route(ALL_OUTPUTS, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ym2413[0]->add_route(ALL_OUTPUTS, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ym2413[0]->add_route(ALL_OUTPUTS, m_viz, 1, 0); + m_ym2413[0]->add_route(ALL_OUTPUTS, m_viz, 1, 1); YM2413(config, m_ym2413[1], 0); - m_ym2413[1]->add_route(ALL_OUTPUTS, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ym2413[1]->add_route(ALL_OUTPUTS, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ym2413[1]->add_route(ALL_OUTPUTS, m_viz, 1, 0); + m_ym2413[1]->add_route(ALL_OUTPUTS, m_viz, 1, 1); YM2612(config, m_ym2612[0], 0); - m_ym2612[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ym2612[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ym2612[0]->add_route(0, m_viz, 1, 0); + m_ym2612[0]->add_route(1, m_viz, 1, 1); YM2612(config, m_ym2612[1], 0); - m_ym2612[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ym2612[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ym2612[1]->add_route(0, m_viz, 1, 0); + m_ym2612[1]->add_route(1, m_viz, 1, 1); YM2151(config, m_ym2151[0], 0); - m_ym2151[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ym2151[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ym2151[0]->add_route(0, m_viz, 1, 0); + m_ym2151[0]->add_route(1, m_viz, 1, 1); YM2151(config, m_ym2151[1], 0); - m_ym2151[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ym2151[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ym2151[1]->add_route(0, m_viz, 1, 0); + m_ym2151[1]->add_route(1, m_viz, 1, 1); SEGAPCM(config, m_segapcm[0], 0); m_segapcm[0]->set_addrmap(0, &vgmplay_state::segapcm_map<0>); - m_segapcm[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_segapcm[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_segapcm[0]->add_route(0, m_viz, 1, 0); + m_segapcm[0]->add_route(1, m_viz, 1, 1); SEGAPCM(config, m_segapcm[1], 0); m_segapcm[1]->set_addrmap(0, &vgmplay_state::segapcm_map<1>); - m_segapcm[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_segapcm[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_segapcm[1]->add_route(0, m_viz, 1, 0); + m_segapcm[1]->add_route(1, m_viz, 1, 1); RF5C68(config, m_rf5c68, 0); m_rf5c68->set_addrmap(0, &vgmplay_state::rf5c68_map<0>); - m_rf5c68->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_rf5c68->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_rf5c68->add_route(0, m_viz, 1, 0); + m_rf5c68->add_route(1, m_viz, 1, 1); // TODO: prevent error.log spew YM2203(config, m_ym2203[0], 0); - m_ym2203[0]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ym2203[0]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); + m_ym2203[0]->add_route(ALL_OUTPUTS, m_viz, 0.25, 0); + m_ym2203[0]->add_route(ALL_OUTPUTS, m_viz, 0.25, 1); YM2203(config, m_ym2203[1], 0); - m_ym2203[1]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ym2203[1]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); + m_ym2203[1]->add_route(ALL_OUTPUTS, m_viz, 0.25, 0); + m_ym2203[1]->add_route(ALL_OUTPUTS, m_viz, 0.25, 1); // TODO: prevent error.log spew YM2608(config, m_ym2608[0], 0); m_ym2608[0]->set_addrmap(0, &vgmplay_state::ym2608_map<0>); - m_ym2608[0]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ym2608[0]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); - m_ym2608[0]->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ym2608[0]->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_ym2608[0]->add_route(0, m_viz, 0.25, 0); + m_ym2608[0]->add_route(0, m_viz, 0.25, 1); + m_ym2608[0]->add_route(1, m_viz, 1.00, 0); + m_ym2608[0]->add_route(2, m_viz, 1.00, 1); YM2608(config, m_ym2608[1], 0); m_ym2608[1]->set_addrmap(0, &vgmplay_state::ym2608_map<1>); - m_ym2608[1]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ym2608[1]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); - m_ym2608[1]->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ym2608[1]->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_ym2608[1]->add_route(0, m_viz, 0.25, 0); + m_ym2608[1]->add_route(0, m_viz, 0.25, 1); + m_ym2608[1]->add_route(1, m_viz, 1.00, 0); + m_ym2608[1]->add_route(2, m_viz, 1.00, 1); // TODO: prevent error.log spew YM2610(config, m_ym2610[0], 0); m_ym2610[0]->set_addrmap(0, &vgmplay_state::ym2610_adpcm_a_map<0>); m_ym2610[0]->set_addrmap(1, &vgmplay_state::ym2610_adpcm_b_map<0>); - m_ym2610[0]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ym2610[0]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); - m_ym2610[0]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_ym2610[0]->add_route(2, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_ym2610[0]->add_route(0, m_viz, 0.25, 0); + m_ym2610[0]->add_route(0, m_viz, 0.25, 1); + m_ym2610[0]->add_route(1, m_viz, 0.50, 0); + m_ym2610[0]->add_route(2, m_viz, 0.50, 1); YM2610(config, m_ym2610[1], 0); m_ym2610[1]->set_addrmap(0, &vgmplay_state::ym2610_adpcm_a_map<1>); m_ym2610[1]->set_addrmap(1, &vgmplay_state::ym2610_adpcm_b_map<1>); - m_ym2610[1]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ym2610[1]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); - m_ym2610[1]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_ym2610[1]->add_route(2, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_ym2610[1]->add_route(0, m_viz, 0.25, 0); + m_ym2610[1]->add_route(0, m_viz, 0.25, 1); + m_ym2610[1]->add_route(1, m_viz, 0.50, 0); + m_ym2610[1]->add_route(2, m_viz, 0.50, 1); YM3812(config, m_ym3812[0], 0); - m_ym3812[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_ym3812[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_ym3812[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_ym3812[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); YM3812(config, m_ym3812[1], 0); - m_ym3812[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_ym3812[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_ym3812[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_ym3812[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); YM3526(config, m_ym3526[0], 0); - m_ym3526[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_ym3526[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_ym3526[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_ym3526[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); YM3526(config, m_ym3526[1], 0); - m_ym3526[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_ym3526[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_ym3526[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_ym3526[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); Y8950(config, m_y8950[0], 0); m_y8950[0]->set_addrmap(0, &vgmplay_state::y8950_map<0>); - m_y8950[0]->add_route(ALL_OUTPUTS, m_mixer, 0.40, AUTO_ALLOC_INPUT, 0); - m_y8950[0]->add_route(ALL_OUTPUTS, m_mixer, 0.40, AUTO_ALLOC_INPUT, 1); + m_y8950[0]->add_route(ALL_OUTPUTS, m_viz, 0.40, 0); + m_y8950[0]->add_route(ALL_OUTPUTS, m_viz, 0.40, 1); Y8950(config, m_y8950[1], 0); m_y8950[1]->set_addrmap(0, &vgmplay_state::y8950_map<1>); - m_y8950[1]->add_route(ALL_OUTPUTS, m_mixer, 0.40, AUTO_ALLOC_INPUT, 0); - m_y8950[1]->add_route(ALL_OUTPUTS, m_mixer, 0.40, AUTO_ALLOC_INPUT, 1); + m_y8950[1]->add_route(ALL_OUTPUTS, m_viz, 0.40, 0); + m_y8950[1]->add_route(ALL_OUTPUTS, m_viz, 0.40, 1); YMF262(config, m_ymf262[0], 0); - m_ymf262[0]->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf262[0]->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_ymf262[0]->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf262[0]->add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_ymf262[0]->add_route(0, m_viz, 1.00, 0); + m_ymf262[0]->add_route(1, m_viz, 1.00, 1); + m_ymf262[0]->add_route(2, m_viz, 1.00, 0); + m_ymf262[0]->add_route(3, m_viz, 1.00, 1); YMF262(config, m_ymf262[1], 0); - m_ymf262[1]->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf262[1]->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_ymf262[1]->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf262[1]->add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_ymf262[1]->add_route(0, m_viz, 1.00, 0); + m_ymf262[1]->add_route(1, m_viz, 1.00, 1); + m_ymf262[1]->add_route(2, m_viz, 1.00, 0); + m_ymf262[1]->add_route(3, m_viz, 1.00, 1); // TODO: prevent error.log spew YMF278B(config, m_ymf278b[0], 0); m_ymf278b[0]->set_addrmap(0, &vgmplay_state::ymf278b_map<0>); - m_ymf278b[0]->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf278b[0]->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_ymf278b[0]->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf278b[0]->add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_ymf278b[0]->add_route(4, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf278b[0]->add_route(5, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_ymf278b[0]->add_route(0, m_viz, 1.00, 0); + m_ymf278b[0]->add_route(1, m_viz, 1.00, 1); + m_ymf278b[0]->add_route(2, m_viz, 1.00, 0); + m_ymf278b[0]->add_route(3, m_viz, 1.00, 1); + m_ymf278b[0]->add_route(4, m_viz, 1.00, 0); + m_ymf278b[0]->add_route(5, m_viz, 1.00, 1); YMF278B(config, m_ymf278b[1], 0); m_ymf278b[1]->set_addrmap(0, &vgmplay_state::ymf278b_map<1>); - m_ymf278b[1]->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf278b[1]->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_ymf278b[1]->add_route(2, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf278b[1]->add_route(3, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); - m_ymf278b[1]->add_route(4, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_ymf278b[1]->add_route(5, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_ymf278b[1]->add_route(0, m_viz, 1.00, 0); + m_ymf278b[1]->add_route(1, m_viz, 1.00, 1); + m_ymf278b[1]->add_route(2, m_viz, 1.00, 0); + m_ymf278b[1]->add_route(3, m_viz, 1.00, 1); + m_ymf278b[1]->add_route(4, m_viz, 1.00, 0); + m_ymf278b[1]->add_route(5, m_viz, 1.00, 1); YMF271(config, m_ymf271[0], 0); m_ymf271[0]->set_addrmap(0, &vgmplay_state::ymf271_map<0>); - m_ymf271[0]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ymf271[0]->add_route(1, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); - m_ymf271[0]->add_route(2, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ymf271[0]->add_route(3, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); + m_ymf271[0]->add_route(0, m_viz, 0.25, 0); + m_ymf271[0]->add_route(1, m_viz, 0.25, 1); + m_ymf271[0]->add_route(2, m_viz, 0.25, 0); + m_ymf271[0]->add_route(3, m_viz, 0.25, 1); YMF271(config, m_ymf271[1], 0); m_ymf271[1]->set_addrmap(0, &vgmplay_state::ymf271_map<0>); - m_ymf271[1]->add_route(0, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ymf271[1]->add_route(1, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); - m_ymf271[1]->add_route(2, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_ymf271[1]->add_route(3, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); + m_ymf271[1]->add_route(0, m_viz, 0.25, 0); + m_ymf271[1]->add_route(1, m_viz, 0.25, 1); + m_ymf271[1]->add_route(2, m_viz, 0.25, 0); + m_ymf271[1]->add_route(3, m_viz, 0.25, 1); // TODO: prevent error.log spew YMZ280B(config, m_ymz280b[0], 0); m_ymz280b[0]->set_addrmap(0, &vgmplay_state::ymz280b_map<0>); - m_ymz280b[0]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_ymz280b[0]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_ymz280b[0]->add_route(0, m_viz, 0.50, 0); + m_ymz280b[0]->add_route(1, m_viz, 0.50, 1); YMZ280B(config, m_ymz280b[1], 0); m_ymz280b[1]->set_addrmap(0, &vgmplay_state::ymz280b_map<1>); - m_ymz280b[1]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_ymz280b[1]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_ymz280b[1]->add_route(0, m_viz, 0.50, 0); + m_ymz280b[1]->add_route(1, m_viz, 0.50, 1); RF5C164(config, m_rf5c164, 0); m_rf5c164->set_addrmap(0, &vgmplay_state::rf5c164_map<0>); - m_rf5c164->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_rf5c164->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_rf5c164->add_route(0, m_viz, 1, 0); + m_rf5c164->add_route(1, m_viz, 1, 1); /// TODO: rewrite to generate audio without using DAC devices SEGA_32X_NTSC(config, m_sega32x, 0, "sega32x_maincpu", "sega32x_scanline_timer"); - m_sega32x->add_route(0, m_mixer, 1.00, AUTO_ALLOC_INPUT, 0); - m_sega32x->add_route(1, m_mixer, 1.00, AUTO_ALLOC_INPUT, 1); + m_sega32x->add_route(0, m_viz, 1.00, 0); + m_sega32x->add_route(1, m_viz, 1.00, 1); auto& sega32x_maincpu(M68000(config, "sega32x_maincpu", 0)); sega32x_maincpu.set_disable(); @@ -3857,249 +3855,248 @@ void vgmplay_state::vgmplay(machine_config &config) // TODO: prevent error.log spew AY8910(config, m_ay8910[0], 0); - m_ay8910[0]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 0); - m_ay8910[0]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 1); + m_ay8910[0]->add_route(ALL_OUTPUTS, m_viz, 0.33, 0); + m_ay8910[0]->add_route(ALL_OUTPUTS, m_viz, 0.33, 1); AY8910(config, m_ay8910[1], 0); - m_ay8910[1]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 0); - m_ay8910[1]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 1); + m_ay8910[1]->add_route(ALL_OUTPUTS, m_viz, 0.33, 0); + m_ay8910[1]->add_route(ALL_OUTPUTS, m_viz, 0.33, 1); DMG_APU(config, m_dmg[0], 0); - m_dmg[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_dmg[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_dmg[0]->add_route(0, m_viz, 1, 0); + m_dmg[0]->add_route(0, m_viz, 1, 1); DMG_APU(config, m_dmg[1], 0); - m_dmg[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_dmg[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_dmg[1]->add_route(0, m_viz, 1, 0); + m_dmg[1]->add_route(0, m_viz, 1, 1); RP2A03G(config, m_nescpu[0], 0); m_nescpu[0]->set_addrmap(AS_PROGRAM, &vgmplay_state::nescpu_map<0>); m_nescpu[0]->set_disable(); - m_nescpu[0]->add_route(ALL_OUTPUTS, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_nescpu[0]->add_route(ALL_OUTPUTS, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_nescpu[0]->add_route(ALL_OUTPUTS, m_viz, 0.50, 0); + m_nescpu[0]->add_route(ALL_OUTPUTS, m_viz, 0.50, 1); RP2A03G(config, m_nescpu[1], 0); m_nescpu[1]->set_addrmap(AS_PROGRAM, &vgmplay_state::nescpu_map<1>); m_nescpu[1]->set_disable(); - m_nescpu[1]->add_route(ALL_OUTPUTS, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_nescpu[1]->add_route(ALL_OUTPUTS, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_nescpu[1]->add_route(ALL_OUTPUTS, m_viz, 0.50, 0); + m_nescpu[1]->add_route(ALL_OUTPUTS, m_viz, 0.50, 1); MULTIPCM(config, m_multipcm[0], 0); m_multipcm[0]->set_addrmap(0, &vgmplay_state::multipcm_map<0>); - m_multipcm[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_multipcm[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_multipcm[0]->add_route(0, m_viz, 1, 0); + m_multipcm[0]->add_route(1, m_viz, 1, 1); MULTIPCM(config, m_multipcm[1], 0); m_multipcm[1]->set_addrmap(0, &vgmplay_state::multipcm_map<1>); - m_multipcm[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_multipcm[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_multipcm[1]->add_route(0, m_viz, 1, 0); + m_multipcm[1]->add_route(1, m_viz, 1, 1); UPD7759(config, m_upd7759[0], 0); m_upd7759[0]->drq().set(FUNC(vgmplay_state::upd7759_drq_w<0>)); m_upd7759[0]->set_addrmap(0, &vgmplay_state::upd7759_map<0>); - m_upd7759[0]->add_route(ALL_OUTPUTS, m_mixer, 1.0, AUTO_ALLOC_INPUT, 0); - m_upd7759[0]->add_route(ALL_OUTPUTS, m_mixer, 1.0, AUTO_ALLOC_INPUT, 1); + m_upd7759[0]->add_route(ALL_OUTPUTS, m_viz, 1.0, 0); + m_upd7759[0]->add_route(ALL_OUTPUTS, m_viz, 1.0, 1); UPD7759(config, m_upd7759[1], 0); m_upd7759[1]->drq().set(FUNC(vgmplay_state::upd7759_drq_w<1>)); m_upd7759[1]->set_addrmap(0, &vgmplay_state::upd7759_map<1>); - m_upd7759[1]->add_route(ALL_OUTPUTS, m_mixer, 1.0, AUTO_ALLOC_INPUT, 0); - m_upd7759[1]->add_route(ALL_OUTPUTS, m_mixer, 1.0, AUTO_ALLOC_INPUT, 1); + m_upd7759[1]->add_route(ALL_OUTPUTS, m_viz, 1.0, 0); + m_upd7759[1]->add_route(ALL_OUTPUTS, m_viz, 1.0, 1); OKIM6258(config, m_okim6258[0], 0); - m_okim6258[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_okim6258[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_okim6258[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_okim6258[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); OKIM6258(config, m_okim6258[1], 0); - m_okim6258[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_okim6258[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_okim6258[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_okim6258[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); OKIM6295(config, m_okim6295[0], 0, okim6295_device::PIN7_HIGH); m_okim6295[0]->set_addrmap(0, &vgmplay_state::okim6295_map<0>); - m_okim6295[0]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_okim6295[0]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); + m_okim6295[0]->add_route(ALL_OUTPUTS, m_viz, 0.25, 0); + m_okim6295[0]->add_route(ALL_OUTPUTS, m_viz, 0.25, 1); OKIM6295(config, m_okim6295[1], 0, okim6295_device::PIN7_HIGH); m_okim6295[1]->set_addrmap(0, &vgmplay_state::okim6295_map<1>); - m_okim6295[1]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 0); - m_okim6295[1]->add_route(ALL_OUTPUTS, m_mixer, 0.25, AUTO_ALLOC_INPUT, 1); + m_okim6295[1]->add_route(ALL_OUTPUTS, m_viz, 0.25, 0); + m_okim6295[1]->add_route(ALL_OUTPUTS, m_viz, 0.25, 1); K051649(config, m_k051649[0], 0); - m_k051649[0]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 0); - m_k051649[0]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 1); + m_k051649[0]->add_route(ALL_OUTPUTS, m_viz, 0.33, 0); + m_k051649[0]->add_route(ALL_OUTPUTS, m_viz, 0.33, 1); K051649(config, m_k051649[1], 0); - m_k051649[1]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 0); - m_k051649[1]->add_route(ALL_OUTPUTS, m_mixer, 0.33, AUTO_ALLOC_INPUT, 1); + m_k051649[1]->add_route(ALL_OUTPUTS, m_viz, 0.33, 0); + m_k051649[1]->add_route(ALL_OUTPUTS, m_viz, 0.33, 1); K054539(config, m_k054539[0], 0); m_k054539[0]->set_addrmap(0, &vgmplay_state::k054539_map<0>); - m_k054539[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_k054539[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_k054539[0]->add_route(0, m_viz, 1, 0); + m_k054539[0]->add_route(1, m_viz, 1, 1); K054539(config, m_k054539[1], 0); m_k054539[1]->set_addrmap(0, &vgmplay_state::k054539_map<1>); - m_k054539[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_k054539[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_k054539[1]->add_route(0, m_viz, 1, 0); + m_k054539[1]->add_route(1, m_viz, 1, 1); // TODO: prevent error.log spew H6280(config, m_huc6280[0], 0); m_huc6280[0]->set_disable(); - m_huc6280[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_huc6280[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_huc6280[0]->add_route(0, m_viz, 1, 0); + m_huc6280[0]->add_route(1, m_viz, 1, 1); H6280(config, m_huc6280[1], 0); m_huc6280[1]->set_disable(); - m_huc6280[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_huc6280[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_huc6280[1]->add_route(0, m_viz, 1, 0); + m_huc6280[1]->add_route(1, m_viz, 1, 1); C140(config, m_c140[0], 0); m_c140[0]->set_addrmap(0, &vgmplay_state::c140_map<0>); - m_c140[0]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_c140[0]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_c140[0]->add_route(0, m_viz, 0.50, 0); + m_c140[0]->add_route(1, m_viz, 0.50, 1); C140(config, m_c140[1], 0); m_c140[1]->set_addrmap(0, &vgmplay_state::c140_map<1>); - m_c140[1]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_c140[1]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_c140[1]->add_route(0, m_viz, 0.50, 0); + m_c140[1]->add_route(1, m_viz, 0.50, 1); C219(config, m_c219[0], 0); m_c219[0]->set_addrmap(0, &vgmplay_state::c219_map<0>); - m_c219[0]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_c219[0]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_c219[0]->add_route(0, m_viz, 0.50, 0); + m_c219[0]->add_route(1, m_viz, 0.50, 1); C219(config, m_c219[1], 0); m_c219[1]->set_addrmap(0, &vgmplay_state::c219_map<1>); - m_c219[1]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_c219[1]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_c219[1]->add_route(0, m_viz, 0.50, 0); + m_c219[1]->add_route(1, m_viz, 0.50, 1); K053260(config, m_k053260[0], 0); m_k053260[0]->set_addrmap(0, &vgmplay_state::k053260_map<0>); - m_k053260[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_k053260[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_k053260[0]->add_route(0, m_viz, 1, 0); + m_k053260[0]->add_route(1, m_viz, 1, 1); K053260(config, m_k053260[1], 0); m_k053260[1]->set_addrmap(0, &vgmplay_state::k053260_map<1>); - m_k053260[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_k053260[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_k053260[1]->add_route(0, m_viz, 1, 0); + m_k053260[1]->add_route(1, m_viz, 1, 1); POKEY(config, m_pokey[0], 0); - m_pokey[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_pokey[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_pokey[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_pokey[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); POKEY(config, m_pokey[1], 0); - m_pokey[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_pokey[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_pokey[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_pokey[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); QSOUND(config, m_qsound, 0); m_qsound->set_addrmap(0, &vgmplay_state::qsound_map<0>); - m_qsound->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_qsound->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_qsound->add_route(0, m_viz, 1, 0); + m_qsound->add_route(1, m_viz, 1, 1); SCSP(config, m_scsp[0], 0); m_scsp[0]->set_addrmap(0, &vgmplay_state::scsp_map<0>); - m_scsp[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_scsp[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_scsp[0]->add_route(0, m_viz, 1, 0); + m_scsp[0]->add_route(1, m_viz, 1, 1); SCSP(config, m_scsp[1], 0); m_scsp[1]->set_addrmap(0, &vgmplay_state::scsp_map<1>); - m_scsp[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_scsp[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_scsp[1]->add_route(0, m_viz, 1, 0); + m_scsp[1]->add_route(1, m_viz, 1, 1); WSWAN_SND(config, m_wswan[0], 0); m_wswan[0]->set_headphone_connected(true); m_wswan[0]->set_addrmap(0, &vgmplay_state::wswan_map<0>); - m_wswan[0]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_wswan[0]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_wswan[0]->add_route(0, m_viz, 0.50, 0); + m_wswan[0]->add_route(1, m_viz, 0.50, 1); WSWAN_SND(config, m_wswan[1], 0); m_wswan[1]->set_headphone_connected(true); m_wswan[1]->set_addrmap(0, &vgmplay_state::wswan_map<1>); - m_wswan[1]->add_route(0, m_mixer, 0.50, AUTO_ALLOC_INPUT, 0); - m_wswan[1]->add_route(1, m_mixer, 0.50, AUTO_ALLOC_INPUT, 1); + m_wswan[1]->add_route(0, m_viz, 0.50, 0); + m_wswan[1]->add_route(1, m_viz, 0.50, 1); VBOYSND(config, m_vsu_vue[0], 0); - m_vsu_vue[0]->add_route(0, m_mixer, 1.0, AUTO_ALLOC_INPUT, 0); - m_vsu_vue[0]->add_route(1, m_mixer, 1.0, AUTO_ALLOC_INPUT, 1); + m_vsu_vue[0]->add_route(0, m_viz, 1.0, 0); + m_vsu_vue[0]->add_route(1, m_viz, 1.0, 1); VBOYSND(config, m_vsu_vue[1], 0); - m_vsu_vue[1]->add_route(0, m_mixer, 1.0, AUTO_ALLOC_INPUT, 0); - m_vsu_vue[1]->add_route(1, m_mixer, 1.0, AUTO_ALLOC_INPUT, 1); + m_vsu_vue[1]->add_route(0, m_viz, 1.0, 0); + m_vsu_vue[1]->add_route(1, m_viz, 1.0, 1); SAA1099(config, m_saa1099[0], 0); - m_saa1099[0]->add_route(0, m_mixer, 1.0, AUTO_ALLOC_INPUT, 0); - m_saa1099[0]->add_route(1, m_mixer, 1.0, AUTO_ALLOC_INPUT, 1); + m_saa1099[0]->add_route(0, m_viz, 1.0, 0); + m_saa1099[0]->add_route(1, m_viz, 1.0, 1); SAA1099(config, m_saa1099[1], 0); - m_saa1099[1]->add_route(0, m_mixer, 1.0, AUTO_ALLOC_INPUT, 0); - m_saa1099[1]->add_route(1, m_mixer, 1.0, AUTO_ALLOC_INPUT, 1); + m_saa1099[1]->add_route(0, m_viz, 1.0, 0); + m_saa1099[1]->add_route(1, m_viz, 1.0, 1); ES5503(config, m_es5503[0], 0); m_es5503[0]->set_channels(2); m_es5503[0]->set_addrmap(0, &vgmplay_state::es5503_map<0>); - m_es5503[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_es5503[0]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_es5503[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_es5503[0]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); ES5503(config, m_es5503[1], 0); m_es5503[1]->set_channels(2); m_es5503[1]->set_addrmap(0, &vgmplay_state::es5503_map<1>); - m_es5503[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_es5503[1]->add_route(ALL_OUTPUTS, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_es5503[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 0); + m_es5503[1]->add_route(ALL_OUTPUTS, m_viz, 0.5, 1); ES5505(config, m_es5505[0], 0); // TODO m_es5505[0]->set_addrmap(0, &vgmplay_state::es5505_map<0>); // TODO m_es5505[0]->set_addrmap(1, &vgmplay_state::es5505_map<0>); m_es5505[0]->set_channels(1); - m_es5505[0]->add_route(0, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_es5505[0]->add_route(1, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_es5505[0]->add_route(0, m_viz, 0.5, 0); + m_es5505[0]->add_route(1, m_viz, 0.5, 1); ES5505(config, m_es5505[1], 0); // TODO m_es5505[1]->set_addrmap(0, &vgmplay_state::es5505_map<1>); // TODO m_es5505[1]->set_addrmap(1, &vgmplay_state::es5505_map<1>); m_es5505[1]->set_channels(1); - m_es5505[1]->add_route(0, m_mixer, 0.5, AUTO_ALLOC_INPUT, 0); - m_es5505[1]->add_route(1, m_mixer, 0.5, AUTO_ALLOC_INPUT, 1); + m_es5505[1]->add_route(0, m_viz, 0.5, 0); + m_es5505[1]->add_route(1, m_viz, 0.5, 1); X1_010(config, m_x1_010[0], 0); m_x1_010[0]->set_addrmap(0, &vgmplay_state::x1_010_map<0>); - m_x1_010[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_x1_010[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_x1_010[0]->add_route(0, m_viz, 1, 0); + m_x1_010[0]->add_route(1, m_viz, 1, 1); X1_010(config, m_x1_010[1], 0); m_x1_010[1]->set_addrmap(0, &vgmplay_state::x1_010_map<1>); - m_x1_010[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_x1_010[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_x1_010[1]->add_route(0, m_viz, 1, 0); + m_x1_010[1]->add_route(1, m_viz, 1, 1); C352(config, m_c352[0], 0, 1); m_c352[0]->set_addrmap(0, &vgmplay_state::c352_map<0>); - m_c352[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_c352[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); - m_c352[0]->add_route(2, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_c352[0]->add_route(3, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_c352[0]->add_route(0, m_viz, 1, 0); + m_c352[0]->add_route(1, m_viz, 1, 1); + m_c352[0]->add_route(2, m_viz, 1, 0); + m_c352[0]->add_route(3, m_viz, 1, 1); C352(config, m_c352[1], 0, 1); m_c352[1]->set_addrmap(0, &vgmplay_state::c352_map<1>); - m_c352[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_c352[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); - m_c352[1]->add_route(2, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_c352[1]->add_route(3, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_c352[1]->add_route(0, m_viz, 1, 0); + m_c352[1]->add_route(1, m_viz, 1, 1); + m_c352[1]->add_route(2, m_viz, 1, 0); + m_c352[1]->add_route(3, m_viz, 1, 1); IREMGA20(config, m_ga20[0], 0); m_ga20[0]->set_addrmap(0, &vgmplay_state::ga20_map<0>); - m_ga20[0]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ga20[0]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ga20[0]->add_route(0, m_viz, 1, 0); + m_ga20[0]->add_route(1, m_viz, 1, 1); IREMGA20(config, m_ga20[1], 0); m_ga20[1]->set_addrmap(0, &vgmplay_state::ga20_map<1>); - m_ga20[1]->add_route(0, m_mixer, 1, AUTO_ALLOC_INPUT, 0); - m_ga20[1]->add_route(1, m_mixer, 1, AUTO_ALLOC_INPUT, 1); + m_ga20[1]->add_route(0, m_viz, 1, 0); + m_ga20[1]->add_route(1, m_viz, 1, 1); - VGMVIZ(config, m_mixer, 0); - m_mixer->add_route(0, "lspeaker", 1); - m_mixer->add_route(1, "rspeaker", 1); + VGMVIZ(config, m_viz, 0); + m_viz->add_route(0, "speaker", 1, 0); + m_viz->add_route(1, "speaker", 1, 1); - SPEAKER(config, m_lspeaker).front_left(); - SPEAKER(config, m_rspeaker).front_right(); + SPEAKER(config, m_speaker, 2).front(); } ROM_START( vgmplay ) diff --git a/src/mame/virtual/wavesynth.cpp b/src/mame/virtual/wavesynth.cpp index 931c8d8b5c0..c5db150bf0d 100644 --- a/src/mame/virtual/wavesynth.cpp +++ b/src/mame/virtual/wavesynth.cpp @@ -40,11 +40,10 @@ void wavesynth_state::machine_start() void wavesynth_state::wavesynth(machine_config &config) { WAVEBLASTER_CONNECTOR(config, m_waveblaster, waveblaster_intf, "omniwave"); - m_waveblaster->add_route(0, "lspeaker", 1.0); - m_waveblaster->add_route(1, "rspeaker", 1.0); + m_waveblaster->add_route(0, "speaker", 1.0, 0); + m_waveblaster->add_route(1, "speaker", 1.0, 1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); auto &mdin(MIDI_PORT(config, "mdin")); midiin_slot(mdin); diff --git a/src/mame/vsystem/aerofgt.cpp b/src/mame/vsystem/aerofgt.cpp index 639c34307f0..4702cc78511 100644 --- a/src/mame/vsystem/aerofgt.cpp +++ b/src/mame/vsystem/aerofgt.cpp @@ -400,8 +400,7 @@ void aerofgt_state::aerofgt(machine_config &config) m_spr->set_pri_cb(FUNC(aerofgt_state::pri_callback)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(aerofgt_state::soundlatch_pending_w)); @@ -409,10 +408,10 @@ void aerofgt_state::aerofgt(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(8'000'000))); // verified on pcb ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/vsystem/crshrace.cpp b/src/mame/vsystem/crshrace.cpp index 78ebe3ad71c..01a07e35460 100644 --- a/src/mame/vsystem/crshrace.cpp +++ b/src/mame/vsystem/crshrace.cpp @@ -622,8 +622,7 @@ void crshrace_state::crshrace(machine_config &config) // TODO: PCB sports 32 MHz m_k053936->set_offsets(-48, -21); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(crshrace_state::soundlatch_pending_w)); @@ -631,10 +630,10 @@ void crshrace_state::crshrace(machine_config &config) // TODO: PCB sports 32 MHz ym2610_device &ymsnd(YM2610(config, "ymsnd", 8'000'000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/vsystem/f1gp.cpp b/src/mame/vsystem/f1gp.cpp index 24bb3ce1090..e1d6764eb17 100644 --- a/src/mame/vsystem/f1gp.cpp +++ b/src/mame/vsystem/f1gp.cpp @@ -858,8 +858,7 @@ void f1gp_state::f1gp(machine_config &config) m_k053936->set_offsets(-58, -2); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(f1gp_state::soundlatch_pending_w)); @@ -867,10 +866,10 @@ void f1gp_state::f1gp(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(8'000'000))); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void f1gp_state::f1gpbl(machine_config &config) diff --git a/src/mame/vsystem/gstriker.cpp b/src/mame/vsystem/gstriker.cpp index be9751a8cc8..78f9ffb57cd 100644 --- a/src/mame/vsystem/gstriker.cpp +++ b/src/mame/vsystem/gstriker.cpp @@ -667,8 +667,7 @@ void gstriker_state::base(machine_config &config) m_spr->set_pal_mask(0x1f); m_spr->set_transpen(0); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); generic_latch_8_device &soundlatch(GENERIC_LATCH_8(config, "soundlatch")); soundlatch.data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -676,10 +675,10 @@ void gstriker_state::base(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", 8_MHz_XTAL)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void gstriker_state::gstriker(machine_config &config) diff --git a/src/mame/vsystem/pspikes.cpp b/src/mame/vsystem/pspikes.cpp index b42f4302950..aeed7a4de25 100644 --- a/src/mame/vsystem/pspikes.cpp +++ b/src/mame/vsystem/pspikes.cpp @@ -2309,8 +2309,7 @@ void pspikes_banked_sound_state::pspikes(machine_config &config) MCFG_VIDEO_START_OVERRIDE(pspikes_banked_sound_state,pspikes) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(pspikes_banked_sound_state::soundlatch_pending_w)); @@ -2318,10 +2317,10 @@ void pspikes_banked_sound_state::pspikes(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", 8000000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void spikes91_state::spikes91(machine_config &config) @@ -2510,8 +2509,7 @@ void pspikes_banked_sound_state::karatblz(machine_config &config) MCFG_VIDEO_START_OVERRIDE(pspikes_banked_sound_state,karatblz) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(pspikes_banked_sound_state::soundlatch_pending_w)); @@ -2519,10 +2517,10 @@ void pspikes_banked_sound_state::karatblz(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(8'000'000))); // verified on pcb ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void karatblzbl_state::karatblzbl(machine_config &config) @@ -2608,8 +2606,7 @@ void pspikes_banked_sound_state::spinlbrk(machine_config &config) MCFG_VIDEO_START_OVERRIDE(pspikes_banked_sound_state,spinlbrk) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(pspikes_banked_sound_state::soundlatch_pending_w)); @@ -2617,10 +2614,10 @@ void pspikes_banked_sound_state::spinlbrk(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(8'000'000))); // verified on pcb ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void pspikes_banked_sound_state::turbofrc(machine_config &config) @@ -2657,8 +2654,7 @@ void pspikes_banked_sound_state::turbofrc(machine_config &config) MCFG_VIDEO_START_OVERRIDE(pspikes_banked_sound_state,turbofrc) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(pspikes_banked_sound_state::soundlatch_pending_w)); @@ -2666,10 +2662,10 @@ void pspikes_banked_sound_state::turbofrc(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", XTAL(8'000'000))); // verified on pcb ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void pspikes_banked_sound_state::aerofgtb(machine_config &config) @@ -2708,8 +2704,7 @@ void pspikes_banked_sound_state::aerofgtb(machine_config &config) MCFG_VIDEO_START_OVERRIDE(pspikes_banked_sound_state,aerofgtb) // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(pspikes_banked_sound_state::soundlatch_pending_w)); @@ -2717,10 +2712,10 @@ void pspikes_banked_sound_state::aerofgtb(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", 8000000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } void pspikes_sound_cpu_state::aerfboot(machine_config &config) diff --git a/src/mame/vsystem/suprslam.cpp b/src/mame/vsystem/suprslam.cpp index 733b85e3f98..ecfe0e900d8 100644 --- a/src/mame/vsystem/suprslam.cpp +++ b/src/mame/vsystem/suprslam.cpp @@ -450,8 +450,7 @@ void suprslam_state::suprslam(machine_config &config) m_k053936->set_wrap(1); m_k053936->set_offsets(-45, -21); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); @@ -459,10 +458,10 @@ void suprslam_state::suprslam(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", 32_MHz_XTAL / 4)); // not verified ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } /*** ROM LOADING *************************************************************/ diff --git a/src/mame/vsystem/tail2nos.cpp b/src/mame/vsystem/tail2nos.cpp index dd6321b6fdc..a9d9ecdea98 100644 --- a/src/mame/vsystem/tail2nos.cpp +++ b/src/mame/vsystem/tail2nos.cpp @@ -516,8 +516,7 @@ void tail2nos_state::tail2nos(machine_config &config) VSYSTEM_GGA(config, "gga", XTAL(14'318'181) / 2); // divider not verified // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(tail2nos_state::soundlatch_pending_w)); @@ -526,10 +525,10 @@ void tail2nos_state::tail2nos(machine_config &config) ym2608_device &ymsnd(YM2608(config, "ymsnd", XTAL(8'000'000))); // verified on PCB ymsnd.irq_handler().set_inputline(m_audiocpu, 0); ymsnd.port_b_write_callback().set(FUNC(tail2nos_state::sound_bankswitch_w)); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/vsystem/taotaido.cpp b/src/mame/vsystem/taotaido.cpp index 8c57e990b25..27375c95070 100644 --- a/src/mame/vsystem/taotaido.cpp +++ b/src/mame/vsystem/taotaido.cpp @@ -600,8 +600,7 @@ void taotaido_state::taotaido(machine_config &config) m_spr->set_tile_indirect_cb(FUNC(taotaido_state::tile_callback)); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); m_soundlatch->data_pending_callback().set(FUNC(taotaido_state::soundlatch_pending_w)); @@ -609,10 +608,10 @@ void taotaido_state::taotaido(machine_config &config) ym2610_device &ymsnd(YM2610(config, "ymsnd", 8'000'000)); ymsnd.irq_handler().set_inputline(m_audiocpu, 0); - ymsnd.add_route(0, "lspeaker", 0.25); - ymsnd.add_route(0, "rspeaker", 0.25); - ymsnd.add_route(1, "lspeaker", 1.0); - ymsnd.add_route(2, "rspeaker", 1.0); + ymsnd.add_route(0, "speaker", 0.25, 0); + ymsnd.add_route(0, "speaker", 0.25, 1); + ymsnd.add_route(1, "speaker", 1.0, 0); + ymsnd.add_route(2, "speaker", 1.0, 1); } diff --git a/src/mame/vtech/clickstart.cpp b/src/mame/vtech/clickstart.cpp index 16a2f2f3e67..01fa870e0db 100644 --- a/src/mame/vtech/clickstart.cpp +++ b/src/mame/vtech/clickstart.cpp @@ -450,8 +450,8 @@ void clickstart_state::clickstart(machine_config &config) m_maincpu->portc_in().set(FUNC(clickstart_state::portc_r)); m_maincpu->adc_in<0>().set_constant(0x0fff); m_maincpu->chip_select().set(FUNC(clickstart_state::chip_sel_w)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); SCREEN(config, m_screen, SCREEN_TYPE_RASTER); m_screen->set_refresh_hz(60); @@ -460,8 +460,7 @@ void clickstart_state::clickstart(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(spg2xx_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(spg2xx_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "clickstart_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/vtech/socrates_a.cpp b/src/mame/vtech/socrates_a.cpp index 8f5c6dfbfed..4de898a24b8 100644 --- a/src/mame/vtech/socrates_a.cpp +++ b/src/mame/vtech/socrates_a.cpp @@ -51,12 +51,12 @@ void socrates_snd_device::device_start() // sound_stream_update - handle a stream update //------------------------------------------------- -void socrates_snd_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) +void socrates_snd_device::sound_stream_update(sound_stream &stream) { - for (int i = 0; i < outputs[0].samples(); i++) + for (int i = 0; i < stream.samples(); i++) { snd_clock(); - outputs[0].put_int(i, (int)m_DAC_output, 32768 >> 4); + stream.put_int(0, i, (int)m_DAC_output, 32768 >> 4); } } diff --git a/src/mame/vtech/socrates_a.h b/src/mame/vtech/socrates_a.h index 2c041ae3389..eb311eb37fb 100644 --- a/src/mame/vtech/socrates_a.h +++ b/src/mame/vtech/socrates_a.h @@ -22,7 +22,7 @@ protected: virtual void device_start() override ATTR_COLD; // sound stream update overrides - virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; + virtual void sound_stream_update(sound_stream &stream) override; private: void snd_clock(); static const uint8_t s_volumeLUT[]; diff --git a/src/mame/vtech/storio.cpp b/src/mame/vtech/storio.cpp index 07188fae25c..9f5b01c6c4c 100644 --- a/src/mame/vtech/storio.cpp +++ b/src/mame/vtech/storio.cpp @@ -108,8 +108,7 @@ void vtech_storio_state::vtech_storio_base(machine_config &config) m_screen->set_visarea(0, 320-1, 0, 240-1); m_screen->set_screen_update(FUNC(vtech_storio_state::screen_update_storio)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "vtech_storio_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/vtech/vsmile.cpp b/src/mame/vtech/vsmile.cpp index 46e4a2fcd5a..43ac56d5e6b 100644 --- a/src/mame/vtech/vsmile.cpp +++ b/src/mame/vtech/vsmile.cpp @@ -309,8 +309,7 @@ void vsmile_base_state::vsmile_base(machine_config &config) m_screen->set_screen_update("maincpu", FUNC(spg2xx_device::screen_update)); m_screen->screen_vblank().set(m_maincpu, FUNC(spg2xx_device::vblank)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ADDRESS_MAP_BANK(config, m_bankdev); m_bankdev->set_endianness(ENDIANNESS_BIG); @@ -327,8 +326,8 @@ void vsmile_state::vsmile(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &vsmile_state::mem_map); m_maincpu->set_force_no_drc(true); m_maincpu->chip_select().set(FUNC(vsmile_state::chip_sel_w)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 0); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5, 1); m_maincpu->portb_in().set(FUNC(vsmile_state::portb_r)); m_maincpu->portb_out().set(FUNC(vsmile_state::portb_w)); m_maincpu->portc_in().set(FUNC(vsmile_state::portc_r)); diff --git a/src/mame/vtech/vsmileb.cpp b/src/mame/vtech/vsmileb.cpp index 06aa0c5d502..f434c11edc0 100644 --- a/src/mame/vtech/vsmileb.cpp +++ b/src/mame/vtech/vsmileb.cpp @@ -142,8 +142,8 @@ void vsmileb_state::vsmileb(machine_config &config) m_maincpu->set_addrmap(AS_PROGRAM, &vsmileb_state::mem_map); m_maincpu->set_force_no_drc(true); m_maincpu->chip_select().set(FUNC(vsmileb_state::chip_sel_w)); - m_maincpu->add_route(ALL_OUTPUTS, "lspeaker", 0.5); - m_maincpu->add_route(ALL_OUTPUTS, "rspeaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5); + m_maincpu->add_route(ALL_OUTPUTS, "speaker", 0.5); m_maincpu->porta_in().set(FUNC(vsmileb_state::porta_r)); m_maincpu->portb_in().set(FUNC(vsmileb_state::portb_r)); diff --git a/src/mame/vtech/vtech_innotab.cpp b/src/mame/vtech/vtech_innotab.cpp index a9f1bbb6e28..c534b0226f3 100644 --- a/src/mame/vtech/vtech_innotab.cpp +++ b/src/mame/vtech/vtech_innotab.cpp @@ -91,8 +91,7 @@ void vtech_innotab_state::vtech_innotab(machine_config& config) m_screen->set_visarea(0, 320 - 1, 0, 240 - 1); m_screen->set_screen_update(FUNC(vtech_innotab_state::screen_update_innotab)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_CARTSLOT(config, m_cart, generic_plain_slot, "vtech_innotab_cart"); m_cart->set_width(GENERIC_ROM16_WIDTH); diff --git a/src/mame/xerox/notetaker.cpp b/src/mame/xerox/notetaker.cpp index 253ff139294..e35b9b850e0 100644 --- a/src/mame/xerox/notetaker.cpp +++ b/src/mame/xerox/notetaker.cpp @@ -894,10 +894,9 @@ void notetaker_state::notetakr(machine_config &config) FLOPPY_CONNECTOR(config, "wd1791:0", notetaker_floppies, "525dd", floppy_image_device::default_mfm_floppy_formats); /* sound hardware */ - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // TODO: hook DAC up to two HA2425 (sample and hold) chips and hook those up to the speakers - DAC1200(config, m_dac, 0).add_route(ALL_OUTPUTS, "lspeaker", 0.5).add_route(ALL_OUTPUTS, "rspeaker", 0.5); // unknown DAC + DAC1200(config, m_dac, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 0).add_route(ALL_OUTPUTS, "speaker", 0.5, 1); // unknown DAC } void notetaker_state::driver_start() diff --git a/src/mame/yamaha/fb01.cpp b/src/mame/yamaha/fb01.cpp index 4aad62dae3b..52098e4ea26 100644 --- a/src/mame/yamaha/fb01.cpp +++ b/src/mame/yamaha/fb01.cpp @@ -203,12 +203,11 @@ void fb01_state::fb01(machine_config &config) MIDI_PORT(config, "mdthru", midiout_slot, "midiout"); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2164_device &ym2164(YM2164(config, "ym2164", XTAL(4'000'000))); ym2164.irq_handler().set(FUNC(fb01_state::ym2164_irq_w)); - ym2164.add_route(0, "lspeaker", 1.00); - ym2164.add_route(1, "rspeaker", 1.00); + ym2164.add_route(0, "speaker", 1.00, 0); + ym2164.add_route(1, "speaker", 1.00, 1); NVRAM(config, "nvram", nvram_device::DEFAULT_ALL_0); } diff --git a/src/mame/yamaha/tg100.cpp b/src/mame/yamaha/tg100.cpp index 582e91a1b9e..3fbaa244117 100644 --- a/src/mame/yamaha/tg100.cpp +++ b/src/mame/yamaha/tg100.cpp @@ -77,13 +77,12 @@ void tg100_state::tg100(machine_config &config) HD6435208(config, m_maincpu, XTAL(20'000'000)); m_maincpu->set_addrmap(AS_PROGRAM, &tg100_state::tg100_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MULTIPCM(config, m_ymw258, 9400000); m_ymw258->set_addrmap(0, &tg100_state::ymw258_map); - m_ymw258->add_route(0, "lspeaker", 1.0); - m_ymw258->add_route(1, "rspeaker", 1.0); + m_ymw258->add_route(0, "speaker", 1.0, 0); + m_ymw258->add_route(1, "speaker", 1.0, 1); } ROM_START( tg100 ) diff --git a/src/mame/yamaha/yman1x.cpp b/src/mame/yamaha/yman1x.cpp index 0467d8ccf83..e2decac1c59 100644 --- a/src/mame/yamaha/yman1x.cpp +++ b/src/mame/yamaha/yman1x.cpp @@ -62,8 +62,7 @@ void an1x_state::an1x(machine_config &config) MULCD(config, "lcd"); // LC7985ND (back-lit) - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MEG(config, m_meg, 11.2896_MHz_XTAL); } diff --git a/src/mame/yamaha/ymdx100.cpp b/src/mame/yamaha/ymdx100.cpp index 22ed94a1441..9492d8490b9 100644 --- a/src/mame/yamaha/ymdx100.cpp +++ b/src/mame/yamaha/ymdx100.cpp @@ -626,12 +626,11 @@ void yamaha_dx100_state::dx100(machine_config &config) lcdc.set_lcd_size(1, 16); lcdc.set_pixel_update_cb(FUNC(yamaha_dx100_state::lcd_pixel_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2164_device &ymsnd(YM2164(config, "ymsnd", 7.15909_MHz_XTAL / 2)); // with YM3014 DAC - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); CASSETTE(config, m_cassette); m_cassette->set_default_state(CASSETTE_STOPPED); diff --git a/src/mame/yamaha/ymdx11.cpp b/src/mame/yamaha/ymdx11.cpp index bc25dd89870..9dab3c12bb1 100644 --- a/src/mame/yamaha/ymdx11.cpp +++ b/src/mame/yamaha/ymdx11.cpp @@ -117,13 +117,12 @@ void yamaha_dx11_state::dx11(machine_config &config) lcdc.set_lcd_size(2, 16); lcdc.set_pixel_update_cb(FUNC(yamaha_dx11_state::lcd_pixel_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2414_device &opz(YM2414(config, "opz", 3.579545_MHz_XTAL)); //opz.irq_handler().set_inputline(m_maincpu, hd6301y_cpu_device::IRQ2_LINE); // IRQ = P51 - opz.add_route(0, "lspeaker", 0.60); - opz.add_route(1, "rspeaker", 0.60); + opz.add_route(0, "speaker", 0.60, 0); + opz.add_route(1, "speaker", 0.60, 1); } ROM_START(dx11) diff --git a/src/mame/yamaha/ymmu10.cpp b/src/mame/yamaha/ymmu10.cpp index ca9e52d510f..f34b6821587 100644 --- a/src/mame/yamaha/ymmu10.cpp +++ b/src/mame/yamaha/ymmu10.cpp @@ -138,12 +138,11 @@ void mu10_state::mu10(machine_config &config) NVRAM(config, m_nvram, nvram_device::DEFAULT_NONE); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP00(config, m_swp00); - m_swp00->add_route(0, "lspeaker", 1.0); - m_swp00->add_route(1, "rspeaker", 1.0); + m_swp00->add_route(0, "speaker", 1.0, 0); + m_swp00->add_route(1, "speaker", 1.0, 1); auto &mdin(MIDI_PORT(config, "mdin")); midiin_slot(mdin); diff --git a/src/mame/yamaha/ymmu100.cpp b/src/mame/yamaha/ymmu100.cpp index 3debaa5560c..1dc406bc95c 100644 --- a/src/mame/yamaha/ymmu100.cpp +++ b/src/mame/yamaha/ymmu100.cpp @@ -479,13 +479,12 @@ void mu100_state::mu100b(machine_config &config) PLG1X0_CONNECTOR(config, m_ext1, plg1x0_intf, nullptr); m_ext1->midi_tx().set(FUNC(mu100_state::e1_tx)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP30(config, m_swp30); m_swp30->set_addrmap(AS_DATA, &mu100_state::swp30_map); - m_swp30->add_route(0, "lspeaker", 1.0); - m_swp30->add_route(1, "rspeaker", 1.0); + m_swp30->add_route(0, "speaker", 1.0, 0); + m_swp30->add_route(1, "speaker", 1.0, 1); auto &mdin_a(MIDI_PORT(config, "mdin_a")); midiin_slot(mdin_a); diff --git a/src/mame/yamaha/ymmu128.cpp b/src/mame/yamaha/ymmu128.cpp index 849d06e9ff2..a8ae8340a0a 100644 --- a/src/mame/yamaha/ymmu128.cpp +++ b/src/mame/yamaha/ymmu128.cpp @@ -186,18 +186,17 @@ void mu128_state::mu128(machine_config &config) MULCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP30(config, m_swp30m); m_swp30m->set_addrmap(AS_DATA, &mu128_state::swp30_map); - m_swp30m->add_route(0, "lspeaker", 1.0); - m_swp30m->add_route(1, "rspeaker", 1.0); + m_swp30m->add_route(0, "speaker", 1.0, 0); + m_swp30m->add_route(1, "speaker", 1.0, 1); SWP30(config, m_swp30s); m_swp30s->set_addrmap(AS_DATA, &mu128_state::swp30_map); - m_swp30s->add_route(0, "lspeaker", 1.0); - m_swp30s->add_route(1, "rspeaker", 1.0); + m_swp30s->add_route(0, "speaker", 1.0, 0); + m_swp30s->add_route(1, "speaker", 1.0, 1); INPUT_MERGER_ANY_HIGH(config, "irq0").output_handler().set_inputline(m_maincpu, 0); I8251(config, m_sci, 10_MHz_XTAL); // uPD71051GU-10 diff --git a/src/mame/yamaha/ymmu15.cpp b/src/mame/yamaha/ymmu15.cpp index 9df5655bc78..eb35768cc9d 100644 --- a/src/mame/yamaha/ymmu15.cpp +++ b/src/mame/yamaha/ymmu15.cpp @@ -176,8 +176,8 @@ void mu15_state::mu15(machine_config &config) m_maincpu->set_addrmap(swx00_device::AS_C, &mu15_state::c_map); m_maincpu->set_addrmap(swx00_device::AS_S, &mu15_state::s_map); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); // Nothing connected to sclki, yet... m_maincpu->sci_set_external_clock_period(0, attotime::from_hz(500000)); @@ -197,8 +197,7 @@ void mu15_state::mu15(machine_config &config) MU5LCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); // sci0 goes to the host connector diff --git a/src/mame/yamaha/ymmu2000.cpp b/src/mame/yamaha/ymmu2000.cpp index 29c7d9ee809..4ef450f7940 100644 --- a/src/mame/yamaha/ymmu2000.cpp +++ b/src/mame/yamaha/ymmu2000.cpp @@ -348,13 +348,12 @@ void mu500_state::mu500(machine_config &config) MULCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP30(config, m_swp30m); m_swp30m->set_addrmap(AS_DATA, &mu500_state::swp30_map); - m_swp30m->add_route(0, "lspeaker", 1.0); - m_swp30m->add_route(1, "rspeaker", 1.0); + m_swp30m->add_route(0, "speaker", 1.0, 0); + m_swp30m->add_route(1, "speaker", 1.0, 1); auto &mdin_a(MIDI_PORT(config, "mdin_a")); midiin_slot(mdin_a); @@ -390,8 +389,8 @@ void mu1000_state::mu1000(machine_config &config) SWP30(config, m_swp30s); m_swp30s->set_addrmap(AS_DATA, &mu1000_state::swp30_map); - m_swp30s->add_route(0, "lspeaker", 1.0); - m_swp30s->add_route(1, "rspeaker", 1.0); + m_swp30s->add_route(0, "speaker", 1.0, 0); + m_swp30s->add_route(1, "speaker", 1.0, 1); } void mu2000_state::mu2000(machine_config &config) diff --git a/src/mame/yamaha/ymmu5.cpp b/src/mame/yamaha/ymmu5.cpp index 7d9251ee176..62ef0795a6e 100644 --- a/src/mame/yamaha/ymmu5.cpp +++ b/src/mame/yamaha/ymmu5.cpp @@ -204,13 +204,12 @@ void mu5_state::mu5(machine_config &config) MU5LCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MULTIPCM(config, m_ymw258, 9.4_MHz_XTAL); // clock verified by schematics m_ymw258->set_addrmap(0, &mu5_state::ymw258_map); - m_ymw258->add_route(0, "lspeaker", 1.0); - m_ymw258->add_route(1, "rspeaker", 1.0); + m_ymw258->add_route(0, "speaker", 1.0, 0); + m_ymw258->add_route(1, "speaker", 1.0, 1); MIDI_PORT(config, "mdin", midiin_slot, "midiin").rxd_handler().set(m_maincpu, FUNC(h83002_device::sci_rx_w<1>)); diff --git a/src/mame/yamaha/ymmu50.cpp b/src/mame/yamaha/ymmu50.cpp index 2b4c47f7dc8..032952a8026 100644 --- a/src/mame/yamaha/ymmu50.cpp +++ b/src/mame/yamaha/ymmu50.cpp @@ -21,6 +21,7 @@ #include "bus/midi/midioutport.h" #include "cpu/h8/h83003.h" #include "machine/nvram.h" +#include "sound/adc.h" #include "sound/swp00.h" #include "mulcd.h" @@ -70,6 +71,8 @@ public: , m_ioport_o1(*this, "O1") , m_ioport_o2(*this, "O2") , m_ram(*this, "ram") + , m_ad(*this, "ad") + , m_adc(*this, "adc%u", 0U) { } void mu50(machine_config &config); @@ -89,6 +92,8 @@ private: required_ioport m_ioport_o1; required_ioport m_ioport_o2; required_shared_ptr<u16> m_ram; + required_device<microphone_device> m_ad; + required_device_array<adc10_device, 2> m_adc; u8 cur_p6, cur_p9, cur_pa, cur_pb, cur_pc; @@ -135,13 +140,19 @@ void mu50_state::mu50_map(address_map &map) // Analog input right (not sent to the swp, mixing is analog) u16 mu50_state::adc_ar_r() { - return 0x3ff; + s16 v = m_adc[0]->read(); + if(v < 0) + v = -v; + return 0x3ff - v; } // Analog input left (not sent to the swp, mixing is analog) u16 mu50_state::adc_al_r() { - return 0x3ff; + s16 v = m_adc[1]->read(); + if(v < 0) + v = -v; + return 0x3ff - v; } // Put the host switch to pure midi @@ -269,12 +280,20 @@ void mu50_state::mu50(machine_config &config) MULCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + MICROPHONE(config, m_ad, 2).front(); + m_ad->add_route(0, "speakers", 1.0, 0); + m_ad->add_route(1, "speakers", 1.0, 1); + m_ad->add_route(0, "adc0", 1.0); + m_ad->add_route(1, "adc1", 1.0); + + ADC10(config, m_adc[0]); + ADC10(config, m_adc[1]); + + SPEAKER(config, "speakers", 2).front(); SWP00(config, m_swp00); - m_swp00->add_route(0, "lspeaker", 1.0); - m_swp00->add_route(1, "rspeaker", 1.0); + m_swp00->add_route(0, "speakers", 1.0, 0); + m_swp00->add_route(1, "speakers", 1.0, 1); auto &mdin(MIDI_PORT(config, "mdin")); midiin_slot(mdin); diff --git a/src/mame/yamaha/ymmu80.cpp b/src/mame/yamaha/ymmu80.cpp index 4ba4aa3a5ac..24f1b4397d3 100644 --- a/src/mame/yamaha/ymmu80.cpp +++ b/src/mame/yamaha/ymmu80.cpp @@ -339,18 +339,17 @@ void mu80_state::mu80(machine_config &config) MULCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP20(config, m_swp20_0); m_swp20_0->set_device_rom_tag("swp20"); - m_swp20_0->add_route(0, "lspeaker", 1.0); - m_swp20_0->add_route(1, "rspeaker", 1.0); + m_swp20_0->add_route(0, "speaker", 1.0, 0); + m_swp20_0->add_route(1, "speaker", 1.0, 1); SWP20(config, m_swp20_1); m_swp20_1->set_device_rom_tag("swp20"); - m_swp20_1->add_route(0, "lspeaker", 1.0); - m_swp20_1->add_route(1, "rspeaker", 1.0); + m_swp20_1->add_route(0, "speaker", 1.0, 0); + m_swp20_1->add_route(1, "speaker", 1.0, 1); MEG(config, m_meg); diff --git a/src/mame/yamaha/ymmu90.cpp b/src/mame/yamaha/ymmu90.cpp index ee4b2e7c950..8b125c9cf4c 100644 --- a/src/mame/yamaha/ymmu90.cpp +++ b/src/mame/yamaha/ymmu90.cpp @@ -213,13 +213,12 @@ void mu90_state::mu90b(machine_config &config) m_maincpu->read_portb().set(FUNC(mu90_state::pb_r)); m_maincpu->write_portb().set(FUNC(mu90_state::pb_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); SWP30(config, m_swp30); m_swp30->set_addrmap(AS_DATA, &mu90_state::swp30_map); - m_swp30->add_route(0, "lspeaker", 1.0); - m_swp30->add_route(1, "rspeaker", 1.0); + m_swp30->add_route(0, "speaker", 1.0, 0); + m_swp30->add_route(1, "speaker", 1.0, 1); auto &mdin_a(MIDI_PORT(config, "mdin_a")); midiin_slot(mdin_a); diff --git a/src/mame/yamaha/ympsr150.cpp b/src/mame/yamaha/ympsr150.cpp index a462949a14a..6796bbf0927 100644 --- a/src/mame/yamaha/ympsr150.cpp +++ b/src/mame/yamaha/ympsr150.cpp @@ -245,11 +245,10 @@ void psr150_state::psr150(machine_config &config) // set up AC filters since the keyboard purposely outputs a DC offset when idle // TODO: there is also a RLC lowpass with R=120, L=3.3mH, C=0.33uF (or R=150 for psr110) - FILTER_RC(config, "lfilter").set_ac().add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_RC(config, "rfilter").set_ac().add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_RC(config, "lfilter").set_ac().add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_RC(config, "rfilter").set_ac().add_route(ALL_OUTPUTS, "speaker", 1.0, 1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.set_default_layout(layout_psr150); } @@ -362,11 +361,10 @@ void psr150_state::psr180(machine_config &config) // set up AC filters since the keyboard purposely outputs a DC offset when idle // TODO: there is also a RLC lowpass with R=120, L=3.3mH, C=0.39uF - FILTER_RC(config, "lfilter").set_ac().add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_RC(config, "rfilter").set_ac().add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_RC(config, "lfilter").set_ac().add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_RC(config, "rfilter").set_ac().add_route(ALL_OUTPUTS, "speaker", 1.0, 1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); config.set_default_layout(layout_psr180); } @@ -448,11 +446,10 @@ void psr150_state::psr190(machine_config &config) // set up AC filters since the keyboard purposely outputs a DC offset when idle // TODO: there is also a RLC lowpass with R=120, L=3.3mH, C=0.33uF - FILTER_RC(config, "lfilter").set_ac().add_route(ALL_OUTPUTS, "lspeaker", 1.0); - FILTER_RC(config, "rfilter").set_ac().add_route(ALL_OUTPUTS, "rspeaker", 1.0); + FILTER_RC(config, "lfilter").set_ac().add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + FILTER_RC(config, "rfilter").set_ac().add_route(ALL_OUTPUTS, "speaker", 1.0, 1); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void psr150_state::psr78(machine_config &config) diff --git a/src/mame/yamaha/ympsr2000.cpp b/src/mame/yamaha/ympsr2000.cpp index 3c15b9273b3..c009a8fec9e 100644 --- a/src/mame/yamaha/ympsr2000.cpp +++ b/src/mame/yamaha/ympsr2000.cpp @@ -58,8 +58,7 @@ void psr2000_state::psr2000(machine_config &config) m_lcdc->set_screen("screen"); m_lcdc->set_addrmap(0, &psr2000_state::lcdc_map); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } void psr2000_state::map(address_map &map) diff --git a/src/mame/yamaha/ympsr340.cpp b/src/mame/yamaha/ympsr340.cpp index d24c3cd6580..6cb11563dcf 100644 --- a/src/mame/yamaha/ympsr340.cpp +++ b/src/mame/yamaha/ympsr340.cpp @@ -219,8 +219,8 @@ void psr340_state::psr340(machine_config &config) m_maincpu->read_pad().set(FUNC(psr340_state::pad_r)); m_maincpu->write_txd().set(FUNC(psr340_state::txd_w)); - m_maincpu->add_route(0, "lspeaker", 1.0); - m_maincpu->add_route(1, "rspeaker", 1.0); + m_maincpu->add_route(0, "speaker", 1.0, 0); + m_maincpu->add_route(1, "speaker", 1.0, 1); // mks3 is connected to sclki, sync comms on sci1 // something generates 500K for sci0, probably internal to the swx00 @@ -248,8 +248,7 @@ void psr340_state::psr340(machine_config &config) auto &mdout(MIDI_PORT(config, "mdout", midiout_slot, "midiout")); m_maincpu->write_sci_tx<0>().set(mdout, FUNC(midi_port_device::write_txd)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); } ROM_START( psr340 ) diff --git a/src/mame/yamaha/ympsr400.cpp b/src/mame/yamaha/ympsr400.cpp index 05a477ccc8c..d01c3d706c7 100644 --- a/src/mame/yamaha/ympsr400.cpp +++ b/src/mame/yamaha/ympsr400.cpp @@ -97,12 +97,11 @@ void psr400_state::psr500(machine_config &config) HD6305V0(config, m_mpscpu, 8_MHz_XTAL).set_disable(); // HD63B05V0D73P (mislabeled HD63B50 on schematic) - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); multipcm_device &gew8(MULTIPCM(config, "gew8", 9.4_MHz_XTAL)); // YMW-258-F - gew8.add_route(1, "lspeaker", 1.0); - gew8.add_route(0, "rspeaker", 1.0); + gew8.add_route(1, "speaker", 1.0, 0); + gew8.add_route(0, "speaker", 1.0, 1); //YM3413(config, "ldsp"); // PSR-500 only (has its own 256K-bit PSRAM) } diff --git a/src/mame/yamaha/ympsr540.cpp b/src/mame/yamaha/ympsr540.cpp index 5b5a2b31e36..ff3ec5f94a3 100644 --- a/src/mame/yamaha/ympsr540.cpp +++ b/src/mame/yamaha/ympsr540.cpp @@ -135,8 +135,8 @@ void psr540_state::psr540(machine_config &config) m_maincpu->read_portf().set(FUNC(psr540_state::pf_r)); SWX00_SOUND(config, m_swx00); - m_swx00->add_route(0, "lspeaker", 1.0); - m_swx00->add_route(1, "rspeaker", 1.0); + m_swx00->add_route(0, "speaker", 1.0, 0); + m_swx00->add_route(1, "speaker", 1.0, 1); MKS3(config, m_mks3); m_mks3->write_da().set(m_maincpu, FUNC(sh7042_device::sci_rx_w<1>)); @@ -164,8 +164,7 @@ void psr540_state::psr540(machine_config &config) screen.set_visarea_full(); screen.screen_vblank().set(FUNC(psr540_state::render_w)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); auto &mdin(MIDI_PORT(config, "mdin")); midiin_slot(mdin); diff --git a/src/mame/yamaha/ympsr60.cpp b/src/mame/yamaha/ympsr60.cpp index 6fda630242e..9ee89f86d1b 100644 --- a/src/mame/yamaha/ympsr60.cpp +++ b/src/mame/yamaha/ympsr60.cpp @@ -144,7 +144,10 @@ private: void ppi_pc_w(u8 data); void recalc_irqs(); - attoseconds_t cv_handler(attotime const &curtime); + TIMER_CALLBACK_MEMBER(bbd_tick); + void bbd_setup_next_tick(); + + emu_timer *m_bbd_timer; int m_acia_irq, m_ym_irq, m_drvif_irq, m_ym2154_irq; u16 m_keyboard_select; @@ -227,9 +230,15 @@ void psr60_state::ryp4_out_w(u8 data) // modulation, which we simulate in a periodic timer } -attoseconds_t psr60_state::cv_handler(attotime const &cvtime) +TIMER_CALLBACK_MEMBER(psr60_state::bbd_tick) { - attotime curtime = cvtime; + m_bbd->tick(); + bbd_setup_next_tick(); +} + +void psr60_state::bbd_setup_next_tick() +{ + attotime curtime = machine().time(); // only two states have been observed to be measured: CT1=1/CT2=0 and CT1=0/CT2=1 double bbd_freq; @@ -252,7 +261,7 @@ attoseconds_t psr60_state::cv_handler(attotime const &cvtime) } // BBD driver provides two out-of-phase clocks to basically run the BBD at 2x - return HZ_TO_ATTOSECONDS(bbd_freq * 2); + m_bbd_timer->adjust(attotime::from_ticks(1, bbd_freq * 2)); } // @@ -313,6 +322,8 @@ void psr60_state::recalc_irqs() void psr60_state::machine_start() { + m_bbd_timer = timer_alloc(FUNC(psr60_state::bbd_tick), this); + m_drvif_out.resolve(); m_rom2bank->configure_entries(0, 2, memregion("rom2")->base(), 0x4000); m_rom2bank->set_entry(0); @@ -324,6 +335,7 @@ void psr60_state::machine_start() void psr60_state::machine_reset() { + bbd_setup_next_tick(); } #define DRVIF_PORT(num, sw1, sw2, sw3, sw4) \ @@ -628,14 +640,13 @@ void psr60_state::psr_common(machine_config &config) clock_device &acia_clock(CLOCK(config, "acia_clock", 500_kHz_XTAL)); // 31250 * 16 = 500,000 acia_clock.signal_handler().set(FUNC(psr60_state::write_acia_clock)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); MIXER(config, m_lmixer); - m_lmixer->add_route(0, "lspeaker", 1.0); + m_lmixer->add_route(0, "speaker", 1.0, 0); MIXER(config, m_rmixer); - m_rmixer->add_route(0, "rspeaker", 1.0); + m_rmixer->add_route(0, "speaker", 1.0, 1); // begin BBD filter chain.... // thanks to Lord Nightmare for figuring this out @@ -660,8 +671,7 @@ void psr60_state::psr_common(machine_config &config) MIXER(config, m_bbd_mixer); m_bbd_mixer->add_route(0, m_postbbd_rc, 1.0); - MN3204P(config, m_bbd, 50000); - m_bbd->set_cv_handler(FUNC(psr60_state::cv_handler)); + MN3204P(config, m_bbd); m_bbd->add_route(0, m_bbd_mixer, 0.5); m_bbd->add_route(1, m_bbd_mixer, 0.5); diff --git a/src/mame/yamaha/ymqs300.cpp b/src/mame/yamaha/ymqs300.cpp index af5318aa70c..b86bb7220b2 100644 --- a/src/mame/yamaha/ymqs300.cpp +++ b/src/mame/yamaha/ymqs300.cpp @@ -214,8 +214,8 @@ void qs300_state::qs300(machine_config &config) m_subcpu->read_porta().set(FUNC(qs300_state::spa_r)); SWP00(config, m_swp00); - m_swp00->add_route(0, "lspeaker", 1.0); - m_swp00->add_route(1, "rspeaker", 1.0); + m_swp00->add_route(0, "speaker", 1.0, 0); + m_swp00->add_route(1, "speaker", 1.0, 1); T6963C(config, m_lcdc, 270000); m_lcdc->set_addrmap(0, &qs300_state::lcdmap); @@ -233,8 +233,7 @@ void qs300_state::qs300(machine_config &config) NVRAM(config, m_nvram, nvram_device::DEFAULT_NONE); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); auto &mdin(MIDI_PORT(config, "mdin")); midiin_slot(mdin); diff --git a/src/mame/yamaha/ymqy70.cpp b/src/mame/yamaha/ymqy70.cpp index 85b434e0943..fc4c8b5220f 100644 --- a/src/mame/yamaha/ymqy70.cpp +++ b/src/mame/yamaha/ymqy70.cpp @@ -180,8 +180,7 @@ void qy70_state::qy70(machine_config &config) PALETTE(config, "palette", FUNC(qy70_state::lcd_palette), 2); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); auto &mdin_a(MIDI_PORT(config, "mdin_a")); midiin_slot(mdin_a); diff --git a/src/mame/yamaha/ymrx15.cpp b/src/mame/yamaha/ymrx15.cpp index a370bc48efe..512999258a2 100644 --- a/src/mame/yamaha/ymrx15.cpp +++ b/src/mame/yamaha/ymrx15.cpp @@ -79,12 +79,11 @@ void rx15_state::rx15(machine_config &config) lcdc.set_lcd_size(2, 8); lcdc.set_pixel_update_cb(FUNC(rx15_state::pixel_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); YM2154(config, m_ryp4, 2.7_MHz_XTAL); - m_ryp4->add_route(0, "lspeaker", 0.50); - m_ryp4->add_route(1, "rspeaker", 0.50); + m_ryp4->add_route(0, "speaker", 0.50, 0); + m_ryp4->add_route(1, "speaker", 0.50, 1); } ROM_START(rx15) diff --git a/src/mame/yamaha/ymtx81z.cpp b/src/mame/yamaha/ymtx81z.cpp index a164ebada95..46733fb808c 100644 --- a/src/mame/yamaha/ymtx81z.cpp +++ b/src/mame/yamaha/ymtx81z.cpp @@ -157,13 +157,12 @@ void ymtx81z_state::tx81z(machine_config &config) lcdc.set_lcd_size(2, 16); lcdc.set_pixel_update_cb(FUNC(ymtx81z_state::lcd_pixel_update)); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); ym2414_device &ymsnd(YM2414(config, "ymsnd", 7.15909_MHz_XTAL / 2)); ymsnd.irq_handler().set_inputline(m_maincpu, HD6301_IRQ1_LINE); - ymsnd.add_route(0, "lspeaker", 0.60); - ymsnd.add_route(1, "rspeaker", 0.60); + ymsnd.add_route(0, "speaker", 0.60, 0); + ymsnd.add_route(1, "speaker", 0.60, 1); } ROM_START(tx81z) diff --git a/src/mame/yamaha/ymvl70.cpp b/src/mame/yamaha/ymvl70.cpp index c16717ae755..b8c77078008 100644 --- a/src/mame/yamaha/ymvl70.cpp +++ b/src/mame/yamaha/ymvl70.cpp @@ -199,8 +199,7 @@ void vl70_state::vl70(machine_config &config) MULCD(config, m_lcd); - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); DSPV(config, m_dspv); MEG(config, m_meg); diff --git a/src/mame/yunsung/yunsun16.cpp b/src/mame/yunsung/yunsun16.cpp index 344381eb9ef..93e74dc59d5 100644 --- a/src/mame/yunsung/yunsun16.cpp +++ b/src/mame/yunsung/yunsun16.cpp @@ -918,19 +918,18 @@ void magicbub_state::magicbub(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 8192); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, m_soundlatch); ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(16'000'000) / 4)); ymsnd.irq_handler().set_inputline("audiocpu", 0); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 0.80); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 0.80); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 0.80, 1); okim6295_device &oki(OKIM6295(config, "oki", XTAL(16'000'000) / 16, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 0.80); - oki.add_route(ALL_OUTPUTS, "rspeaker", 0.80); + oki.add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } @@ -955,12 +954,11 @@ void shocking_state::shocking(machine_config &config) PALETTE(config, m_palette).set_format(palette_device::xRGB_555, 8192); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); okim6295_device &oki(OKIM6295(config, "oki", XTAL(16'000'000) / 16, okim6295_device::PIN7_HIGH)); - oki.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - oki.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + oki.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); oki.set_addrmap(0, &shocking_state::oki_map); } diff --git a/src/mame/yunsung/yunsung8.cpp b/src/mame/yunsung/yunsung8.cpp index e2168cc0926..be17279320f 100644 --- a/src/mame/yunsung/yunsung8.cpp +++ b/src/mame/yunsung/yunsung8.cpp @@ -603,14 +603,13 @@ void yunsung8_state::yunsung8(machine_config &config) PALETTE(config, m_palette).set_entries(2048); // sound hardware - SPEAKER(config, "lspeaker").front_left(); - SPEAKER(config, "rspeaker").front_right(); + SPEAKER(config, "speaker", 2).front(); GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, 0); ym3812_device &ymsnd(YM3812(config, "ymsnd", XTAL(16'000'000) / 4)); - ymsnd.add_route(ALL_OUTPUTS, "lspeaker", 1.0); - ymsnd.add_route(ALL_OUTPUTS, "rspeaker", 1.0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 0); + ymsnd.add_route(ALL_OUTPUTS, "speaker", 1.0, 1); LS157(config, m_adpcm_select, 0); m_adpcm_select->out_callback().set("msm", FUNC(msm5205_device::data_w)); @@ -618,8 +617,8 @@ void yunsung8_state::yunsung8(machine_config &config) MSM5205(config, m_msm, XTAL(400'000)); // verified on PCB m_msm->vck_legacy_callback().set(FUNC(yunsung8_state::adpcm_int)); // interrupt function m_msm->set_prescaler_selector(msm5205_device::S96_4B); // 4KHz, 4 Bits - m_msm->add_route(ALL_OUTPUTS, "lspeaker", 0.80); - m_msm->add_route(ALL_OUTPUTS, "rspeaker", 0.80); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 0); + m_msm->add_route(ALL_OUTPUTS, "speaker", 0.80, 1); } diff --git a/src/mame/zaccaria/zaccaria_a.cpp b/src/mame/zaccaria/zaccaria_a.cpp index 5bde9725b95..44b48a257f7 100644 --- a/src/mame/zaccaria/zaccaria_a.cpp +++ b/src/mame/zaccaria/zaccaria_a.cpp @@ -179,7 +179,7 @@ zac1b111xx_melody_base::zac1b111xx_melody_base( device_t *owner, u32 clock) : device_t(mconfig, devtype, tag, owner, clock) - , device_mixer_interface(mconfig, *this, 1) + , device_mixer_interface(mconfig, *this) , m_melodycpu(*this, "melodycpu") , m_melodypia(*this, "melodypia") , m_melodypsg1(*this, "melodypsg1") @@ -314,10 +314,10 @@ void zac1b11107_audio_device::device_add_mconfig(machine_config &config) m_melodycpu->set_addrmap(AS_PROGRAM, &zac1b11107_audio_device::zac1b11107_melody_map); m_melodypsg1->port_a_write_callback().set(FUNC(zac1b11107_audio_device::melodypsg1_porta_w)); - m_melodypsg1->add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); + m_melodypsg1->add_route(ALL_OUTPUTS, *this, 0.5, 0); m_melodypsg2->port_a_write_callback().set(FUNC(zac1b11107_audio_device::melodypsg2_porta_w)); - m_melodypsg2->add_route(ALL_OUTPUTS, *this, 0.5, AUTO_ALLOC_INPUT, 0); + m_melodypsg2->add_route(ALL_OUTPUTS, *this, 0.5, 0); } @@ -435,7 +435,7 @@ void zac1b11142_audio_device::device_add_mconfig(machine_config &config) m_pia_1i->writepa_handler().set(m_speech, FUNC(tms5220_device::data_w)); m_pia_1i->writepb_handler().set(FUNC(zac1b11142_audio_device::pia_1i_portb_w)); - //MC1408(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 0.30, AUTO_ALLOC_INPUT, 0); // mc1408.1f + //MC1408(config, "dac", 0).add_route(ALL_OUTPUTS, *this, 0.30, 0); // mc1408.1f MC1408(config, "dac").add_route(ALL_OUTPUTS, "sound_nl", 1.0, 7); // mc1408.1f // There is no xtal, the clock is obtained from a RC oscillator as shown in the TMS5220 datasheet (R=100kOhm C=22pF) @@ -447,7 +447,7 @@ void zac1b11142_audio_device::device_add_mconfig(machine_config &config) NETLIST_SOUND(config, "sound_nl", 48000) .set_source(netlist_zac1b11142) - .add_route(ALL_OUTPUTS, *this, 1.0, AUTO_ALLOC_INPUT, 0); + .add_route(ALL_OUTPUTS, *this, 1.0, 0); NETLIST_LOGIC_INPUT(config, "sound_nl:ioa0", "I_IOA0.IN", 0); NETLIST_LOGIC_INPUT(config, "sound_nl:ioa1", "I_IOA1.IN", 0); diff --git a/src/osd/interface/audio.h b/src/osd/interface/audio.h new file mode 100644 index 00000000000..081a4a9353b --- /dev/null +++ b/src/osd/interface/audio.h @@ -0,0 +1,53 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +#ifndef MAME_OSD_INTERFACE_AUDIO_H +#define MAME_OSD_INTERFACE_AUDIO_H + +#pragma once + +#include <string> +#include <array> +#include <vector> +#include <math.h> + +namespace osd { + +struct audio_rate_range { + uint32_t m_default_rate; + uint32_t m_min_rate; + uint32_t m_max_rate; +}; + +struct audio_info { + struct node_info { + std::string m_name; + uint32_t m_id; + audio_rate_range m_rate; + std::vector<std::string> m_port_names; + std::vector<std::array<double, 3>> m_port_positions; + uint32_t m_sinks; + uint32_t m_sources; + + std::string name() const { return (m_sinks ? "o:" : "i:") + m_name; } + }; + + struct stream_info { + uint32_t m_id; + uint32_t m_node; + std::vector<float> m_volumes; + }; + + uint32_t m_generation; + uint32_t m_default_sink; + uint32_t m_default_source; + std::vector<node_info> m_nodes; + std::vector<stream_info> m_streams; +}; + +static inline float db_to_linear(float db) { return db <= -96 ? 0.0 : pow(10, db/20); } +static inline float linear_to_db(float linear) { return linear <= 1/65536.0 ? -96 : 20*log10(linear); } +static inline int linear_to_db_int(float linear) { return linear <= 1/65536.0 ? -96 : int(floor(20*log10(linear) + 0.5)); } +} + +#endif diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index e3c8d63b0d6..b73327b6862 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -270,6 +270,9 @@ void osd_common_t::register_options() #ifndef NO_USE_PULSEAUDIO REGISTER_MODULE(m_mod_man, SOUND_PULSEAUDIO); #endif +#ifndef NO_USE_PIPEWIRE + REGISTER_MODULE(m_mod_man, SOUND_PIPEWIRE); +#endif REGISTER_MODULE(m_mod_man, SOUND_NONE); REGISTER_MODULE(m_mod_man, MONITOR_SDL); @@ -505,39 +508,58 @@ void osd_common_t::debugger_update() } -//------------------------------------------------- -// update_audio_stream - update the stereo audio -// stream -//------------------------------------------------- +bool osd_common_t::sound_external_per_channel_volume() +{ + return m_sound->external_per_channel_volume(); +} -void osd_common_t::update_audio_stream(const int16_t *buffer, int samples_this_frame) +bool osd_common_t::sound_split_streams_per_source() { - // - // This method is called whenever the system has new audio data to stream. - // It provides an array of stereo samples in L-R order which should be - // output at the configured sample_rate. - // - m_sound->update_audio_stream(m_machine->video().throttled(), buffer,samples_this_frame); + return m_sound->split_streams_per_source(); } +uint32_t osd_common_t::sound_get_generation() +{ + return m_sound->get_generation(); +} -//------------------------------------------------- -// set_mastervolume - set the system volume -//------------------------------------------------- +osd::audio_info osd_common_t::sound_get_information() +{ + return m_sound->get_information(); +} -void osd_common_t::set_mastervolume(int attenuation) +uint32_t osd_common_t::sound_stream_sink_open(uint32_t node, std::string name, uint32_t rate) { - // - // Attenuation is the attenuation in dB (a negative number). - // To convert from dB to a linear volume scale do the following: - // volume = MAX_VOLUME; - // while (attenuation++ < 0) - // volume /= 1.122018454; // = (10 ^ (1/20)) = 1dB - // - if (m_sound != nullptr) - m_sound->set_mastervolume(attenuation); + return m_sound->stream_sink_open(node, name, rate); +} + +uint32_t osd_common_t::sound_stream_source_open(uint32_t node, std::string name, uint32_t rate) +{ + return m_sound->stream_source_open(node, name, rate); +} + +void osd_common_t::sound_stream_set_volumes(uint32_t id, const std::vector<float> &db) +{ + m_sound->stream_set_volumes(id, db); +} + +void osd_common_t::sound_stream_close(uint32_t id) +{ + m_sound->stream_close(id); } +void osd_common_t::sound_stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) +{ + m_sound->stream_sink_update(id, buffer, samples_this_frame); +} + +void osd_common_t::sound_stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) +{ + m_sound->stream_source_update(id, buffer, samples_this_frame); +} + + + //------------------------------------------------- // customize_input_type_list - provide OSD diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index 820fe3edf21..04e4ddf70bc 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -223,9 +223,17 @@ public: virtual void wait_for_debugger(device_t &device, bool firststop) override; // audio overridables - virtual void update_audio_stream(const int16_t *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; virtual bool no_sound() override; + virtual bool sound_external_per_channel_volume() override; + virtual bool sound_split_streams_per_source() override; + virtual uint32_t sound_get_generation() override; + virtual osd::audio_info sound_get_information() override; + virtual uint32_t sound_stream_sink_open(uint32_t node, std::string name, uint32_t rate) override; + virtual uint32_t sound_stream_source_open(uint32_t node, std::string name, uint32_t rate) override; + virtual void sound_stream_set_volumes(uint32_t id, const std::vector<float> &db) override; + virtual void sound_stream_close(uint32_t id) override; + virtual void sound_stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) override; + virtual void sound_stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) override; // input overridables virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) override; diff --git a/src/osd/modules/render/aviwrite.cpp b/src/osd/modules/render/aviwrite.cpp index e86d8f99ba6..e758d467e37 100644 --- a/src/osd/modules/render/aviwrite.cpp +++ b/src/osd/modules/render/aviwrite.cpp @@ -72,7 +72,7 @@ void avi_write::begin_avi_recording(std::string_view name) info.audio_timescale = m_machine.sample_rate(); info.audio_sampletime = 1; info.audio_numsamples = 0; - info.audio_channels = 2; + info.audio_channels = m_machine.sound().outputs_count(); info.audio_samplebits = 16; info.audio_samplerate = m_machine.sample_rate(); @@ -142,9 +142,10 @@ void avi_write::audio_frame(const int16_t *buffer, int samples_this_frame) if (m_output_file != nullptr) { // write the next frame - avi_file::error avierr = m_output_file->append_sound_samples(0, buffer + 0, samples_this_frame, 1); - if (avierr == avi_file::error::NONE) - avierr = m_output_file->append_sound_samples(1, buffer + 1, samples_this_frame, 1); + int channels = m_machine.sound().outputs_count(); + avi_file::error avierr = avi_file::error::NONE; + for (int channel = 0; channel != channels && avierr == avi_file::error::NONE; channel ++) + avierr = m_output_file->append_sound_samples(channel, buffer + channel, samples_this_frame, channels-1); if (avierr != avi_file::error::NONE) { osd_printf_error("Error while logging AVI audio frame: %s\n", avi_file::error_string(avierr)); diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp index 3e5de546bcf..7e9814af117 100644 --- a/src/osd/modules/sound/coreaudio_sound.cpp +++ b/src/osd/modules/sound/coreaudio_sound.cpp @@ -46,7 +46,6 @@ public: m_playpos(0), m_writepos(0), m_in_underrun(false), - m_scale(128), m_overflows(0), m_underflows(0) { @@ -60,8 +59,7 @@ public: // sound_module - virtual void update_audio_stream(bool is_throttled, int16_t const *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; + virtual void stream_sink_update(uint32_t, int16_t const *buffer, int samples_this_frame) override; private: struct node_detail @@ -83,14 +81,6 @@ private: uint32_t buffer_avail() const { return ((m_writepos >= m_playpos) ? m_buffer_size : 0) + m_playpos - m_writepos; } uint32_t buffer_used() const { return ((m_playpos > m_writepos) ? m_buffer_size : 0) + m_writepos - m_playpos; } - void copy_scaled(void *dst, void const *src, uint32_t bytes) const - { - bytes /= sizeof(int16_t); - int16_t const *s = (int16_t const *)src; - for (int16_t *d = (int16_t *)dst; bytes > 0; bytes--, s++, d++) - *d = (*s * m_scale) >> 7; - } - bool create_graph(osd_options const &options); bool add_output(char const *name); bool add_device_output(char const *name); @@ -178,7 +168,6 @@ private: uint32_t m_playpos; uint32_t m_writepos; bool m_in_underrun; - int32_t m_scale; unsigned m_overflows; unsigned m_underflows; }; @@ -240,7 +229,6 @@ int sound_coreaudio::init(osd_interface &osd, const osd_options &options) m_playpos = 0; m_writepos = m_headroom; m_in_underrun = false; - m_scale = 128; m_overflows = m_underflows = 0; // Initialise and start @@ -290,7 +278,7 @@ void sound_coreaudio::exit() } -void sound_coreaudio::update_audio_stream(bool is_throttled, int16_t const *buffer, int samples_this_frame) +void sound_coreaudio::stream_sink_update(uint32_t, int16_t const *buffer, int samples_this_frame) { if ((m_sample_rate == 0) || !m_buffer) return; @@ -318,13 +306,6 @@ void sound_coreaudio::update_audio_stream(bool is_throttled, int16_t const *buff } -void sound_coreaudio::set_mastervolume(int attenuation) -{ - int const clamped_attenuation = std::clamp(attenuation, -32, 0); - m_scale = (-32 == clamped_attenuation) ? 0 : (int32_t)(pow(10.0, clamped_attenuation / 20.0) * 128); -} - - bool sound_coreaudio::create_graph(osd_options const &options) { OSStatus err; @@ -984,7 +965,7 @@ OSStatus sound_coreaudio::render( } uint32_t const chunk = std::min(m_buffer_size - m_playpos, number_bytes); - copy_scaled((int8_t *)data->mBuffers[0].mData, &m_buffer[m_playpos], chunk); + memcpy((int8_t *)data->mBuffers[0].mData, &m_buffer[m_playpos], chunk); m_playpos += chunk; if (m_playpos >= m_buffer_size) m_playpos = 0; @@ -993,7 +974,7 @@ OSStatus sound_coreaudio::render( { assert(0U == m_playpos); assert(m_writepos >= (number_bytes - chunk)); - copy_scaled((int8_t *)data->mBuffers[0].mData + chunk, &m_buffer[0], number_bytes - chunk); + memcpy((int8_t *)data->mBuffers[0].mData + chunk, &m_buffer[0], number_bytes - chunk); m_playpos += number_bytes - chunk; } diff --git a/src/osd/modules/sound/direct_sound.cpp b/src/osd/modules/sound/direct_sound.cpp index 0e89bb1ac0d..a00328e436a 100644 --- a/src/osd/modules/sound/direct_sound.cpp +++ b/src/osd/modules/sound/direct_sound.cpp @@ -120,13 +120,6 @@ public: assert(m_buffer); return m_buffer->Stop(); } - HRESULT set_volume(LONG volume) const - { - assert(m_buffer); - return m_buffer->SetVolume(volume); - } - HRESULT set_min_volume() { return set_volume(DSBVOLUME_MIN); } - HRESULT get_current_positions(DWORD &play_pos, DWORD &write_pos) const { assert(m_buffer); @@ -225,8 +218,7 @@ public: virtual void exit() override; // sound_module - virtual void update_audio_stream(bool is_throttled, int16_t const *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; + virtual void stream_sink_update(uint32_t, int16_t const *buffer, int samples_this_frame) override; private: HRESULT dsound_init(); @@ -297,11 +289,11 @@ void sound_direct_sound::exit() //============================================================ -// update_audio_stream +// stream_update //============================================================ -void sound_direct_sound::update_audio_stream( - bool is_throttled, +void sound_direct_sound::stream_sink_update( + uint32_t, int16_t const *buffer, int samples_this_frame) { @@ -364,26 +356,6 @@ void sound_direct_sound::update_audio_stream( //============================================================ -// set_mastervolume -//============================================================ - -void sound_direct_sound::set_mastervolume(int attenuation) -{ - // clamp the attenuation to 0-32 range - attenuation = std::clamp(attenuation, -32, 0); - - // set the master volume - if (m_stream_buffer) - { - if (-32 == attenuation) - m_stream_buffer.set_min_volume(); - else - m_stream_buffer.set_volume(100 * attenuation); - } -} - - -//============================================================ // dsound_init //============================================================ diff --git a/src/osd/modules/sound/js_sound.cpp b/src/osd/modules/sound/js_sound.cpp index 7375d014141..dbf60460bd3 100644 --- a/src/osd/modules/sound/js_sound.cpp +++ b/src/osd/modules/sound/js_sound.cpp @@ -29,26 +29,16 @@ public: // sound_module - virtual void update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) + virtual void stream_update(uint32_t, const int16_t *buffer, int samples_this_frame) { EM_ASM_ARGS( { // Forward audio stream update on to JS backend implementation. - jsmame_update_audio_stream($0, $1); + jsmame_steam_update($1, $2); }, (unsigned int)buffer, samples_this_frame); } - - virtual void set_mastervolume(int attenuation) - { - EM_ASM_ARGS( - { - // Forward volume update on to JS backend implementation. - jsmame_set_mastervolume($0); - }, - attenuation); - } }; #else // SDLMAME_EMSCRIPTEN diff --git a/src/osd/modules/sound/js_sound.js b/src/osd/modules/sound/js_sound.js index 571a5227f2b..81ad07dcef1 100644 --- a/src/osd/modules/sound/js_sound.js +++ b/src/osd/modules/sound/js_sound.js @@ -98,30 +98,7 @@ function disconnect_old_event() { eventNode = null; }; -function set_mastervolume ( - // even though it's 'attenuation' the value is negative, so... - attenuation_in_decibels -) { - lazy_init(); - if (!context) return; - - // http://stackoverflow.com/questions/22604500/web-audio-api-working-with-decibels - // seemingly incorrect/broken. figures. welcome to Web Audio - // var gain_web_audio = 1.0 - Math.pow(10, 10 / attenuation_in_decibels); - - // HACK: Max attenuation in JSMESS appears to be 32. - // Hit ' then left/right arrow to test. - // FIXME: This is linear instead of log10 scale. - var gain_web_audio = 1.0 + (+attenuation_in_decibels / +32); - if (gain_web_audio < +0) - gain_web_audio = +0; - else if (gain_web_audio > +1) - gain_web_audio = +1; - - gain_node.gain.value = gain_web_audio; -}; - -function update_audio_stream ( +function stream_update ( pBuffer, // pointer into emscripten heap. int16 samples samples_this_frame // int. number of samples at pBuffer address. ) { @@ -207,14 +184,12 @@ function sample_count() { } return { - set_mastervolume: set_mastervolume, - update_audio_stream: update_audio_stream, + stream_update: stream_update, get_context: get_context, sample_count: sample_count }; })(); -window.jsmame_set_mastervolume = jsmame_web_audio.set_mastervolume; -window.jsmame_update_audio_stream = jsmame_web_audio.update_audio_stream; +window.jsmame_stream_update = jsmame_web_audio.stream_update; window.jsmame_sample_count = jsmame_web_audio.sample_count; diff --git a/src/osd/modules/sound/none.cpp b/src/osd/modules/sound/none.cpp index ba1085f436b..bdb219636d0 100644 --- a/src/osd/modules/sound/none.cpp +++ b/src/osd/modules/sound/none.cpp @@ -27,11 +27,6 @@ public: virtual int init(osd_interface &osd, const osd_options &options) override { return 0; } virtual void exit() override { } - - // sound_module - - virtual void update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) override { } - virtual void set_mastervolume(int attenuation) override { } }; } // anonymous namespace diff --git a/src/osd/modules/sound/pa_sound.cpp b/src/osd/modules/sound/pa_sound.cpp index d5bb96a25af..68200a9c3f1 100644 --- a/src/osd/modules/sound/pa_sound.cpp +++ b/src/osd/modules/sound/pa_sound.cpp @@ -52,8 +52,7 @@ public: // sound_module - virtual void update_audio_stream(bool is_throttled, const s16 *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; + virtual void stream_sink_update(uint32_t, const s16 *buffer, int samples_this_frame) override; private: // Lock free SPSC ring buffer @@ -80,14 +79,14 @@ private: writepos.store((writepos + n) % size); } - int write(const T* src, int n, int attenuation) { + int write(const T* src, int n) { n = std::min<int>(n, size - reserve - count()); if (writepos + n > size) { - att_memcpy(buf + writepos, src, sizeof(T) * (size - writepos), attenuation); - att_memcpy(buf, src + (size - writepos), sizeof(T) * (n - (size - writepos)), attenuation); + memcpy(buf + writepos, src, sizeof(T) * (size - writepos)); + memcpy(buf, src + (size - writepos), sizeof(T) * (n - (size - writepos))); } else { - att_memcpy(buf + writepos, src, sizeof(T) * n, attenuation); + memcpy(buf + writepos, src, sizeof(T) * n); } increment_writepos(n); @@ -128,13 +127,6 @@ private: return n; } - - void att_memcpy(T* dest, const T* data, int n, int attenuation) { - int level = powf(10.0, attenuation / 20.0) * 32768; - n /= sizeof(T); - while (n--) - *dest++ = (*data++ * level) >> 15; - } }; enum @@ -159,7 +151,6 @@ private: int m_sample_rate; int m_audio_latency; - int m_attenuation; audio_buffer<s16>* m_ab; @@ -193,7 +184,6 @@ int sound_pa::init(osd_interface &osd, osd_options const &options) unsigned long frames_per_callback = paFramesPerBufferUnspecified; double callback_interval; - m_attenuation = options.volume(); m_underflows = 0; m_overflows = 0; m_has_overflowed = false; @@ -389,7 +379,7 @@ int sound_pa::callback(s16* output_buffer, size_t number_of_samples) m_ab->read(output_buffer, buf_ct); std::memset(output_buffer + buf_ct, 0, (number_of_samples - buf_ct) * sizeof(s16)); - // if update_audio_stream has been called, note the underflow + // if stream_sink_update has been called, note the underflow if (m_osd_ticks) m_has_underflowed = true; @@ -399,7 +389,7 @@ int sound_pa::callback(s16* output_buffer, size_t number_of_samples) return paContinue; } -void sound_pa::update_audio_stream(bool is_throttled, const s16 *buffer, int samples_this_frame) +void sound_pa::stream_sink_update(uint32_t, const s16 *buffer, int samples_this_frame) { if (!m_sample_rate) return; @@ -423,17 +413,12 @@ void sound_pa::update_audio_stream(bool is_throttled, const s16 *buffer, int sam m_has_overflowed = false; } - m_ab->write(buffer, samples_this_frame * 2, m_attenuation); + m_ab->write(buffer, samples_this_frame * 2); // for determining buffer overflows, take the sample here instead of in the callback m_osd_ticks = osd_ticks(); } -void sound_pa::set_mastervolume(int attenuation) -{ - m_attenuation = attenuation; -} - void sound_pa::exit() { if (!m_sample_rate) diff --git a/src/osd/modules/sound/pipewire_sound.cpp b/src/osd/modules/sound/pipewire_sound.cpp new file mode 100644 index 00000000000..8bf5b8e0afa --- /dev/null +++ b/src/osd/modules/sound/pipewire_sound.cpp @@ -0,0 +1,823 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert +/*************************************************************************** + + piepewire_sound.c + + PipeWire interface. + +***************************************************************************/ + +#include "sound_module.h" +#include "modules/osdmodule.h" + +#ifndef NO_USE_PIPEWIRE + +#define GNU_SOURCE +#include "modules/lib/osdobj_common.h" + +#include <pipewire/pipewire.h> +#include <pipewire/extensions/metadata.h> +#include <spa/debug/pod.h> +#include <spa/debug/dict.h> +#include <spa/pod/builder.h> +#include <spa/param/audio/raw-utils.h> +#include <rapidjson/document.h> + +#include <map> + +class sound_pipewire : public osd_module, public sound_module +{ +public: + sound_pipewire() + : osd_module(OSD_SOUND_PROVIDER, "pipewire"), sound_module() + { + } + virtual ~sound_pipewire() { } + + virtual int init(osd_interface &osd, osd_options const &options) override; + virtual void exit() override; + + virtual bool external_per_channel_volume() override { return true; } + virtual bool split_streams_per_source() override { return true; } + + virtual uint32_t get_generation() override; + virtual osd::audio_info get_information() override; + virtual uint32_t stream_sink_open(uint32_t node, std::string name, uint32_t rate) override; + virtual uint32_t stream_source_open(uint32_t node, std::string name, uint32_t rate) override; + virtual void stream_set_volumes(uint32_t id, const std::vector<float> &db) override; + virtual void stream_close(uint32_t id) override; + virtual void stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) override; + virtual void stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) override; + +private: + struct position_info { + uint32_t m_position; + std::array<double, 3> m_coords; + }; + + static const position_info position_infos[]; + + static const char *const typenames[]; + enum { AREC, APLAY }; + + struct node_info { + sound_pipewire *m_wire; + uint32_t m_id, m_osdid; + int m_type; + std::string m_serial; + std::string m_name; + std::string m_text_id; + + // Audio node info + uint32_t m_sinks, m_sources; + std::vector<uint32_t> m_position_codes; + std::vector<std::string> m_port_names; + std::vector<std::array<double, 3>> m_positions; + + osd::audio_rate_range m_rate; + bool m_has_s16; + bool m_has_iec958; + + pw_node *m_node; + spa_hook m_node_listener; + + node_info(sound_pipewire *wire, uint32_t id, uint32_t osdid, int type, std::string serial, std::string name, std::string text_id) : m_wire(wire), m_id(id), m_osdid(osdid), m_type(type), m_serial(serial), m_name(name), m_text_id(text_id), m_sinks(0), m_sources(0), m_rate{0, 0, 0}, m_has_s16(false), m_has_iec958(false), m_node(nullptr) { + spa_zero(m_node_listener); + } + }; + + struct stream_info { + sound_pipewire *m_wire; + bool m_is_output; + uint32_t m_osdid; + uint32_t m_node_id; + node_info *m_node; + uint32_t m_channels; + pw_stream *m_stream; + std::vector<float> m_volumes; + abuffer m_buffer; + + stream_info(sound_pipewire *wire, bool is_output, uint32_t osdid, uint32_t channels) : m_wire(wire), m_is_output(is_output), m_osdid(osdid), m_channels(channels), m_stream(nullptr), m_buffer(channels) {} + }; + + static const pw_core_events core_events; + static const pw_registry_events registry_events; + static const pw_node_events node_events; + static const pw_metadata_events default_events; + static const pw_stream_events stream_sink_events; + static const pw_stream_events stream_source_events; + + std::map<uint32_t, node_info> m_nodes; + std::map<uint32_t, uint32_t> m_node_osdid_to_id; + + std::map<uint32_t, stream_info> m_streams; + + pw_thread_loop *m_loop; + pw_context *m_context; + pw_core *m_core; + spa_hook m_core_listener; + pw_registry *m_registry; + spa_hook m_registry_listener; + pw_metadata *m_default; + spa_hook m_default_listener; + + std::string m_default_audio_sink; + std::string m_default_audio_source; + + uint32_t m_node_current_id, m_stream_current_id; + uint32_t m_generation; + bool m_wait_sync, m_wait_stream; + + void sync(); + + void core_event_done(uint32_t id, int seq); + static void s_core_event_done(void *data, uint32_t id, int seq); + + void register_node(uint32_t id, const spa_dict *props); + void register_port(uint32_t id, const spa_dict *props); + void register_link(uint32_t id, const spa_dict *props); + void register_default_metadata(uint32_t id); + void register_metadata(uint32_t id, const spa_dict *props); + void registry_event_global(uint32_t id, uint32_t permissions, const char *type, uint32_t version, const spa_dict *props); + static void s_registry_event_global(void *data, uint32_t id, uint32_t permissions, const char *type, uint32_t version, const spa_dict *props); + + void registry_event_global_remove(uint32_t id); + static void s_registry_event_global_remove(void *data, uint32_t id); + + void node_event_param(node_info *node, int seq, uint32_t id, uint32_t index, uint32_t next, const spa_pod *param); + static void s_node_event_param(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const spa_pod *param); + + int default_event_property(uint32_t subject, const char *key, const char *type, const char *value); + static int s_default_event_property(void *data, uint32_t subject, const char *key, const char *type, const char *value); + + void stream_sink_event_process(stream_info *stream); + static void s_stream_sink_event_process(void *data); + + void stream_source_event_process(stream_info *stream); + static void s_stream_source_event_process(void *data); + + void stream_event_param_changed(stream_info *stream, uint32_t id, const spa_pod *param); + static void s_stream_event_param_changed(void *data, uint32_t id, const spa_pod *param); +}; + +// Try to more or less map to speaker.h positions + +const sound_pipewire::position_info sound_pipewire::position_infos[] = { + { SPA_AUDIO_CHANNEL_MONO, { 0.0, 0.0, 1.0 } }, + { SPA_AUDIO_CHANNEL_FL, { -0.2, 0.0, 1.0 } }, + { SPA_AUDIO_CHANNEL_FR, { 0.2, 0.0, 1.0 } }, + { SPA_AUDIO_CHANNEL_FC, { 0.0, 0.0, 1.0 } }, + { SPA_AUDIO_CHANNEL_LFE, { 0.0, -0.5, 1.0 } }, + { SPA_AUDIO_CHANNEL_RL, { -0.2, 0.0, -0.5 } }, + { SPA_AUDIO_CHANNEL_RR, { 0.2, 0.0, -0.5 } }, + { SPA_AUDIO_CHANNEL_RC, { 0.0, 0.0, -0.5 } }, + { SPA_AUDIO_CHANNEL_UNKNOWN, { 0.0, 0.0, 0.0 } } +}; + + +const char *const sound_pipewire::typenames[] = { + "Audio recorder", "Speaker" +}; + +const pw_core_events sound_pipewire::core_events = { + PW_VERSION_CORE_EVENTS, + nullptr, // info + s_core_event_done, + nullptr, // ping + nullptr, // error + nullptr, // remove_id + nullptr, // bound_id + nullptr, // add_mem + nullptr, // remove_mem + nullptr // bound_props +}; + +const pw_registry_events sound_pipewire::registry_events = { + PW_VERSION_REGISTRY_EVENTS, + s_registry_event_global, + s_registry_event_global_remove +}; + +const pw_node_events sound_pipewire::node_events = { + PW_VERSION_NODE_EVENTS, + nullptr, // info + s_node_event_param +}; + +const pw_metadata_events sound_pipewire::default_events = { + PW_VERSION_METADATA_EVENTS, + s_default_event_property +}; + +const pw_stream_events sound_pipewire::stream_sink_events = { + PW_VERSION_STREAM_EVENTS, + nullptr, // destroy + nullptr, // state changed + nullptr, // control info + nullptr, // io changed + s_stream_event_param_changed, + nullptr, // add buffer + nullptr, // remove buffer + s_stream_sink_event_process, + nullptr, // drained + nullptr, // command + nullptr // trigger done +}; + +const pw_stream_events sound_pipewire::stream_source_events = { + PW_VERSION_STREAM_EVENTS, + nullptr, // destroy + nullptr, // state changed + nullptr, // control info + nullptr, // io changed + s_stream_event_param_changed, + nullptr, // add buffer + nullptr, // remove buffer + s_stream_source_event_process, + nullptr, // drained + nullptr, // command + nullptr // trigger done +}; + +void sound_pipewire::register_node(uint32_t id, const spa_dict *props) +{ + const spa_dict_item *cls = spa_dict_lookup_item(props, PW_KEY_MEDIA_CLASS); + const spa_dict_item *desc = spa_dict_lookup_item(props, PW_KEY_NODE_DESCRIPTION); + const spa_dict_item *name = spa_dict_lookup_item(props, PW_KEY_NODE_NAME); + const spa_dict_item *serial = spa_dict_lookup_item(props, PW_KEY_OBJECT_SERIAL); + if(!cls) + return; + int type; + if(!strcmp(cls->value, "Audio/Source")) + type = AREC; + else if(!strcmp(cls->value, "Audio/Sink")) + type = APLAY; + else + return; + + m_node_osdid_to_id[m_node_current_id] = id; + auto &node = m_nodes.emplace(id, node_info(this, id, m_node_current_id++, type, serial->value, desc ? desc->value : "?", name ? name->value : "?")).first->second; + + // printf("node %03x: %s %s %s | %s\n", node.m_id, serial->value, typenames[node.m_type], node.m_name.c_str(), node.m_text_id.c_str()); + + node.m_node = (pw_node *)pw_registry_bind(m_registry, id, PW_TYPE_INTERFACE_Node, PW_VERSION_NODE, 0); + pw_node_add_listener(node.m_node, &node.m_node_listener, &node_events, &node); + pw_node_enum_params(node.m_node, 0, 3, 0, 0xffffffff, nullptr); + m_generation++; +} + +void sound_pipewire::register_port(uint32_t id, const spa_dict *props) +{ + uint32_t node = strtol(spa_dict_lookup_item(props, PW_KEY_NODE_ID)->value, nullptr, 10); + auto ind = m_nodes.find(node); + if(ind == m_nodes.end()) + return; + + const spa_dict_item *channel = spa_dict_lookup_item(props, PW_KEY_AUDIO_CHANNEL); + const spa_dict_item *dir = spa_dict_lookup_item(props, PW_KEY_PORT_DIRECTION); + bool is_in = dir && !strcmp(dir->value, "in") ; + uint32_t index = strtol(spa_dict_lookup_item(props, PW_KEY_PORT_ID)->value, nullptr, 10); + + if(is_in && ind->second.m_sinks <= index) + ind->second.m_sinks = index+1; + if(!is_in && ind->second.m_sources <= index) + ind->second.m_sources = index+1; + + auto &port_names = ind->second.m_port_names; + if(port_names.size() <= index) + port_names.resize(index+1); + + if(is_in || port_names[index].empty()) + port_names[index] = channel ? channel->value : "?"; + + m_generation++; + // printf("port %03x.%d %03x: %s\n", node, index, id, port_names[index].c_str()); +} + +void sound_pipewire::register_link(uint32_t id, const spa_dict *props) +{ + const spa_dict_item *input = spa_dict_lookup_item(props, PW_KEY_LINK_INPUT_NODE); + const spa_dict_item *output = spa_dict_lookup_item(props, PW_KEY_LINK_OUTPUT_NODE); + if(!input || !output) + return; + + uint32_t input_id = strtol(input->value, nullptr, 10); + uint32_t output_id = strtol(output->value, nullptr, 10); + + for(auto &si : m_streams) { + stream_info &stream = si.second; + if(stream.m_is_output && stream.m_node_id == output_id && (stream.m_node && stream.m_node->m_id != input_id)) { + auto ni = m_nodes.find(input_id); + if(ni != m_nodes.end()) { + stream.m_node = &ni->second; + m_generation ++; + return; + } + } + if(!stream.m_is_output && stream.m_node_id == input_id && (stream.m_node && stream.m_node->m_id != output_id)) { + auto ni = m_nodes.find(output_id); + if(ni != m_nodes.end()) { + stream.m_node = &ni->second; + m_generation ++; + return; + } + } + } +} + +void sound_pipewire::register_default_metadata(uint32_t id) +{ + m_default = (pw_metadata *)pw_registry_bind(m_registry, id, PW_TYPE_INTERFACE_Metadata, PW_VERSION_METADATA, 0); + pw_metadata_add_listener(m_default, &m_default_listener, &default_events, this); +} + +void sound_pipewire::register_metadata(uint32_t id, const spa_dict *props) +{ + const spa_dict_item *mn = spa_dict_lookup_item(props, PW_KEY_METADATA_NAME); + if(mn && !strcmp(mn->value, "default")) + register_default_metadata(id); +} + +void sound_pipewire::registry_event_global(uint32_t id, + uint32_t permissions, const char *type, uint32_t version, + const spa_dict *props) +{ + if(!strcmp(type, PW_TYPE_INTERFACE_Node)) + register_node(id, props); + else if(!strcmp(type, PW_TYPE_INTERFACE_Port)) + register_port(id, props); + else if(!strcmp(type, PW_TYPE_INTERFACE_Metadata)) + register_metadata(id, props); + else if(!strcmp(type, PW_TYPE_INTERFACE_Link)) + register_link(id, props); + else { + // printf("type %03x %s\n", id, type); + } +} + +void sound_pipewire::s_registry_event_global(void *data, uint32_t id, + uint32_t permissions, const char *type, uint32_t version, + const spa_dict *props) +{ + ((sound_pipewire *)data)->registry_event_global(id, permissions, type, version, props); +} + +void sound_pipewire::registry_event_global_remove(uint32_t id) +{ + auto ind = m_nodes.find(id); + if(ind == m_nodes.end()) + return; + + for(auto &istream : m_streams) + if(istream.second.m_node == &ind->second) + istream.second.m_node = nullptr; + m_nodes.erase(ind); + m_generation++; +} + +void sound_pipewire::s_registry_event_global_remove(void *data, uint32_t id) +{ + ((sound_pipewire *)data)->registry_event_global_remove(id); +} + +void sound_pipewire::node_event_param(node_info *node, int seq, uint32_t id, uint32_t index, uint32_t next, const spa_pod *param) +{ + if(id == SPA_PARAM_EnumFormat) { + const spa_pod_prop *subtype = spa_pod_find_prop(param, nullptr, SPA_FORMAT_mediaSubtype); + if(subtype) { + uint32_t sval; + if(!spa_pod_get_id(&subtype->value, &sval)) { + if(sval == SPA_MEDIA_SUBTYPE_raw) { + const spa_pod_prop *format = spa_pod_find_prop(param, nullptr, SPA_FORMAT_AUDIO_format); + const spa_pod_prop *rate = spa_pod_find_prop(param, nullptr, SPA_FORMAT_AUDIO_rate); + const spa_pod_prop *position = spa_pod_find_prop(param, nullptr, SPA_FORMAT_AUDIO_position); + + if(format) { + uint32_t *entry; + SPA_POD_CHOICE_FOREACH((spa_pod_choice *)(&format->value), entry) { + if(*entry == SPA_AUDIO_FORMAT_S16) + node->m_has_s16 = true; + } + } + if(rate) { + if(rate->value.type == SPA_TYPE_Choice) { + struct spa_pod_choice_body *b = &((spa_pod_choice *)(&rate->value))->body; + uint32_t *choices = (uint32_t *)(b+1); + node->m_rate.m_default_rate = choices[0]; + if(b->type == SPA_CHOICE_Range) { + node->m_rate.m_min_rate = choices[1]; + node->m_rate.m_max_rate = choices[2]; + } else { + node->m_rate.m_min_rate = node->m_rate.m_default_rate; + node->m_rate.m_max_rate = node->m_rate.m_default_rate; + } + } + } + + if(position) { + uint32_t *entry; + node->m_position_codes.clear(); + node->m_positions.clear(); + SPA_POD_ARRAY_FOREACH((spa_pod_array *)(&position->value), entry) { + node->m_position_codes.push_back(*entry); + for(uint32_t i = 0;; i++) { + if((position_infos[i].m_position == *entry) || (position_infos[i].m_position == SPA_AUDIO_CHANNEL_UNKNOWN)) { + node->m_positions.push_back(position_infos[i].m_coords); + break; + } + } + } + } + } else if(sval == SPA_MEDIA_SUBTYPE_iec958) + node->m_has_iec958 = true; + } + } + m_generation++; + + } else + spa_debug_pod(2, nullptr, param); +} + +void sound_pipewire::s_node_event_param(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const spa_pod *param) +{ + node_info *n = (node_info *)data; + n->m_wire->node_event_param(n, seq, id, index, next, param); +} + +int sound_pipewire::default_event_property(uint32_t subject, const char *key, const char *type, const char *value) +{ + if(!value) + return 0; + std::string val = value; + if(!strcmp(type, "Spa:String:JSON")) { + rapidjson::Document json; + json.Parse(value); + if(json.IsObject() && json.HasMember("name") && json["name"].IsString()) + val = json["name"].GetString(); + } else + val = value; + + if(!strcmp(key, "default.audio.sink")) + m_default_audio_sink = val; + + else if(!strcmp(key, "default.audio.source")) + m_default_audio_source = val; + + return 0; +} + +int sound_pipewire::s_default_event_property(void *data, uint32_t subject, const char *key, const char *type, const char *value) +{ + return ((sound_pipewire *)data)->default_event_property(subject, key, type, value); +} + +int sound_pipewire::init(osd_interface &osd, osd_options const &options) +{ + spa_zero(m_core_listener); + spa_zero(m_registry_listener); + spa_zero(m_default_listener); + + m_node_current_id = 1; + m_stream_current_id = 1; + m_generation = 1; + + m_wait_sync = false; + m_wait_stream = false; + + pw_init(nullptr, nullptr); + m_loop = pw_thread_loop_new(nullptr, nullptr); + m_context = pw_context_new(pw_thread_loop_get_loop(m_loop), nullptr, 0); + m_core = pw_context_connect(m_context, nullptr, 0); + + if(!m_core) + return 1; + + pw_core_add_listener(m_core, &m_core_listener, &core_events, this); + + m_registry = pw_core_get_registry(m_core, PW_VERSION_REGISTRY, 0); + pw_registry_add_listener(m_registry, &m_registry_listener, ®istry_events, this); + + pw_thread_loop_start(m_loop); + + // The first sync ensures that the initial information request is + // completed, the second that the subsequent ones (parameters + // retrieval) are completed too. + sync(); + sync(); + + return 0; +} + +void sound_pipewire::core_event_done(uint32_t id, int seq) +{ + m_wait_sync = false; + pw_thread_loop_signal(m_loop, false); +} + +void sound_pipewire::s_core_event_done(void *data, uint32_t id, int seq) +{ + ((sound_pipewire *)data)->core_event_done(id, seq); +} + +void sound_pipewire::sync() +{ + pw_thread_loop_lock(m_loop); + m_wait_sync = true; + pw_core_sync(m_core, PW_ID_CORE, 0); + while(m_wait_sync) + pw_thread_loop_wait(m_loop); + pw_thread_loop_unlock(m_loop); +} + +void sound_pipewire::exit() +{ + pw_thread_loop_stop(m_loop); + for(const auto &si : m_streams) + pw_stream_destroy(si.second.m_stream); + for(const auto &ni : m_nodes) + pw_proxy_destroy((pw_proxy *)ni.second.m_node); + pw_proxy_destroy((pw_proxy *)m_default); + pw_proxy_destroy((pw_proxy *)m_registry); + pw_core_disconnect(m_core); + pw_context_destroy(m_context); + pw_thread_loop_destroy(m_loop); + pw_deinit(); +} + +uint32_t sound_pipewire::get_generation() +{ + pw_thread_loop_lock(m_loop); + uint32_t result = m_generation; + pw_thread_loop_unlock(m_loop); + return result; +} + +osd::audio_info sound_pipewire::get_information() +{ + osd::audio_info result; + pw_thread_loop_lock(m_loop); + result.m_nodes.resize(m_nodes.size()); + result.m_default_sink = 0; + result.m_default_source = 0; + result.m_generation = m_generation; + uint32_t node = 0; + for(auto &inode : m_nodes) { + result.m_nodes[node].m_name = inode.second.m_name; + result.m_nodes[node].m_id = inode.second.m_osdid; + result.m_nodes[node].m_rate = inode.second.m_rate; + result.m_nodes[node].m_sinks = inode.second.m_sinks; + result.m_nodes[node].m_sources = inode.second.m_sources; + result.m_nodes[node].m_port_names = inode.second.m_port_names; + result.m_nodes[node].m_port_positions = inode.second.m_positions; + + if(inode.second.m_text_id == m_default_audio_sink) + result.m_default_sink = inode.second.m_osdid; + if(inode.second.m_text_id == m_default_audio_source) + result.m_default_source = inode.second.m_osdid; + node ++; + } + + for(auto &istream : m_streams) + if(istream.second.m_node) + result.m_streams.emplace_back(osd::audio_info::stream_info { istream.second.m_osdid, istream.second.m_node->m_osdid, istream.second.m_volumes }); + + pw_thread_loop_unlock(m_loop); + return result; +} + +void sound_pipewire::stream_sink_event_process(stream_info *stream) +{ + pw_buffer *buffer = pw_stream_dequeue_buffer(stream->m_stream); + if(!buffer) + return; + + spa_buffer *sbuf = buffer->buffer; + stream->m_buffer.get((int16_t *)(sbuf->datas[0].data), buffer->requested); + + sbuf->datas[0].chunk->offset = 0; + sbuf->datas[0].chunk->stride = stream->m_channels * 2; + sbuf->datas[0].chunk->size = buffer->requested * stream->m_channels * 2; + + pw_stream_queue_buffer(stream->m_stream, buffer); +} + +void sound_pipewire::s_stream_sink_event_process(void *data) +{ + stream_info *info = (stream_info *)(data); + info->m_wire->stream_sink_event_process(info); +} + +void sound_pipewire::stream_source_event_process(stream_info *stream) +{ + pw_buffer *buffer = pw_stream_dequeue_buffer(stream->m_stream); + if(!buffer) + return; + + spa_buffer *sbuf = buffer->buffer; + stream->m_buffer.push((int16_t *)(sbuf->datas[0].data), sbuf->datas[0].chunk->size / stream->m_channels / 2); + pw_stream_queue_buffer(stream->m_stream, buffer); +} + +void sound_pipewire::s_stream_source_event_process(void *data) +{ + stream_info *info = (stream_info *)(data); + info->m_wire->stream_source_event_process(info); +} + +void sound_pipewire::stream_event_param_changed(stream_info *stream, uint32_t id, const spa_pod *param) +{ + if(id == SPA_PARAM_Props) { + const spa_pod_prop *vols = spa_pod_find_prop(param, nullptr, SPA_PROP_channelVolumes); + if(vols) { + bool initial = stream->m_volumes.empty(); + stream->m_volumes.clear(); + float *entry; + SPA_POD_ARRAY_FOREACH((spa_pod_array *)(&vols->value), entry) { + stream->m_volumes.push_back(osd::linear_to_db(*entry)); + } + if(!stream->m_volumes.empty()) { + if(initial) { + m_wait_stream = false; + pw_thread_loop_signal(m_loop, false); + } else + m_generation++; + } + } + } +} + +void sound_pipewire::s_stream_event_param_changed(void *data, uint32_t id, const spa_pod *param) +{ + stream_info *info = (stream_info *)(data); + info->m_wire->stream_event_param_changed(info, id, param); +} + +uint32_t sound_pipewire::stream_sink_open(uint32_t node, std::string name, uint32_t rate) +{ + pw_thread_loop_lock(m_loop); + auto ni = m_node_osdid_to_id.find(node); + if(ni == m_node_osdid_to_id.end()) { + pw_thread_loop_unlock(m_loop); + return 0; + } + node_info &snode = m_nodes.find(ni->second)->second; + + uint32_t id = m_stream_current_id++; + auto &stream = m_streams.emplace(id, stream_info(this, true, id, snode.m_sinks)).first->second; + + stream.m_stream = pw_stream_new_simple(pw_thread_loop_get_loop(m_loop), + name.c_str(), + pw_properties_new(PW_KEY_MEDIA_TYPE, "Audio", + PW_KEY_MEDIA_CATEGORY, "Playback", + PW_KEY_MEDIA_ROLE, "Game", + PW_KEY_TARGET_OBJECT, snode.m_serial.c_str(), + nullptr), + &stream_sink_events, + &stream); + stream.m_node = &snode; + + const spa_pod *params; + spa_audio_info_raw format = { + SPA_AUDIO_FORMAT_S16, + 0, + rate, + stream.m_channels + }; + for(uint32_t i=0; i != snode.m_sinks; i++) + format.position[i] = snode.m_position_codes[i]; + + uint8_t buffer[1024]; + spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &format); + + pw_stream_connect(stream.m_stream, + PW_DIRECTION_OUTPUT, + PW_ID_ANY, + pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS), + ¶ms, 1); + + m_wait_stream = true; + while(m_wait_stream) + pw_thread_loop_wait(m_loop); + + stream.m_node_id = pw_stream_get_node_id(stream.m_stream); + pw_thread_loop_unlock(m_loop); + + return id; +} + +uint32_t sound_pipewire::stream_source_open(uint32_t node, std::string name, uint32_t rate) +{ + pw_thread_loop_lock(m_loop); + auto ni = m_node_osdid_to_id.find(node); + if(ni == m_node_osdid_to_id.end()) { + pw_thread_loop_unlock(m_loop); + return 0; + } + node_info &snode = m_nodes.find(ni->second)->second; + + uint32_t id = m_stream_current_id++; + auto &stream = m_streams.emplace(id, stream_info(this, false, id, snode.m_sources)).first->second; + + stream.m_stream = pw_stream_new_simple(pw_thread_loop_get_loop(m_loop), + name.c_str(), + pw_properties_new(PW_KEY_MEDIA_TYPE, "Audio", + PW_KEY_MEDIA_CATEGORY, "Record", + PW_KEY_MEDIA_ROLE, "Game", + PW_KEY_TARGET_OBJECT, snode.m_serial.c_str(), + nullptr), + &stream_source_events, + &stream); + stream.m_node = &snode; + + const spa_pod *params; + spa_audio_info_raw format = { + SPA_AUDIO_FORMAT_S16, + 0, + rate, + stream.m_channels + }; + for(uint32_t i=0; i != snode.m_sources; i++) + format.position[i] = snode.m_position_codes[i]; + + uint8_t buffer[1024]; + spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer)); + params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &format); + + pw_stream_connect(stream.m_stream, + PW_DIRECTION_INPUT, + PW_ID_ANY, + pw_stream_flags(PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS | PW_STREAM_FLAG_RT_PROCESS), + ¶ms, 1); + + m_wait_stream = true; + while(m_wait_stream) + pw_thread_loop_wait(m_loop); + + stream.m_node_id = pw_stream_get_node_id(stream.m_stream); + pw_thread_loop_unlock(m_loop); + + return id; +} + +void sound_pipewire::stream_set_volumes(uint32_t id, const std::vector<float> &db) +{ + pw_thread_loop_lock(m_loop); + auto si = m_streams.find(id); + if(si == m_streams.end()) { + pw_thread_loop_unlock(m_loop); + return; + } + stream_info &stream = si->second; + stream.m_volumes = db; + std::vector<float> linear; + for(float db1 : db) + linear.push_back(osd::db_to_linear(db1)); + pw_stream_set_control(stream.m_stream, SPA_PROP_channelVolumes, linear.size(), linear.data(), 0); + pw_thread_loop_unlock(m_loop); +} + +void sound_pipewire::stream_close(uint32_t id) +{ + pw_thread_loop_lock(m_loop); + auto si = m_streams.find(id); + if(si == m_streams.end()) { + pw_thread_loop_unlock(m_loop); + return; + } + stream_info &stream = si->second; + pw_stream_destroy(stream.m_stream); + m_streams.erase(si); + pw_thread_loop_unlock(m_loop); +} + +void sound_pipewire::stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) +{ + pw_thread_loop_lock(m_loop); + auto si = m_streams.find(id); + if(si == m_streams.end()) { + pw_thread_loop_unlock(m_loop); + return; + } + si->second.m_buffer.push(buffer, samples_this_frame); + pw_thread_loop_unlock(m_loop); +} + +void sound_pipewire::stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) +{ + pw_thread_loop_lock(m_loop); + auto si = m_streams.find(id); + if(si == m_streams.end()) { + pw_thread_loop_unlock(m_loop); + return; + } + si->second.m_buffer.get(buffer, samples_this_frame); + pw_thread_loop_unlock(m_loop); +} + +#else + MODULE_NOT_SUPPORTED(sound_pipewire, OSD_SOUND_PROVIDER, "pipewire") +#endif + +MODULE_DEFINITION(SOUND_PIPEWIRE, sound_pipewire) diff --git a/src/osd/modules/sound/pulse_sound.cpp b/src/osd/modules/sound/pulse_sound.cpp index 373913f9f91..4b7c87b6b9b 100644 --- a/src/osd/modules/sound/pulse_sound.cpp +++ b/src/osd/modules/sound/pulse_sound.cpp @@ -14,21 +14,12 @@ #ifndef NO_USE_PULSEAUDIO #define GNU_SOURCE -#include <fcntl.h> -#include <unistd.h> -#include <stdio.h> -#include <stdlib.h> -#include <poll.h> - -#include <mutex> -#include <thread> + #include <pulse/pulseaudio.h> +#include <map> #include "modules/lib/osdobj_common.h" -using osd::s16; -using osd::u32; - class sound_pulse : public osd_module, public sound_module { public: @@ -40,52 +31,113 @@ public: virtual int init(osd_interface &osd, osd_options const &options) override; virtual void exit() override; - virtual void update_audio_stream(bool is_throttled, const s16 *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; + + virtual bool external_per_channel_volume() override { return false; } + virtual bool split_streams_per_source() override { return true; } + + virtual uint32_t get_generation() override; + virtual osd::audio_info get_information() override; + virtual uint32_t stream_sink_open(uint32_t node, std::string name, uint32_t rate) override; + virtual void stream_set_volumes(uint32_t id, const std::vector<float> &db) override; + virtual void stream_close(uint32_t id) override; + virtual void stream_sink_update(uint32_t, const int16_t *buffer, int samples_this_frame) override; private: - struct abuffer { - size_t cpos; - std::vector<u32> data; + struct position_info { + pa_channel_position_t m_position; + std::array<double, 3> m_coords; }; - std::thread *m_thread; - pa_mainloop *m_mainloop; - pa_context *m_context; - pa_stream *m_stream; - std::mutex m_mutex; + static const position_info position_infos[]; + static const char *const typenames[]; + enum { AREC, APLAY }; + + struct node_info { + sound_pulse *m_pulse; + uint32_t m_id, m_osdid; + int m_type; + std::string m_name, m_desc; + + // Audio node info + std::vector<pa_channel_position_t> m_position_codes; + std::vector<std::string> m_position_names; + std::vector<std::array<double, 3>> m_positions; + uint32_t m_sink_port_count, m_source_port_count; + + osd::audio_rate_range m_rate; + + node_info(sound_pulse *pulse, uint32_t id, uint32_t osdid, int type, std::string name, std::string desc) : m_pulse(pulse), m_id(id), m_osdid(osdid), m_type(type), m_name(name), m_desc(desc), m_sink_port_count(0), m_source_port_count(0), m_rate{0, 0, 0} { + } + }; + + struct stream_info { + sound_pulse *m_pulse; + uint32_t m_osdid; + uint32_t m_pulse_id; + node_info *m_target_node; + uint32_t m_channels; + pa_stream *m_stream; + std::vector<float> m_volumes; + abuffer m_buffer; + + stream_info(sound_pulse *pulse, uint32_t osdid, uint32_t channels) : m_pulse(pulse), m_osdid(osdid), m_pulse_id(0), m_channels(channels), m_stream(nullptr), m_volumes(channels), m_buffer(channels) {} + }; - std::vector<abuffer> m_buffers; + std::map<uint32_t, node_info> m_nodes; + std::map<uint32_t, uint32_t> m_node_osdid_to_id; - u32 m_last_sample; - int m_new_volume_value; - bool m_setting_volume; - bool m_new_volume; + std::map<uint32_t, stream_info> m_streams; + std::map<uint32_t, uint32_t> m_stream_pulse_id_to_osdid; - int m_pipe_to_sub[2]; - int m_pipe_to_main[2]; + pa_threaded_mainloop *m_mainloop; + pa_context *m_context; + uint32_t m_node_current_id, m_stream_current_id; + uint32_t m_generation; + bool m_wait_stream, m_wait_init; + + std::string m_default_audio_sink; + std::string m_default_audio_source; - static void i_volume_set_notify(pa_context *, int success, void *self); - void volume_set_notify(int success); + static void i_server_info(pa_context *, const pa_server_info *i, void *self); + void server_info(const pa_server_info *i); static void i_context_notify(pa_context *, void *self); void context_notify(); + static void i_context_subscribe(pa_context *, pa_subscription_event_type_t t, uint32_t idx, void *self); + void context_subscribe(pa_subscription_event_type_t t, uint32_t idx); static void i_stream_notify(pa_stream *, void *self); - void stream_notify(); + void stream_notify(stream_info *stream); static void i_stream_write_request(pa_stream *, size_t size, void *self); - void stream_write_request(size_t size); + void stream_write_request(stream_info *stream, size_t size); + static void i_source_info(pa_context *, const pa_source_info *i, int eol, void *self); + void source_info(const pa_source_info *i, int eol); + static void i_sink_info_new(pa_context *, const pa_sink_info *i, int eol, void *self); + void sink_info_new(const pa_sink_info *i, int eol); + static void i_sink_input_info_change(pa_context *, const pa_sink_input_info *i, int eol, void *self); + void sink_input_info_change(stream_info *stream, const pa_sink_input_info *i, int eol); - void make_pipes(); - - void mainloop_thread(); - void send_main(char c); - void send_sub(char c); - char get_main(); - char peek_main(); - void stop_mainloop(int err); void generic_error(const char *msg); void generic_pa_error(const char *msg, int err); }; +// Try to more or less map to speaker.h positions + +const sound_pulse::position_info sound_pulse::position_infos[] = { + { PA_CHANNEL_POSITION_MONO, { 0.0, 0.0, 1.0 } }, + { PA_CHANNEL_POSITION_FRONT_LEFT, { -0.2, 0.0, 1.0 } }, + { PA_CHANNEL_POSITION_FRONT_RIGHT, { 0.2, 0.0, 1.0 } }, + { PA_CHANNEL_POSITION_FRONT_CENTER, { 0.0, 0.0, 1.0 } }, + { PA_CHANNEL_POSITION_LFE, { 0.0, -0.5, 1.0 } }, + { PA_CHANNEL_POSITION_REAR_LEFT, { -0.2, 0.0, -0.5 } }, + { PA_CHANNEL_POSITION_REAR_RIGHT, { 0.2, 0.0, -0.5 } }, + { PA_CHANNEL_POSITION_REAR_CENTER, { 0.0, 0.0, -0.5 } }, + { PA_CHANNEL_POSITION_MAX, { 0.0, 0.0, 0.0 } } +}; + + +const char *const sound_pulse::typenames[] = { + "Audio recorder", "Speaker" +}; + void sound_pulse::generic_error(const char *msg) { perror(msg); @@ -98,205 +150,312 @@ void sound_pulse::generic_pa_error(const char *msg, int err) ::exit(1); } -char sound_pulse::peek_main() +void sound_pulse::context_notify() { - char c; - int err = read(m_pipe_to_main[0], &c, 1); - if(err != 1) { - if(err >= 0) { - fprintf(stderr, "peek_main: read returned %d, that's supposedly impossible\n", err); - ::exit(1); - } - if(errno == EAGAIN || errno == EWOULDBLOCK) { - // No data, no problem - return -1; - } - generic_error("peek_main: read"); + fprintf(stderr, "context notify\n"); + pa_context_state state = pa_context_get_state(m_context); + if(state == PA_CONTEXT_READY) { + pa_context_subscribe(m_context, PA_SUBSCRIPTION_MASK_ALL, nullptr, this); + pa_context_get_sink_info_list(m_context, i_sink_info_new, (void *)this); + + } else if(state == PA_CONTEXT_FAILED || state == PA_CONTEXT_TERMINATED) { + m_generation = 0x80000000; + pa_threaded_mainloop_signal(m_mainloop, 0); } - return c; } -char sound_pulse::get_main() +void sound_pulse::i_context_notify(pa_context *, void *self) { - pollfd pfds[1]; - pfds[0].fd = m_pipe_to_main[0]; - pfds[0].events = POLLIN; - pfds[0].revents = 0; - int err = poll(pfds, 1, -1); - if(err < 0) - generic_error("get_main: poll"); - - char c; - err = read(m_pipe_to_main[0], &c, 1); - if(err != 1) { - if(err >= 0) { - fprintf(stderr, "get_main: read returned %d, that's supposedly impossible\n", err); - ::exit(1); - } - generic_error("get_main: read"); - } - return c; + static_cast<sound_pulse *>(self)->context_notify(); } -void sound_pulse::send_main(char c) +void sound_pulse::stream_notify(stream_info *stream) { - int err = write(m_pipe_to_main[1], &c, 1); - if(err != 1) { - if(err >= 0) { - fprintf(stderr, "send_main: write returned %d, that's supposedly impossible\n", err); - ::exit(1); - } - if(errno == EAGAIN || errno == EWOULDBLOCK) { - fprintf(stderr, "send_main: write would block, pipe buffer overflowed, something is going very badly\n"); - ::exit(1); - } - generic_error("send_main: write"); + pa_stream_state state = pa_stream_get_state(stream->m_stream); + + fprintf(stderr, "stream notify\n"); + if(state == PA_STREAM_READY || state == PA_STREAM_FAILED || state == PA_STREAM_TERMINATED) { + m_wait_stream = false; + pa_threaded_mainloop_signal(m_mainloop, 0); } } -void sound_pulse::send_sub(char c) +void sound_pulse::i_stream_notify(pa_stream *, void *self) { - int err = write(m_pipe_to_sub[1], &c, 1); - if(err != 1) { - if(err >= 0) { - fprintf(stderr, "send_sub: write returned %d, that's supposedly impossible\n", err); - ::exit(1); - } - if(errno == EAGAIN || errno == EWOULDBLOCK) { - fprintf(stderr, "send_sub: write would block, pipe buffer overflowed, something is going very badly\n"); - ::exit(1); - } - generic_error("send_sub: write"); - } + stream_info *si = static_cast<stream_info *>(self); + si->m_pulse->stream_notify(si); } -void sound_pulse::make_pipes() +void sound_pulse::stream_write_request(stream_info *stream, size_t size) { - if(pipe2(m_pipe_to_sub, O_NONBLOCK)) - generic_error("pipe2 pipe_to_sub"); - if(pipe2(m_pipe_to_main, O_NONBLOCK)) - generic_error("pipe2 pipe_to_main"); + // This is called with the thread locked + while(size) { + void *buffer; + size_t bsize = size; + int err = pa_stream_begin_write(stream->m_stream, &buffer, &bsize); + if(err) + generic_pa_error("stream begin write", err); + uint32_t frames = bsize/2/stream->m_channels; + uint32_t bytes = frames*2*stream->m_channels; + stream->m_buffer.get((int16_t *)buffer, frames); + err = pa_stream_write(stream->m_stream, buffer, bytes, nullptr, 0, PA_SEEK_RELATIVE); + if(err) + generic_pa_error("stream write", err); + size -= bytes; + } } -void sound_pulse::context_notify() +void sound_pulse::i_stream_write_request(pa_stream *, size_t size, void *self) { - pa_context_state state = pa_context_get_state(m_context); - if(state == PA_CONTEXT_READY) - send_main('r'); + stream_info *si = static_cast<stream_info *>(self); + si->m_pulse->stream_write_request(si, size); +} - else if(state == PA_CONTEXT_FAILED) { - send_main('f'); - stop_mainloop(pa_context_errno(m_context)); - } else if(state == PA_CONTEXT_TERMINATED) { - send_main('t'); - stop_mainloop(0); +void sound_pulse::server_info(const pa_server_info *i) +{ + m_default_audio_sink = i->default_sink_name; + m_default_audio_source = i->default_source_name; + fprintf(stderr, "defaults %s %s\n", i->default_sink_name, i->default_source_name); + m_generation++; + if(m_wait_init) { + m_wait_init = false; + pa_threaded_mainloop_signal(m_mainloop, 0); } } -void sound_pulse::i_context_notify(pa_context *, void *self) +void sound_pulse::i_server_info(pa_context *, const pa_server_info *i, void *self) { - static_cast<sound_pulse *>(self)->context_notify(); + static_cast<sound_pulse *>(self)->server_info(i); } -void sound_pulse::stream_notify() +void sound_pulse::source_info(const pa_source_info *i, int eol) { - pa_stream_state state = pa_stream_get_state(m_stream); - - if(state == PA_STREAM_READY) - send_main('r'); - - else if(state == PA_STREAM_FAILED) { - send_main('f'); - stop_mainloop(pa_context_errno(m_context)); + if(eol) { + if(m_wait_init) + pa_context_get_server_info(m_context, i_server_info, (void *)this); + return; + } + auto ni = m_nodes.find(i->index); + if(ni != m_nodes.end()) { + // Add the monitoring sources to the node + ni->second.m_source_port_count = i->channel_map.channels; + return; + } - } else if(state == PA_STREAM_TERMINATED) - pa_context_disconnect(m_context); + fprintf(stderr, "new source %d (%s)\n", i->index, i->description); + m_node_osdid_to_id[m_node_current_id] = i->index; + auto &node = m_nodes.emplace(i->index, node_info(this, i->index, m_node_current_id++, AREC, i->name, i->description)).first->second; + + node.m_source_port_count = i->channel_map.channels; + for(int chan=0; chan != i->channel_map.channels; chan++) { + pa_channel_position_t pos = i->channel_map.map[chan]; + node.m_position_codes.push_back(pos); + node.m_position_names.push_back(pa_channel_position_to_pretty_string(pos)); + for(uint32_t j = 0;; j++) { + if((position_infos[j].m_position == pos) || (position_infos[j].m_position == PA_CHANNEL_POSITION_MAX)) { + node.m_positions.push_back(position_infos[j].m_coords); + break; + } + } + } } -void sound_pulse::i_stream_notify(pa_stream *, void *self) +void sound_pulse::i_source_info(pa_context *, const pa_source_info *i, int eol, void *self) { - static_cast<sound_pulse *>(self)->stream_notify(); + static_cast<sound_pulse *>(self)->source_info(i, eol); } -void sound_pulse::stream_write_request(size_t size) +void sound_pulse::sink_info_new(const pa_sink_info *i, int eol) { - if(size & 3) { - fprintf(stderr, "stream request with size %d not a multiple of 4.\n", int(size)); - ::exit(1); + if(eol) { + if(m_wait_init) + pa_context_get_source_info_list(m_context, i_source_info, (void *)this); + return; } - size >>= 2; - std::unique_lock<std::mutex> lock(m_mutex); - while(size) { - if(m_buffers.empty()) { - std::vector<u32> zero(size, m_last_sample); - int err = pa_stream_write(m_stream, zero.data(), size << 2, nullptr, 0, PA_SEEK_RELATIVE); - if(err) - generic_pa_error("stream write", err); - size = 0; - - } else { - auto &buf = m_buffers[0]; - size_t csz = size; - size_t cur = buf.data.size() - buf.cpos; - if(csz > cur) - csz = cur; - int err = pa_stream_write(m_stream, buf.data.data() + buf.cpos, csz << 2, nullptr, 0, PA_SEEK_RELATIVE); - if(err) - generic_pa_error("stream write", err); - if(csz == cur) - m_buffers.erase(m_buffers.begin()); - else - buf.cpos += csz; - size -= csz; + fprintf(stderr, "new sink %d (%s)\n", i->index, i->description); + fprintf(stderr, "rate %d\n", i->sample_spec.rate); + m_node_osdid_to_id[m_node_current_id] = i->index; + auto &node = m_nodes.emplace(i->index, node_info(this, i->index, m_node_current_id++, APLAY, i->name, i->description)).first->second; + + node.m_sink_port_count = i->channel_map.channels; + for(int chan=0; chan != i->channel_map.channels; chan++) { + pa_channel_position_t pos = i->channel_map.map[chan]; + node.m_position_codes.push_back(pos); + node.m_position_names.push_back(pa_channel_position_to_pretty_string(pos)); + for(uint32_t j = 0;; j++) { + if((position_infos[j].m_position == pos) || (position_infos[j].m_position == PA_CHANNEL_POSITION_MAX)) { + node.m_positions.push_back(position_infos[j].m_coords); + break; + } } } + m_generation++; } -void sound_pulse::i_stream_write_request(pa_stream *, size_t size, void *self) +void sound_pulse::i_sink_info_new(pa_context *, const pa_sink_info *i, int eol, void *self) { - static_cast<sound_pulse *>(self)->stream_write_request(size); + static_cast<sound_pulse *>(self)->sink_info_new(i, eol); } -void sound_pulse::mainloop_thread() +void sound_pulse::sink_input_info_change(stream_info *stream, const pa_sink_input_info *i, int eol) { - int err = 0; - pa_mainloop_run(m_mainloop, &err); - if(err) - generic_pa_error("mainloop stopped", err); + if(eol) + return; + + auto ni = m_nodes.find(i->sink); + if(ni != m_nodes.end()) + stream->m_target_node = &ni->second; + + for(uint32_t port = 0; port != stream->m_channels; port++) + stream->m_volumes[port] = pa_sw_volume_to_dB(i->volume.values[port]); + + fprintf(stderr, "change stream %d/%d sink=%s [%f %f]\n", stream->m_osdid, stream->m_pulse_id, stream->m_target_node->m_desc.c_str(), stream->m_volumes[0], stream->m_volumes[1]); + m_generation++; } -void sound_pulse::stop_mainloop(int err) +void sound_pulse::i_sink_input_info_change(pa_context *, const pa_sink_input_info *i, int eol, void *self) { - pa_mainloop_quit(m_mainloop, err); + fprintf(stderr, "i_sink_input_info_change %p %d\n", i, eol); + stream_info *stream = static_cast<stream_info *>(self); + stream->m_pulse->sink_input_info_change(stream, i, eol); } -int sound_pulse::init(osd_interface &osd, osd_options const &options) +void sound_pulse::context_subscribe(pa_subscription_event_type_t t, uint32_t idx) { - m_last_sample = 0; - m_setting_volume = false; - m_new_volume = false; - m_new_volume_value = 0; + // This is called with the thread locked + static const char *const evt[] = { "sink", "source", "sink-input", "source-output", "module", "client", "cache", "server", "autoload", "card" }; + static const char *const evt2[] = { "new", "change", "remove" }; + switch(int(t)) { + case PA_SUBSCRIPTION_EVENT_REMOVE | PA_SUBSCRIPTION_EVENT_SINK: + case PA_SUBSCRIPTION_EVENT_REMOVE | PA_SUBSCRIPTION_EVENT_SOURCE: { + auto si = m_nodes.find(idx); + if(si == m_nodes.end()) + break; + fprintf(stderr, "removing %s\n", si->second.m_desc.c_str()); + for(auto &istream : m_streams) + if(istream.second.m_target_node == &si->second) + istream.second.m_target_node = nullptr; + m_nodes.erase(si); + m_generation++; + break; + } + + case PA_SUBSCRIPTION_EVENT_NEW | PA_SUBSCRIPTION_EVENT_SINK: + pa_context_get_sink_info_by_index(m_context, idx, i_sink_info_new, this); + break; + + case PA_SUBSCRIPTION_EVENT_NEW | PA_SUBSCRIPTION_EVENT_SOURCE: + pa_context_get_source_info_by_index(m_context, idx, i_source_info, this); + break; + + case PA_SUBSCRIPTION_EVENT_CHANGE | PA_SUBSCRIPTION_EVENT_SERVER: + pa_context_get_server_info(m_context, i_server_info, (void *)this); + break; + + case PA_SUBSCRIPTION_EVENT_CHANGE | PA_SUBSCRIPTION_EVENT_SINK_INPUT: { + auto si1 = m_stream_pulse_id_to_osdid.find(idx); + if(si1 == m_stream_pulse_id_to_osdid.end()) + break; + auto si = m_streams.find(si1->second); + if(si == m_streams.end()) + break; + pa_context_get_sink_input_info(m_context, idx, i_sink_input_info_change, (void *)&si->second); + break; + } - m_mainloop = pa_mainloop_new(); - m_context = pa_context_new(pa_mainloop_get_api(m_mainloop), "MAME"); - pa_context_set_state_callback(m_context, i_context_notify, this); - int err = pa_context_connect(m_context, nullptr, PA_CONTEXT_NOFLAGS, nullptr); + default: + fprintf(stderr, "event %s %s %d\n", evt2[t>>4], evt[t&15], idx); + } +} - if(err) - generic_pa_error("pa_connect", err); +void sound_pulse::i_context_subscribe(pa_context *, pa_subscription_event_type_t t, uint32_t idx, void *self) +{ + static_cast<sound_pulse *>(self)->context_subscribe(t, idx); +} - make_pipes(); - m_thread = new std::thread(&sound_pulse::mainloop_thread, this); - char res = get_main(); - if(res != 'r') +int sound_pulse::init(osd_interface &osd, osd_options const &options) +{ + m_node_current_id = 1; + m_stream_current_id = 1; + m_generation = 0; + m_wait_stream = false; + m_wait_init = true; + + m_mainloop = pa_threaded_mainloop_new(); + m_context = pa_context_new(pa_threaded_mainloop_get_api(m_mainloop), "MAME"); + pa_context_set_state_callback(m_context, i_context_notify, this); + pa_context_set_subscribe_callback(m_context, i_context_subscribe, this); + pa_context_connect(m_context, nullptr, PA_CONTEXT_NOFLAGS, nullptr); + pa_threaded_mainloop_start(m_mainloop); + + pa_threaded_mainloop_lock(m_mainloop); + while(m_wait_init) + pa_threaded_mainloop_wait(m_mainloop); + pa_threaded_mainloop_unlock(m_mainloop); + if(m_generation >= 0x80000000) return 1; - const int sample_rate = options.sample_rate(); + return 0; +} + +uint32_t sound_pulse::get_generation() +{ + pa_threaded_mainloop_lock(m_mainloop); + uint32_t result = m_generation; + pa_threaded_mainloop_unlock(m_mainloop); + return result; +} + +osd::audio_info sound_pulse::get_information() +{ + osd::audio_info result; + pa_threaded_mainloop_lock(m_mainloop); + result.m_nodes.resize(m_nodes.size()); + result.m_default_sink = 0; + result.m_default_source = 0; + result.m_generation = m_generation; + uint32_t node = 0; + for(auto &inode : m_nodes) { + result.m_nodes[node].m_name = inode.second.m_desc; + result.m_nodes[node].m_id = inode.second.m_osdid; + result.m_nodes[node].m_rate = inode.second.m_rate; + result.m_nodes[node].m_sinks = inode.second.m_sink_port_count; + result.m_nodes[node].m_sources = inode.second.m_source_port_count; + result.m_nodes[node].m_port_names = inode.second.m_position_names; + result.m_nodes[node].m_port_positions = inode.second.m_positions; + + if(inode.second.m_name == m_default_audio_sink) + result.m_default_sink = inode.second.m_osdid; + if(inode.second.m_name == m_default_audio_source) + result.m_default_source = inode.second.m_osdid; + node ++; + } + + for(auto &istream : m_streams) + if(istream.second.m_target_node) + result.m_streams.emplace_back(osd::audio_info::stream_info { istream.second.m_osdid, istream.second.m_target_node->m_osdid, istream.second.m_volumes }); + + pa_threaded_mainloop_unlock(m_mainloop); + return result; +} + +uint32_t sound_pulse::stream_sink_open(uint32_t node, std::string name, uint32_t rate) +{ + pa_threaded_mainloop_lock(m_mainloop); + auto ni = m_node_osdid_to_id.find(node); + if(ni == m_node_osdid_to_id.end()) { + pa_threaded_mainloop_unlock(m_mainloop); + return 0; + } + node_info &snode = m_nodes.find(ni->second)->second; + + uint32_t id = m_stream_current_id++; + auto &stream = m_streams.emplace(id, stream_info(this, id, snode.m_sink_port_count)).first->second; pa_sample_spec ss; #ifdef LSB_FIRST @@ -304,108 +463,79 @@ int sound_pulse::init(osd_interface &osd, osd_options const &options) #else ss.format = PA_SAMPLE_S16BE; #endif - ss.rate = sample_rate; - ss.channels = 2; - m_stream = pa_stream_new(m_context, "main output", &ss, nullptr); - pa_stream_set_state_callback(m_stream, i_stream_notify, this); - pa_stream_set_write_callback(m_stream, i_stream_write_request, this); + ss.rate = rate; + ss.channels = stream.m_channels; + stream.m_stream = pa_stream_new(m_context, name.c_str(), &ss, nullptr); + pa_stream_set_state_callback(stream.m_stream, i_stream_notify, &stream); + pa_stream_set_write_callback(stream.m_stream, i_stream_write_request, &stream); pa_buffer_attr battr; - battr.fragsize = sample_rate / 1000; - battr.maxlength = uint32_t(-1); - battr.minreq = sample_rate / 1000; + battr.fragsize = uint32_t(-1); + battr.maxlength = 1024; + battr.minreq = uint32_t(-1); battr.prebuf = uint32_t(-1); - battr.tlength = sample_rate / 1000; + battr.tlength = uint32_t(-1); - err = pa_stream_connect_playback(m_stream, nullptr, &battr, PA_STREAM_ADJUST_LATENCY, nullptr, nullptr); + int err = pa_stream_connect_playback(stream.m_stream, snode.m_name.c_str(), &battr, pa_stream_flags_t(PA_STREAM_ADJUST_LATENCY|PA_STREAM_START_UNMUTED), nullptr, nullptr); if(err) generic_pa_error("stream connect playback", err); - res = get_main(); - if(res != 'r') - return 1; - return 0; -} + stream.m_target_node = &snode; -void sound_pulse::update_audio_stream(bool is_throttled, const s16 *buffer, int samples_this_frame) -{ - std::unique_lock<std::mutex> lock(m_mutex); - m_buffers.resize(m_buffers.size() + 1); - auto &buf = m_buffers.back(); - buf.cpos = 0; - buf.data.resize(samples_this_frame); - memcpy(buf.data.data(), buffer, samples_this_frame*4); - m_last_sample = buf.data.back(); - - if(m_buffers.size() > 10) - // If there way too many buffers, drop some so only 10 are left (roughly 0.2s) - m_buffers.erase(m_buffers.begin(), m_buffers.begin() + m_buffers.size() - 10); - - else if(m_buffers.size() >= 5) - // If there are too many buffers, remove five sample per buffer - // to slowly resync to reduce latency (4 seconds to - // compensate one buffer roughly) - buf.cpos = 5; + m_wait_stream = true; + while(m_wait_stream) + pa_threaded_mainloop_wait(m_mainloop); + + stream.m_pulse_id = pa_stream_get_index(stream.m_stream); + m_stream_pulse_id_to_osdid[stream.m_pulse_id] = id; + + fprintf(stderr, "stream id %d\n", stream.m_pulse_id); + pa_threaded_mainloop_unlock(m_mainloop); + + return id; } -void sound_pulse::volume_set_notify(int success) +void sound_pulse::stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) { - std::unique_lock<std::mutex> lock(m_mutex); - if(m_new_volume) { - m_new_volume = false; - pa_cvolume vol; - pa_cvolume_set(&vol, 2, pa_sw_volume_from_dB(m_new_volume_value)); - pa_context_set_sink_input_volume(m_context, pa_stream_get_index(m_stream), &vol, i_volume_set_notify, this); - } else - m_setting_volume = false; + pa_threaded_mainloop_lock(m_mainloop); + auto si = m_streams.find(id); + if(si == m_streams.end()) { + pa_threaded_mainloop_unlock(m_mainloop); + return; + } + si->second.m_buffer.push(buffer, samples_this_frame); + pa_threaded_mainloop_unlock(m_mainloop); } -void sound_pulse::i_volume_set_notify(pa_context *, int success, void *self) +void sound_pulse::stream_set_volumes(uint32_t id, const std::vector<float> &db) { - static_cast<sound_pulse *>(self)->volume_set_notify(success); } -void sound_pulse::set_mastervolume(int attenuation) +void sound_pulse::stream_close(uint32_t id) { - if(!m_stream) + pa_threaded_mainloop_lock(m_mainloop); + auto si = m_streams.find(id); + if(si == m_streams.end()) { + pa_threaded_mainloop_unlock(m_mainloop); return; - - - std::unique_lock<std::mutex> lock(m_mutex); - if(m_setting_volume) { - m_new_volume = true; - m_new_volume_value = attenuation; - } else { - m_setting_volume = true; - pa_cvolume vol; - pa_cvolume_set(&vol, 2, pa_sw_volume_from_dB(attenuation)); - pa_context_set_sink_input_volume(m_context, pa_stream_get_index(m_stream), &vol, i_volume_set_notify, this); } + stream_info &stream = si->second; + pa_stream_set_state_callback(stream.m_stream, nullptr, &stream); + pa_stream_set_write_callback(stream.m_stream, nullptr, &stream); + pa_stream_disconnect(stream.m_stream); + m_streams.erase(si); + pa_threaded_mainloop_unlock(m_mainloop); } void sound_pulse::exit() { - if(!m_stream) - return; + for(const auto &si : m_streams) { + pa_stream_disconnect(si.second.m_stream); + pa_stream_unref(si.second.m_stream); + } - pa_stream_disconnect(m_stream); - while(get_main() != 't') {} - pa_stream_unref(m_stream); pa_context_unref(m_context); - m_thread->join(); - pa_mainloop_free(m_mainloop); - delete m_thread; - - close(m_pipe_to_sub[0]); - close(m_pipe_to_sub[1]); - close(m_pipe_to_main[0]); - close(m_pipe_to_main[1]); - - m_thread = nullptr; - m_mainloop = nullptr; - m_context = nullptr; - m_stream = nullptr; - m_buffers.clear(); + pa_threaded_mainloop_free(m_mainloop); } #else diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp index 7f4993bea35..35c11eae86d 100644 --- a/src/osd/modules/sound/sdl_sound.cpp +++ b/src/osd/modules/sound/sdl_sound.cpp @@ -24,450 +24,205 @@ #include <cmath> #include <fstream> #include <memory> +#include <map> namespace osd { namespace { -//============================================================ -// DEBUGGING -//============================================================ - -#define LOG_SOUND 0 - -#define SDLMAME_SOUND_LOG "sound.log" - - -//============================================================ -// CLASS -//============================================================ - class sound_sdl : public osd_module, public sound_module { public: - - // number of samples per SDL callback - static inline constexpr int SDL_XFER_SAMPLES = 512; - sound_sdl() : - osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(), - sample_rate(0), - sdl_xfer_samples(SDL_XFER_SAMPLES), - stream_in_initialized(0), - attenuation(0), - buf_locked(0), - stream_buffer(nullptr), - stream_buffer_size(0), - buffer_underflows(0), - buffer_overflows(0) + osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module() { } + virtual ~sound_sdl() { } virtual int init(osd_interface &osd, const osd_options &options) override; virtual void exit() override; - // sound_module + virtual bool external_per_channel_volume() override { return false; } + virtual bool split_streams_per_source() override { return false; } - virtual void update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) override; - virtual void set_mastervolume(int attenuation) override; + virtual uint32_t get_generation() override; + virtual osd::audio_info get_information() override; + virtual uint32_t stream_sink_open(uint32_t node, std::string name, uint32_t rate) override; + virtual void stream_close(uint32_t id) override; + virtual void stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) override; private: - class ring_buffer - { - public: - ring_buffer(size_t size); - - size_t data_size() const { return (tail - head + buffer_size) % buffer_size; } - size_t free_size() const { return (head - tail - 1 + buffer_size) % buffer_size; } - int append(const void *data, size_t size); - int pop(void *data, size_t size); - - private: - std::unique_ptr<int8_t []> const buffer; - size_t const buffer_size; - int head = 0, tail = 0; + struct device_info { + std::string m_name; + int m_freq; + uint8_t m_channels; + device_info(const char *name, int freq, uint8_t channels) : m_name(name), m_freq(freq), m_channels(channels) {} }; - static void sdl_callback(void *userdata, Uint8 *stream, int len); - - void lock_buffer(); - void unlock_buffer(); - void attenuate(int16_t *data, int bytes); - void copy_sample_data(bool is_throttled, const int16_t *data, int bytes_to_copy); - int sdl_create_buffers(); - void sdl_destroy_buffers(); - - int sample_rate; - int sdl_xfer_samples; - int stream_in_initialized; - int attenuation; + struct stream_info { + uint32_t m_id; + SDL_AudioDeviceID m_sdl_id; + abuffer m_buffer; + stream_info(uint32_t id, uint8_t channels) : m_id(id), m_sdl_id(0), m_buffer(channels) {} + }; - int buf_locked; - std::unique_ptr<ring_buffer> stream_buffer; - uint32_t stream_buffer_size; + std::vector<device_info> m_devices; + uint32_t m_default_sink; + uint32_t m_stream_next_id; + std::map<uint32_t, std::unique_ptr<stream_info>> m_streams; - // diagnostics - int buffer_underflows; - int buffer_overflows; - std::unique_ptr<std::ofstream> sound_log; + static void sink_callback(void *userdata, Uint8 *stream, int len); }; - -//============================================================ -// PARAMETERS -//============================================================ - -// maximum audio latency -#define MAX_AUDIO_LATENCY 5 - -//============================================================ -// ring_buffer - constructor -//============================================================ - -sound_sdl::ring_buffer::ring_buffer(size_t size) - : buffer(std::make_unique<int8_t []>(size + 1)), buffer_size(size + 1) -{ - // A size+1 bytes buffer is allocated because it can never be full. - // Otherwise the case head == tail couldn't be distinguished between a - // full buffer and an empty buffer. - std::fill_n(buffer.get(), size + 1, 0); -} - //============================================================ -// ring_buffer::append +// sound_sdl::init //============================================================ -int sound_sdl::ring_buffer::append(const void *data, size_t size) +int sound_sdl::init(osd_interface &osd, const osd_options &options) { - if (free_size() < size) - return -1; + m_stream_next_id = 1; - int8_t const *const data8 = reinterpret_cast<int8_t const *>(data); - size_t sz = buffer_size - tail; - if (size <= sz) - sz = size; - else - std::copy_n(&data8[sz], size - sz, &buffer[0]); - - std::copy_n(data8, sz, &buffer[tail]); - tail = (tail + size) % buffer_size; - - return 0; -} - -//============================================================ -// ring_buffer::pop -//============================================================ - -int sound_sdl::ring_buffer::pop(void *data, size_t size) -{ - if (data_size() < size) + if(SDL_InitSubSystem(SDL_INIT_AUDIO)) { + osd_printf_error("Could not initialize SDL %s\n", SDL_GetError()); return -1; - - int8_t *const data8 = reinterpret_cast<int8_t *>(data); - size_t sz = buffer_size - head; - if (size <= sz) - sz = size; - else - { - std::copy_n(&buffer[0], size - sz, &data8[sz]); - std::fill_n(&buffer[0], size - sz, 0); } - std::copy_n(&buffer[head], sz, data8); - std::fill_n(&buffer[head], sz, 0); - head = (head + size) % buffer_size; - - return 0; -} - -//============================================================ -// sound_sdl - destructor -//============================================================ - -//============================================================ -// lock_buffer -//============================================================ -void sound_sdl::lock_buffer() -{ - if (!buf_locked) - SDL_LockAudio(); - buf_locked++; - - if (LOG_SOUND) - *sound_log << "locking\n"; -} - -//============================================================ -// unlock_buffer -//============================================================ -void sound_sdl::unlock_buffer() -{ - buf_locked--; - if (!buf_locked) - SDL_UnlockAudio(); - - if (LOG_SOUND) - *sound_log << "unlocking\n"; - -} - -//============================================================ -// Apply attenuation -//============================================================ - -void sound_sdl::attenuate(int16_t *data, int bytes_to_copy) -{ - int level = (int) (pow(10.0, (double) attenuation / 20.0) * 128.0); - int count = bytes_to_copy / sizeof(*data); - while (count > 0) - { - *data = (*data * level) >> 7; /* / 128 */ - data++; - count--; + osd_printf_verbose("Audio: Start initialization\n"); + char const *const audio_driver = SDL_GetCurrentAudioDriver(); + osd_printf_verbose("Audio: Driver is %s\n", audio_driver ? audio_driver : "not initialized"); + + // Capture is not implemented in SDL2, and the enumeration + // interface is different in SDL3 + int dev_count = SDL_GetNumAudioDevices(0); + for(int i=0; i != dev_count; i++) { + SDL_AudioSpec spec; + const char *name = SDL_GetAudioDeviceName(i, 0); + int err = SDL_GetAudioDeviceSpec(i, 0, &spec); + if(!err) + m_devices.emplace_back(name, spec.freq, spec.channels); } + char *def_name; + SDL_AudioSpec def_spec; + if(!SDL_GetDefaultAudioInfo(&def_name, &def_spec, 0)) { + uint32_t idx; + for(idx = 0; idx != m_devices.size() && m_devices[idx].m_name != def_name; idx++); + if(idx == m_devices.size()) + m_devices.emplace_back(def_name, def_spec.freq, def_spec.channels); + m_default_sink = idx+1; + SDL_free(def_name); + } else + m_default_sink = 0; + return 0; } -//============================================================ -// copy_sample_data -//============================================================ - -void sound_sdl::copy_sample_data(bool is_throttled, const int16_t *data, int bytes_to_copy) -{ - lock_buffer(); - int const err = stream_buffer->append(data, bytes_to_copy); - unlock_buffer(); - - if (LOG_SOUND && err) - *sound_log << "Late detection of overflow. This shouldn't happen.\n"; -} - - -//============================================================ -// update_audio_stream -//============================================================ - -void sound_sdl::update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) +void sound_sdl::exit() { - // if nothing to do, don't do it - if (sample_rate == 0 || !stream_buffer) - return; - - if (!stream_in_initialized) - { - // Fill in some zeros to prevent an initial buffer underflow - int8_t zero = 0; - size_t zsize = stream_buffer->free_size() / 2; - while (zsize--) - stream_buffer->append(&zero, 1); - - // start playing - SDL_PauseAudio(0); - stream_in_initialized = 1; - } - - size_t bytes_this_frame = samples_this_frame * sizeof(*buffer) * 2; - size_t free_size = stream_buffer->free_size(); - size_t data_size = stream_buffer->data_size(); - - if (stream_buffer->free_size() < bytes_this_frame) { - if (LOG_SOUND) - util::stream_format(*sound_log, "Overflow: DS=%u FS=%u BTF=%u\n", data_size, free_size, bytes_this_frame); - buffer_overflows++; - return; - } - - copy_sample_data(is_throttled, buffer, bytes_this_frame); - - size_t nfree_size = stream_buffer->free_size(); - size_t ndata_size = stream_buffer->data_size(); - if (LOG_SOUND) - util::stream_format(*sound_log, "Appended data: DS=%u(%u) FS=%u(%u) BTF=%u\n", data_size, ndata_size, free_size, nfree_size, bytes_this_frame); + SDL_QuitSubSystem(SDL_INIT_AUDIO); } - - -//============================================================ -// set_mastervolume -//============================================================ - -void sound_sdl::set_mastervolume(int _attenuation) +uint32_t sound_sdl::get_generation() { - // clamp the attenuation to 0-32 range - attenuation = std::clamp(_attenuation, -32, 0); - - if (stream_in_initialized) - { - if (attenuation == -32) - SDL_PauseAudio(1); - else - SDL_PauseAudio(0); - } + // sdl2 is not dynamic w.r.t devices + return 1; } -//============================================================ -// sdl_callback -//============================================================ -void sound_sdl::sdl_callback(void *userdata, Uint8 *stream, int len) +osd::audio_info sound_sdl::get_information() { - sound_sdl *thiz = reinterpret_cast<sound_sdl *>(userdata); - size_t const free_size = thiz->stream_buffer->free_size(); - size_t const data_size = thiz->stream_buffer->data_size(); - - if (data_size < len) - { - thiz->buffer_underflows++; - if (LOG_SOUND) - util::stream_format(*thiz->sound_log, "Underflow at sdl_callback: DS=%u FS=%u Len=%d\n", data_size, free_size, len); + enum { FL, FR, FC, LFE, BL, BR, BC, SL, SR }; + static const char *const posname[9] = { "FL", "FR", "FC", "LFE", "BL", "BR", "BC", "SL", "SR" }; + + static std::array<double, 3> pos3d[9] = { + { -0.2, 0.0, 1.0 }, + { 0.2, 0.0, 1.0 }, + { 0.0, 0.0, 1.0 }, + { 0.0, -0.5, 1.0 }, + { -0.2, 0.0, -0.5 }, + { 0.2, 0.0, -0.5 }, + { 0.0, 0.0, -0.5 }, + { -0.2, 0.0, 0.0 }, + { 0.2, 0.0, 0.0 }, + }; + + static const uint32_t positions[8][8] = { + { FC }, + { FL, FR }, + { FL, FR, LFE }, + { FL, FR, BL, BR }, + { FL, FR, LFE, BL, BR }, + { FL, FR, FC, LFE, BL, BR }, + { FL, FR, FC, LFE, BC, SL, SR }, + { FL, FR, FC, LFE, BL, BR, SL, SR } + }; - // Maybe read whatever is left in the stream_buffer anyway? - memset(stream, 0, len); - return; + osd::audio_info result; + result.m_nodes.resize(m_devices.size()); + result.m_default_sink = m_default_sink; + result.m_default_source = 0; + result.m_generation = 1; + for(uint32_t node = 0; node != m_devices.size(); node++) { + result.m_nodes[node].m_name = m_devices[node].m_name; + result.m_nodes[node].m_id = node + 1; + uint32_t freq = m_devices[node].m_freq; + result.m_nodes[node].m_rate = audio_rate_range{ freq, freq, freq }; + result.m_nodes[node].m_sinks = m_devices[node].m_channels; + for(uint32_t port = 0; port != m_devices[node].m_channels; port++) { + uint32_t pos = positions[m_devices[node].m_channels-1][port]; + result.m_nodes[node].m_port_names.push_back(posname[pos]); + result.m_nodes[node].m_port_positions.push_back(pos3d[pos]); + } } - - int err = thiz->stream_buffer->pop((void *)stream, len); - if (LOG_SOUND && err) - *thiz->sound_log << "Late detection of underflow. This shouldn't happen.\n"; - - thiz->attenuate((int16_t *)stream, len); - - if (LOG_SOUND) - util::stream_format(*thiz->sound_log, "callback: xfer DS=%u FS=%u Len=%d\n", data_size, free_size, len); + return result; } - -//============================================================ -// sound_sdl::init -//============================================================ - -int sound_sdl::init(osd_interface &osd, const osd_options &options) +uint32_t sound_sdl::stream_sink_open(uint32_t node, std::string name, uint32_t rate) { - int n_channels = 2; - int audio_latency; - SDL_AudioSpec aspec, obtained; - - if (LOG_SOUND) - sound_log = std::make_unique<std::ofstream>(SDLMAME_SOUND_LOG); - - // skip if sound disabled - sample_rate = options.sample_rate(); - if (sample_rate != 0) - { - if (SDL_InitSubSystem(SDL_INIT_AUDIO)) - { - osd_printf_error("Could not initialize SDL %s\n", SDL_GetError()); - return -1; - } - - osd_printf_verbose("Audio: Start initialization\n"); - char const *const audio_driver = SDL_GetCurrentAudioDriver(); - osd_printf_verbose("Audio: Driver is %s\n", audio_driver ? audio_driver : "not initialized"); - - sdl_xfer_samples = SDL_XFER_SAMPLES; - stream_in_initialized = 0; - - // set up the audio specs - aspec.freq = sample_rate; - aspec.format = AUDIO_S16SYS; // keep endian independent - aspec.channels = n_channels; - aspec.samples = sdl_xfer_samples; - aspec.callback = sdl_callback; - aspec.userdata = this; - - if (SDL_OpenAudio(&aspec, &obtained) < 0) - goto cant_start_audio; - - osd_printf_verbose("Audio: frequency: %d, channels: %d, samples: %d\n", - obtained.freq, obtained.channels, obtained.samples); - - sdl_xfer_samples = obtained.samples; - - // pin audio latency - audio_latency = std::clamp(options.audio_latency(), 1, MAX_AUDIO_LATENCY); - - // compute the buffer sizes - stream_buffer_size = (sample_rate * 2 * sizeof(int16_t) * (2 + audio_latency)) / 30; - stream_buffer_size = (stream_buffer_size / 1024) * 1024; - if (stream_buffer_size < 1024) - stream_buffer_size = 1024; - - // create the buffers - if (sdl_create_buffers()) - goto cant_create_buffers; - - // set the startup volume - set_mastervolume(attenuation); - osd_printf_verbose("Audio: End initialization\n"); + device_info &dev = m_devices[node-1]; + std::unique_ptr<stream_info> stream = std::make_unique<stream_info>(m_stream_next_id ++, dev.m_channels); + + SDL_AudioSpec dspec, ospec; + dspec.freq = rate; + dspec.format = AUDIO_S16SYS; + dspec.channels = dev.m_channels; + dspec.samples = 512; + dspec.callback = sink_callback; + dspec.userdata = stream.get(); + + stream->m_sdl_id = SDL_OpenAudioDevice(dev.m_name.c_str(), 0, &dspec, &ospec, 0); + if(!stream->m_sdl_id) return 0; - - // error handling - cant_create_buffers: - cant_start_audio: - osd_printf_verbose("Audio: Initialization failed. SDL error: %s\n", SDL_GetError()); - - return -1; - } - - return 0; + SDL_PauseAudioDevice(stream->m_sdl_id, 0); + uint32_t id = stream->m_id; + m_streams[stream->m_id] = std::move(stream); + return id; } - - -//============================================================ -// sdl_kill -//============================================================ - -void sound_sdl::exit() +void sound_sdl::stream_close(uint32_t id) { - // if nothing to do, don't do it - if (sample_rate == 0) + auto si = m_streams.find(id); + if(si == m_streams.end()) return; - - osd_printf_verbose("sdl_kill: closing audio\n"); - SDL_CloseAudio(); - - SDL_QuitSubSystem(SDL_INIT_AUDIO); - - // kill the buffers - sdl_destroy_buffers(); - - // print out over/underflow stats - if (buffer_overflows || buffer_underflows) - osd_printf_verbose("Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); - - if (LOG_SOUND) - { - util::stream_format(*sound_log, "Sound buffer: overflows=%d underflows=%d\n", buffer_overflows, buffer_underflows); - sound_log.reset(); - } + SDL_CloseAudioDevice(si->second->m_sdl_id); + m_streams.erase(si); } - - -//============================================================ -// dsound_create_buffers -//============================================================ - -int sound_sdl::sdl_create_buffers() +void sound_sdl::stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) { - osd_printf_verbose("sdl_create_buffers: creating stream buffer of %u bytes\n", stream_buffer_size); - - stream_buffer = std::make_unique<ring_buffer>(stream_buffer_size); - buf_locked = 0; - return 0; + auto si = m_streams.find(id); + if(si == m_streams.end()) + return; + stream_info *stream = si->second.get(); + SDL_LockAudioDevice(stream->m_sdl_id); + stream->m_buffer.push(buffer, samples_this_frame); + SDL_UnlockAudioDevice(stream->m_sdl_id); } -//============================================================ -// sdl_destroy_buffers -//============================================================ - -void sound_sdl::sdl_destroy_buffers() +void sound_sdl::sink_callback(void *userdata, uint8_t *data, int len) { - // release the buffer - stream_buffer.reset(); + stream_info *stream = reinterpret_cast<stream_info *>(userdata); + stream->m_buffer.get((int16_t *)data, len / 2 / stream->m_buffer.channels()); } } // anonymous namespace diff --git a/src/osd/modules/sound/sound_module.cpp b/src/osd/modules/sound/sound_module.cpp new file mode 100644 index 00000000000..5dc13eb3246 --- /dev/null +++ b/src/osd/modules/sound/sound_module.cpp @@ -0,0 +1,61 @@ +// license:BSD-3-Clause +// copyright-holders:O. Galibert + + +#include "emu.h" +#include "sound_module.h" + +void sound_module::abuffer::get(int16_t *data, uint32_t samples) +{ + uint32_t pos = 0; + while(pos != samples) { + if(m_buffers.empty()) { + while(pos != samples) { + memcpy(data, m_last_sample.data(), m_channels*2); + data += m_channels; + pos ++; + } + break; + } + + auto &buf = m_buffers.front(); + if(buf.m_data.empty()) { + m_buffers.erase(m_buffers.begin()); + continue; + } + + uint32_t avail = buf.m_data.size() / m_channels - buf.m_cpos; + if(avail > samples - pos) { + avail = samples - pos; + memcpy(data, buf.m_data.data() + buf.m_cpos * m_channels, avail * 2 * m_channels); + buf.m_cpos += avail; + break; + } + + memcpy(data, buf.m_data.data() + buf.m_cpos * m_channels, avail * 2 * m_channels); + m_buffers.erase(m_buffers.begin()); + pos += avail; + data += avail * m_channels; + } +} + +void sound_module::abuffer::push(const int16_t *data, uint32_t samples) +{ + m_buffers.resize(m_buffers.size() + 1); + auto &buf = m_buffers.back(); + buf.m_cpos = 0; + buf.m_data.resize(samples * m_channels); + memcpy(buf.m_data.data(), data, samples * 2 * m_channels); + memcpy(m_last_sample.data(), data + (samples-1) * m_channels, 2 * m_channels); + + if(m_buffers.size() > 10) + // If there are way too many buffers, drop some so only 10 are left (roughly 0.2s) + m_buffers.erase(m_buffers.begin(), m_buffers.begin() + m_buffers.size() - 10); + + else if(m_buffers.size() >= 5) + // If there are too many buffers, remove five samples per buffer + // to slowly resync to reduce latency (4 seconds to + // compensate one buffer, roughly) + buf.m_cpos = 5; +} + diff --git a/src/osd/modules/sound/sound_module.h b/src/osd/modules/sound/sound_module.h index 088da5ea8d0..2498db84107 100644 --- a/src/osd/modules/sound/sound_module.h +++ b/src/osd/modules/sound/sound_module.h @@ -9,11 +9,12 @@ #pragma once -#include <cstdint> +#include <osdepend.h> -//============================================================ -// CONSTANTS -//============================================================ +#include <cstdint> +#include <array> +#include <vector> +#include <string> #define OSD_SOUND_PROVIDER "sound" @@ -22,8 +23,57 @@ class sound_module public: virtual ~sound_module() = default; - virtual void update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) = 0; - virtual void set_mastervolume(int attenuation) = 0; + virtual uint32_t get_generation() { return 1; } + virtual osd::audio_info get_information() { + osd::audio_info result; + result.m_generation = 1; + result.m_default_sink = 1; + result.m_default_source = 0; + result.m_nodes.resize(1); + result.m_nodes[0].m_name = ""; + result.m_nodes[0].m_id = 1; + result.m_nodes[0].m_rate.m_default_rate = 0; // Magic value meaning "use configured sample rate" + result.m_nodes[0].m_rate.m_min_rate = 0; + result.m_nodes[0].m_rate.m_max_rate = 0; + result.m_nodes[0].m_sinks = 2; + result.m_nodes[0].m_sources = 0; + result.m_nodes[0].m_port_names.push_back("L"); + result.m_nodes[0].m_port_names.push_back("R"); + result.m_nodes[0].m_port_positions.emplace_back(std::array<double, 3>({ -0.2, 0.0, 1.0 })); + result.m_nodes[0].m_port_positions.emplace_back(std::array<double, 3>({ 0.2, 0.0, 1.0 })); + result.m_streams.resize(1); + result.m_streams[0].m_id = 1; + result.m_streams[0].m_node = 1; + return result; + } + virtual bool external_per_channel_volume() { return false; } + virtual bool split_streams_per_source() { return false; } + + virtual uint32_t stream_sink_open(uint32_t node, std::string name, uint32_t rate) { return 1; } + virtual uint32_t stream_source_open(uint32_t node, std::string name, uint32_t rate) { return 0; } + virtual void stream_set_volumes(uint32_t id, const std::vector<float> &db) {} + virtual void stream_close(uint32_t id) {} + virtual void stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) {} + virtual void stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) {} + +protected: + class abuffer { + public: + abuffer(uint32_t channels) : m_channels(channels), m_last_sample(channels, 0) {} + void get(int16_t *data, uint32_t samples); + void push(const int16_t *data, uint32_t samples); + uint32_t channels() const { return m_channels; } + + private: + struct buffer { + uint32_t m_cpos; + std::vector<int16_t> m_data; + }; + + uint32_t m_channels; + std::vector<int16_t> m_last_sample; + std::vector<buffer> m_buffers; + }; }; #endif // MAME_OSD_SOUND_SOUND_MODULE_H diff --git a/src/osd/modules/sound/xaudio2_sound.cpp b/src/osd/modules/sound/xaudio2_sound.cpp index d0243ba1267..34973c4e0cb 100644 --- a/src/osd/modules/sound/xaudio2_sound.cpp +++ b/src/osd/modules/sound/xaudio2_sound.cpp @@ -214,8 +214,7 @@ public: void exit() override; // sound_module - void update_audio_stream(bool is_throttled, int16_t const *buffer, int samples_this_frame) override; - void set_mastervolume(int attenuation) override; + void stream_update(uint32_t, int16_t const *buffer, int samples_this_frame) override; private: // Xaudio callbacks @@ -376,11 +375,11 @@ void sound_xaudio2::exit() } //============================================================ -// update_audio_stream +// stream_update //============================================================ -void sound_xaudio2::update_audio_stream( - bool is_throttled, +void sound_xaudio2::stream_update( + uint32_t, int16_t const *buffer, int samples_this_frame) { @@ -414,32 +413,6 @@ void sound_xaudio2::update_audio_stream( } //============================================================ -// set_mastervolume -//============================================================ - -void sound_xaudio2::set_mastervolume(int attenuation) -{ - if (!m_initialized) - return; - - assert(m_sourceVoice); - - HRESULT result; - - // clamp the attenuation to 0-32 range - attenuation = std::clamp(attenuation, -32, 0); - - // Ranges from 1.0 to XAUDIO2_MAX_VOLUME_LEVEL indicate additional gain - // Ranges from 0 to 1.0 indicate a reduced volume level - // 0 indicates silence - // We only support a reduction from 1.0, so we generate values in the range 0.0 to 1.0 - float scaledVolume = (32.0f + attenuation) / 32.0f; - - // set the master volume - HR_RETV(m_sourceVoice->SetVolume(scaledVolume)); -} - -//============================================================ // IXAudio2VoiceCallback::OnBufferEnd //============================================================ diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h index 8e9a4be6d7a..a64ea2579c4 100644 --- a/src/osd/osdepend.h +++ b/src/osd/osdepend.h @@ -16,6 +16,7 @@ #include "emufwd.h" #include "bitmap.h" +#include "interface/audio.h" #include "interface/midiport.h" #include <cstdint> @@ -23,7 +24,7 @@ #include <string> #include <string_view> #include <vector> - +#include <array> // forward references class input_type_entry; @@ -64,7 +65,6 @@ public: class osd_interface { public: - // general overridables virtual void init(running_machine &machine) = 0; virtual void update(bool skip_redraw) = 0; @@ -77,9 +77,17 @@ public: virtual void wait_for_debugger(device_t &device, bool firststop) = 0; // audio overridables - virtual void update_audio_stream(const int16_t *buffer, int samples_this_frame) = 0; - virtual void set_mastervolume(int attenuation) = 0; virtual bool no_sound() = 0; + virtual bool sound_external_per_channel_volume() = 0; + virtual bool sound_split_streams_per_source() = 0; + virtual uint32_t sound_get_generation() = 0; + virtual osd::audio_info sound_get_information() = 0; + virtual uint32_t sound_stream_sink_open(uint32_t node, std::string name, uint32_t rate) = 0; + virtual uint32_t sound_stream_source_open(uint32_t node, std::string name, uint32_t rate) = 0; + virtual void sound_stream_close(uint32_t id) = 0; + virtual void sound_stream_sink_update(uint32_t id, const int16_t *buffer, int samples_this_frame) = 0; + virtual void sound_stream_source_update(uint32_t id, int16_t *buffer, int samples_this_frame) = 0; + virtual void sound_stream_set_volumes(uint32_t id, const std::vector<float> &db) = 0; // input overridables virtual void customize_input_type_list(std::vector<input_type_entry> &typelist) = 0; |