blob: 180111760e2ddae092d1ff00a94658b8b5d10700 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "sndintrf.h"
#include "streams.h"
#include "flt_vol.h"
struct filter_volume_info
{
sound_stream * stream;
int gain;
};
static STREAM_UPDATE( filter_volume_update )
{
stream_sample_t *src = inputs[0];
stream_sample_t *dst = outputs[0];
struct filter_volume_info *info = param;
while (samples--)
*dst++ = (*src++ * info->gain) >> 8;
}
static SND_START( filter_volume )
{
struct filter_volume_info *info = device->token;
info->gain = 0x100;
info->stream = stream_create(device, 1, 1, device->machine->sample_rate, info, filter_volume_update);
return DEVICE_START_OK;
}
void flt_volume_set_volume(int num, float volume)
{
struct filter_volume_info *info = sndti_token(SOUND_FILTER_VOLUME, num);
info->gain = (int)(volume * 256);
}
/**************************************************************************
* Generic get_info
**************************************************************************/
static SND_SET_INFO( filter_volume )
{
switch (state)
{
/* no parameters to set */
}
}
SND_GET_INFO( filter_volume )
{
switch (state)
{
/* --- the following bits of info are returned as 64-bit signed integers --- */
case SNDINFO_INT_TOKEN_BYTES: info->i = sizeof(struct filter_volume_info); break;
/* --- the following bits of info are returned as pointers to data or functions --- */
case SNDINFO_PTR_SET_INFO: info->set_info = SND_SET_INFO_NAME( filter_volume ); break;
case SNDINFO_PTR_START: info->start = SND_START_NAME( filter_volume ); break;
case SNDINFO_PTR_STOP: /* Nothing */ break;
case SNDINFO_PTR_RESET: /* Nothing */ break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case SNDINFO_STR_NAME: strcpy(info->s, "Volume Filter"); break;
case SNDINFO_STR_CORE_FAMILY: strcpy(info->s, "Filters"); break;
case SNDINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break;
case SNDINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break;
case SNDINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
}
}
|