summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/streams.h
blob: 8f72bddd886733d97d4e2631110481b272eb4aab (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/***************************************************************************

    streams.h

    Handle general purpose audio streams

    Copyright Nicola Salmoria and the MAME Team.
    Visit http://mamedev.org for licensing and usage restrictions.

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

#ifndef STREAMS_H
#define STREAMS_H

#include "mamecore.h"


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

typedef struct _sound_stream sound_stream;

typedef void (*stream_update_func)(void *param, stream_sample_t **inputs, stream_sample_t **outputs, int samples);



/***************************************************************************
    FUNCTION PROTOTYPES
***************************************************************************/


/* ----- system-level management ----- */

/* initialize the streams engine */
void streams_init(running_machine *machine, attoseconds_t update_subseconds);

/* set the tag to be associated with all streams allocated from now on */
void streams_set_tag(running_machine *machine, void *streamtag);

/* update all the streams periodically */
void streams_update(running_machine *machine);



/* ----- stream configuration and setup ----- */

/* create a new stream */
sound_stream *stream_create(int inputs, int outputs, int sample_rate, void *param, stream_update_func callback);

/* configure a stream's input */
void stream_set_input(sound_stream *stream, int index, sound_stream *input_stream, int output_index, float gain);

/* force a stream to update to the current emulated time */
void stream_update(sound_stream *stream);

/* return a pointer to the output buffer and the number of samples since the last global update */
const stream_sample_t *stream_get_output_since_last_update(sound_stream *stream, int outputnum, int *numsamples);



/* ----- stream timing ----- */

/* return the currently set sample rate on a given stream */
int stream_get_sample_rate(sound_stream *stream);

/* set the sample rate on a given stream */
void stream_set_sample_rate(sound_stream *stream, int sample_rate);

/* return the emulation time of the next sample to be generated on the stream */
attotime stream_get_time(sound_stream *stream);

/* return the duration of a single sample for a stream */
attotime stream_get_sample_period(sound_stream *stream);



/* ----- stream information and control ----- */

/* find a stream using a tag and index */
sound_stream *stream_find_by_tag(void *streamtag, int streamindex);

/* return the number of inputs for a given stream */
int stream_get_inputs(sound_stream *stream);

/* return the number of outputs for a given stream */
int stream_get_outputs(sound_stream *stream);

/* set the input gain on a given stream */
void stream_set_input_gain(sound_stream *stream, int input, float gain);

/* set the output gain on a given stream */
void stream_set_output_gain(sound_stream *stream, int output, float gain);


#endif