summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/tms3615.h
blob: b3325ebc354359de324d03fbe4d4691777785c81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// license:BSD-3-Clause
// copyright-holders:Juergen Buchmueller
#ifndef MAME_SOUND_TMS3615_H
#define MAME_SOUND_TMS3615_H

#pragma once


//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************


// ======================> tms3615_device

class tms3615_device : public device_t, public device_sound_interface
{
public:
	static constexpr unsigned FOOTAGE_8 = 0;
	static constexpr unsigned FOOTAGE_16 = 1;

	tms3615_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	void enable_w(int enable);

protected:
	// device-level overrides
	virtual void device_start() override;

	// sound stream update overrides
	virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;

private:
	static constexpr unsigned TMS3615_TONES = 13;
	static const int divisor[TMS3615_TONES];

	sound_stream *m_channel;        // returned by stream_create()
	int m_samplerate;               // output sample rate
	int m_basefreq;                 // chip's base frequency
	int m_counter8[TMS3615_TONES];  // tone frequency counter for 8'
	int m_counter16[TMS3615_TONES]; // tone frequency counter for 16'
	int m_output8;                  // output signal bits for 8'
	int m_output16;                 // output signal bits for 16'
	int m_enable;                   // mask which tones to play
};

DECLARE_DEVICE_TYPE(TMS3615, tms3615_device)

#endif // MAME_SOUND_TMS3615_H