src/mixer.cpp
author rubidium
Sun, 30 Nov 2008 18:45:44 +0000
changeset 10394 a0fec997d412
parent 9643 685360d6f6a9
permissions -rw-r--r--
(svn r14645) -Fix [FS#2431]: Debian packaging rules could use a non-existing makefile target when rerunning it with dpkg-buildpackage
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1891
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 1891
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 6247
diff changeset
     3
/** @file mixer.cpp Mixing of sound samples. */
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
     4
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1498
diff changeset
     6
#include "openttd.h"
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
     7
#include "mixer.h"
9632
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
     8
#include "core/math_func.hpp"
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
     9
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    10
struct MixerChannel {
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    11
	bool active;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    12
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
    13
	/* pointer to allocated buffer memory */
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    14
	int8 *memory;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    15
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
    16
	/* current position in memory */
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    17
	uint32 pos;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    18
	uint32 frac_pos;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    19
	uint32 frac_speed;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    20
	uint32 samples_left;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    21
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
    22
	/* Mixing volume */
9632
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    23
	int volume_left;
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    24
	int volume_right;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    25
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    26
	uint flags;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    27
};
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    28
2977
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
    29
static MixerChannel _channels[8];
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
    30
static uint32 _play_rate;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    31
9632
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    32
/**
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    33
 * The theoretical maximum volume for a single sound sample. Multiple sound
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    34
 * samples should not exceed this limit as it will sound too loud. It also
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    35
 * stops overflowing when too many sounds are played at the same time, which
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    36
 * causes an even worse sound quality.
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    37
 */
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    38
static const int MAX_VOLUME = 128 * 128;
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    39
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    40
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    41
static void mix_int8_to_int16(MixerChannel *sc, int16 *buffer, uint samples)
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    42
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    43
	int8 *b;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    44
	uint32 frac_pos;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    45
	uint32 frac_speed;
9632
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    46
	int volume_left;
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    47
	int volume_right;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    48
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    49
	if (samples > sc->samples_left) samples = sc->samples_left;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    50
	sc->samples_left -= samples;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    51
	assert(samples > 0);
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    52
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    53
	b = sc->memory + sc->pos;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    54
	frac_pos = sc->frac_pos;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    55
	frac_speed = sc->frac_speed;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    56
	volume_left = sc->volume_left;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    57
	volume_right = sc->volume_right;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    58
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    59
	if (frac_speed == 0x10000) {
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
    60
		/* Special case when frac_speed is 0x10000 */
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    61
		do {
9632
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    62
			buffer[0] = Clamp(buffer[0] + (*b * volume_left  >> 8), -MAX_VOLUME, MAX_VOLUME);
9643
685360d6f6a9 (svn r13706) -Fix (r13695): Small typo.
frosch
parents: 9632
diff changeset
    63
			buffer[1] = Clamp(buffer[1] + (*b * volume_right >> 8), -MAX_VOLUME, MAX_VOLUME);
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    64
			b++;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    65
			buffer += 2;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    66
		} while (--samples > 0);
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    67
	} else {
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    68
		do {
9632
d5d9088b10d8 (svn r13695) -Fix [FS#2120]: in some cases the (sound) mixer could overflow causing artefacts in the sound.
rubidium
parents: 9390
diff changeset
    69
			buffer[0] = Clamp(buffer[0] + (*b * volume_left  >> 8), -MAX_VOLUME, MAX_VOLUME);
9643
685360d6f6a9 (svn r13706) -Fix (r13695): Small typo.
frosch
parents: 9632
diff changeset
    70
			buffer[1] = Clamp(buffer[1] + (*b * volume_right >> 8), -MAX_VOLUME, MAX_VOLUME);
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    71
			buffer += 2;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    72
			frac_pos += frac_speed;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    73
			b += frac_pos >> 16;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    74
			frac_pos &= 0xffff;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    75
		} while (--samples > 0);
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    76
	}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    77
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    78
	sc->frac_pos = frac_pos;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    79
	sc->pos = b - sc->memory;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    80
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    81
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    82
static void MxCloseChannel(MixerChannel *mc)
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    83
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    84
	if (mc->flags & MX_AUTOFREE) free(mc->memory);
1497
4fc9f620d3e0 (svn r2001) Resolve a race condition which could lead to dropped a sound and a memory leak
tron
parents: 1496
diff changeset
    85
	mc->active = false;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    86
	mc->memory = NULL;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    87
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    88
2977
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
    89
void MxMixSamples(void *buffer, uint samples)
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    90
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    91
	MixerChannel *mc;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    92
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
    93
	/* Clear the buffer */
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    94
	memset(buffer, 0, sizeof(int16) * 2 * samples);
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    95
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
    96
	/* Mix each channel */
2977
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
    97
	for (mc = _channels; mc != endof(_channels); mc++) {
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
    98
		if (mc->active) {
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
    99
			mix_int8_to_int16(mc, (int16*)buffer, samples);
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   100
			if (mc->samples_left == 0) MxCloseChannel(mc);
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   101
		}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   102
	}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   103
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   104
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6201
diff changeset
   105
MixerChannel *MxAllocateChannel()
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   106
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   107
	MixerChannel *mc;
2977
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
   108
	for (mc = _channels; mc != endof(_channels); mc++)
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   109
		if (mc->memory == NULL) {
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   110
			mc->active = false;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   111
			return mc;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   112
		}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   113
	return NULL;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   114
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   115
9390
88d36f907e96 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents: 9111
diff changeset
   116
void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, size_t size, uint rate, uint flags)
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   117
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   118
	mc->memory = mem;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   119
	mc->flags = flags;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   120
	mc->frac_pos = 0;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   121
	mc->pos = 0;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   122
2977
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
   123
	mc->frac_speed = (rate << 16) / _play_rate;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   124
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 5587
diff changeset
   125
	/* adjust the magnitude to prevent overflow */
9390
88d36f907e96 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents: 9111
diff changeset
   126
	while (size & ~0xFFFF) {
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   127
		size >>= 1;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   128
		rate = (rate >> 1) + 1;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   129
	}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   130
9390
88d36f907e96 (svn r13301) -Fix [FS#1997]: resolve more MSVC 9 x64 warnings.
rubidium
parents: 9111
diff changeset
   131
	mc->samples_left = (uint)size * _play_rate / rate;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   132
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   133
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   134
void MxSetChannelVolume(MixerChannel *mc, uint left, uint right)
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   135
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   136
	mc->volume_left = left;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   137
	mc->volume_right = right;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   138
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   139
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   140
1498
508395d0639a (svn r2002) Rename MxActivate to MxActivateChannel, which is more appropriate
tron
parents: 1497
diff changeset
   141
void MxActivateChannel(MixerChannel* mc)
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   142
{
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   143
	mc->active = true;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   144
}
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   145
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   146
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   147
bool MxInitialize(uint rate)
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   148
{
2977
97c1c76b499a (svn r3552) Remove the global variable _mixer
tron
parents: 2186
diff changeset
   149
	_play_rate = rate;
1496
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   150
	return true;
15d859a626e8 (svn r2000) Split the sound system into backend (mixer.[ch]) and frontend (sound.[ch])
tron
parents:
diff changeset
   151
}