LMMS
Loading...
Searching...
No Matches
panning.h
Go to the documentation of this file.
1/*
2 * panning.h - declaration of some types, concerning the
3 * panning of a note
4 *
5 * Copyright (c) 2004-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
6 *
7 * This file is part of LMMS - https://lmms.io
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program (see COPYING); if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA.
23 *
24 */
25
26#ifndef LMMS_PANNING_H
27#define LMMS_PANNING_H
28
29#include "LmmsTypes.h"
30#include "Midi.h"
31#include "volume.h"
32
33#include <cmath>
34
35namespace lmms
36{
37
38inline constexpr panning_t PanningRight = 100;
40inline constexpr panning_t PanningCenter = 0;
42
44 float _scale = 1.0f )
45{
46 StereoVolumeVector v = { { _scale, _scale } };
47 const float pf = _p / 100.0f;
48 v.vol[_p >= PanningCenter ? 0 : 1] *= 1.0f - std::abs(pf);
49 return v;
50}
51
52
53inline int panningToMidi( panning_t _p )
54{
55 return MidiMinPanning + (int) (
56 ( (float)( _p - PanningLeft ) ) /
57 ( (float)( PanningRight - PanningLeft ) ) *
58 ( (float)( MidiMaxPanning - MidiMinPanning ) ) );
59}
60
61
62} // namespace lmms
63
64#endif // LMMS_PANNING_H
unsigned v[N_MAX]
Definition inflate.c:1584
Definition AudioAlsa.cpp:35
constexpr panning_t DefaultPanning
Definition panning.h:41
constexpr panning_t PanningLeft
Definition panning.h:39
StereoVolumeVector panningToVolumeVector(panning_t _p, float _scale=1.0f)
Definition panning.h:43
int panningToMidi(panning_t _p)
Definition panning.h:53
constexpr panning_t PanningCenter
Definition panning.h:40
const int MidiMaxPanning
Definition Midi.h:135
const int MidiMinPanning
Definition Midi.h:136
std::int8_t panning_t
Definition LmmsTypes.h:37
constexpr panning_t PanningRight
Definition panning.h:38
Definition volume.h:40
typedef int(UZ_EXP MsgFn)()