Previous 199869 Revisions Next

r26431 Tuesday 26th November, 2013 at 17:58:07 UTC by Osso
Modernized wave sound device. (nw)
[src/emu/sound]wave.c wave.h

trunk/src/emu/sound/wave.c
r26430r26431
1616#include "emu.h"
1717#include "imagedev/cassette.h"
1818#include "wave.h"
19#include "devlegcy.h"
2019
2120#define ALWAYS_PLAY_SOUND   0
2221
23static STREAM_UPDATE( wave_sound_update )
22
23
24void wave_device::static_set_cassette_tag(device_t &device, const char *cassette_tag)
2425{
25   cassette_image_device *cass = (cassette_image_device *)param;
26   wave_device &wave = downcast<wave_device &>(device);
27   wave.m_cassette_tag = cassette_tag;
28}
29
30const device_type WAVE = &device_creator<wave_device>;
31
32wave_device::wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
33   : device_t(mconfig, WAVE, "Wave", tag, owner, clock, "wawe", __FILE__),
34      device_sound_interface(mconfig, *this)
35{
36   m_cassette_tag = 0;
37}
38
39//-------------------------------------------------
40//  device_config_complete - perform any
41//  operations now that the configuration is
42//  complete
43//-------------------------------------------------
44
45void wave_device::device_config_complete()
46{
47}
48
49//-------------------------------------------------
50//  device_start - device-specific startup
51//-------------------------------------------------
52
53void wave_device::device_start()
54{
55   speaker_device_iterator spkiter(machine().root_device());
56   int speakers = spkiter.count();
57   if (speakers > 1)
58      machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate(), this);
59   else
60      machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate(), this);
61}
62
63//-------------------------------------------------
64//  sound_stream_update - handle a stream update
65//-------------------------------------------------
66
67void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
68{
69   cassette_image_device *cass = machine().device<cassette_image_device>(m_cassette_tag);
2670   cassette_image *cassette;
2771   cassette_state state;
2872   double time_index;
r26430r26431
64108         memset(right_buffer, 0, sizeof(*right_buffer) * samples);
65109   }
66110}
67
68
69
70static DEVICE_START( wave )
71{
72   cassette_image_device *image = NULL;
73
74   assert( device != NULL );
75   assert( device->static_config() != NULL );
76   speaker_device_iterator spkiter(device->machine().root_device());
77   int speakers = spkiter.count();
78   image = dynamic_cast<cassette_image_device *>(device->machine().device( (const char *)device->static_config()));
79   if (speakers > 1)
80      device->machine().sound().stream_alloc(*device, 0, 2, device->machine().sample_rate(), (void *)image, wave_sound_update);
81   else
82      device->machine().sound().stream_alloc(*device, 0, 1, device->machine().sample_rate(), (void *)image, wave_sound_update);
83}
84
85
86const device_type WAVE = &device_creator<wave_device>;
87
88wave_device::wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
89   : device_t(mconfig, WAVE, "Wave", tag, owner, clock, "wawe", __FILE__),
90      device_sound_interface(mconfig, *this)
91{
92}
93
94//-------------------------------------------------
95//  device_config_complete - perform any
96//  operations now that the configuration is
97//  complete
98//-------------------------------------------------
99
100void wave_device::device_config_complete()
101{
102}
103
104//-------------------------------------------------
105//  device_start - device-specific startup
106//-------------------------------------------------
107
108void wave_device::device_start()
109{
110   DEVICE_START_NAME( wave )(this);
111}
112
113//-------------------------------------------------
114//  sound_stream_update - handle a stream update
115//-------------------------------------------------
116
117void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
118{
119   // should never get here
120   fatalerror("sound_stream_update called; not applicable to legacy sound devices\n");
121}
trunk/src/emu/sound/wave.h
r26430r26431
1313{
1414public:
1515   wave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
16
16   
17   static void static_set_cassette_tag(device_t &device, const char *cassette_tag);
18   
1719protected:
1820   // device-level overrides
1921   virtual void device_config_complete();
r26430r26431
2123
2224   // sound stream update overrides
2325   virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples);
26
2427private:
28   const char *m_cassette_tag;
2529};
2630
2731extern const device_type WAVE;
r26430r26431
3337
3438#define MCFG_SOUND_WAVE_ADD(_tag, _cass_tag) \
3539   MCFG_SOUND_ADD( _tag, WAVE, 0 ) \
36   MCFG_DEVICE_CONFIG( _cass_tag )
40   wave_device::static_set_cassette_tag(*device, _cass_tag);
3741
3842#endif /* __WAVE_H__ */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team