summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/imaadpcm.h
blob: eb03fce6af2a7930877df2af403225306789c422 (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
// license:BSD-3-Clause
// copyright-holders:Andrew Gardner,Aaron Giles
/***************************************************************************

    imaadpcm.h

    IMA ADCPM emulation.

***************************************************************************/

#ifndef MAME_SOUND_IMAADPCM_H
#define MAME_SOUND_IMAADPCM_H

#pragma once


// ======================> ima_adpcm_state

// Internal ADPCM state
class ima_adpcm_state
{
public:
	ima_adpcm_state() { compute_tables(); reset(); }

	void reset();
	int16_t clock(uint8_t nibble);
	int16_t output() { return m_signal; }
	void save();
	void restore();

	int32_t   m_signal;
	int32_t   m_step;
	int32_t   m_loop_signal;
	int32_t   m_loop_step;
	bool      m_saved;

private:
	static const int8_t s_index_shift[8];
	static int s_diff_lookup[89*16];

	static void compute_tables();
	static bool s_tables_computed;
};

#endif // MAME_SOUND_IMAADPCM_H