summaryrefslogtreecommitdiffstats
path: root/kradio3/plugins/v4lradio/v4lcfg_interfaces.h
blob: 2a099e1a05e566e0347e7a165bca671a59acb379 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/***************************************************************************
                          v4lradio_interfaces.h  -  description
                             -------------------
    begin                : Sam Jun 21 2003
    copyright            : (C) 2003 by Martin Witte
    email                : witte@kawo1.rwth-aachen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KRADIO_V4LCFG_INTERFACES_H
#define KRADIO_V4LCFG_INTERFACES_H

#include "../../src/include/interfaces.h"
#include "math.h"

struct V4LCaps
{
    int     version;
    TQString description;

    bool    hasMute;

    bool    hasVolume;
    int     minVolume,  maxVolume;
    bool    hasTreble;
    int     minTreble,  maxTreble;
    bool    hasBass;
    int     minBass,    maxBass;
    bool    hasBalance;
    int     minBalance, maxBalance;

    V4LCaps();
    V4LCaps(const V4LCaps &);

    float  volumeStep()  const { return 1.0 / (float)(maxVolume  - minVolume); }
    float  trebleStep()  const { return 1.0 / (float)(maxTreble  - minTreble); }
    float  bassStep()    const { return 1.0 / (float)(maxBass    - minBass); }
    float  balanceStep() const { return 1.0 / (float)(maxBalance - minBalance); }

    void   setVolume (int min, int max) { hasVolume  = true; minVolume  = min; maxVolume  = max; }
    void   setTreble (int min, int max) { hasTreble  = true; minTreble  = min; maxTreble  = max; }
    void   setBass   (int min, int max) { hasBass    = true; minBass    = min; maxBass    = max; }
    void   setBalance(int min, int max) { hasBalance = true; minBalance = min; maxBalance = max; }

    void   unsetVolume () { hasVolume  = false; minVolume  = 0; maxVolume  = 65535; }
    void   unsetTreble () { hasTreble  = false; minTreble  = 0; maxTreble  = 65535; }
    void   unsetBass   () { hasBass    = false; minBass    = 0; maxBass    = 65535; }
    void   unsetBalance() { hasBalance = false; minBalance = 0; maxBalance = 65535; }

    int    intGetVolume (float f) const { return (int)rint(minVolume  + (maxVolume  - minVolume ) * f); }
    int    intGetTreble (float f) const { return (int)rint(minTreble  + (maxTreble  - minTreble ) * f); }
    int    intGetBass   (float f) const { return (int)rint(minBass    + (maxBass    - minBass   ) * f); }
    int    intGetBalance(float f) const { return (int)rint(minBalance + (maxBalance - minBalance) / 2.0 * (1.0 + f)); }

    float  floatGetVolume (int i) const { return (float)(i - minVolume)  * volumeStep(); }
    float  floatGetTreble (int i) const { return (float)(i - minTreble)  * trebleStep(); }
    float  floatGetBass   (int i) const { return (float)(i - minBass  )  * bassStep(); }
    float  floatGetBalance(int i) const { return (float)(i - minBalance) * balanceStep() * 2.0 - 1.0; }
};



INTERFACE(IV4LCfg, IV4LCfgClient)
{
public:
    IF_CON_DESTRUCTOR(IV4LCfg, -1)

RECEIVERS:
    IF_RECEIVER(   setRadioDevice  (const TQString &s)                            )
    IF_RECEIVER(   setPlaybackMixer(const TQString &soundStreamClientID, const TQString &ch)  )
    IF_RECEIVER(   setCaptureMixer (const TQString &soundStreamClientID, const TQString &ch)  )
    IF_RECEIVER(   setDeviceVolume(float v)                                      )
    IF_RECEIVER(   setActivePlayback(bool a)                                     )
    IF_RECEIVER(   setMuteOnPowerOff(bool m)                                     )
    IF_RECEIVER(   setVolumeZeroOnPowerOff(bool m)                               )

SENDERS:
    IF_SENDER  (   notifyRadioDeviceChanged  (const TQString &s)                   )
    IF_SENDER  (   notifyPlaybackMixerChanged(const TQString &soundStreamClientID, const TQString &Channel)      )
    IF_SENDER  (   notifyCaptureMixerChanged (const TQString &soundStreamClientID, const TQString &Channel)      )
    IF_SENDER  (   notifyDeviceVolumeChanged (float v)                           )
    IF_SENDER  (   notifyCapabilitiesChanged (const V4LCaps &)                   )
    IF_SENDER  (   notifyActivePlaybackChanged (bool a)                          )
    IF_SENDER  (   notifyMuteOnPowerOffChanged (bool a)                          )
    IF_SENDER  (   notifyVolumeZeroOnPowerOffChanged (bool a)                    )

ANSWERS:
    IF_ANSWER  (   const TQString &getRadioDevice () const                       )
    IF_ANSWER  (   const TQString &getPlaybackMixerID () const                   )
    IF_ANSWER  (   const TQString &getCaptureMixerID () const                    )
    IF_ANSWER  (   const TQString &getPlaybackMixerChannel() const               )
    IF_ANSWER  (   const TQString &getCaptureMixerChannel() const                )
    IF_ANSWER  (   float          getDeviceVolume() const                       )
    IF_ANSWER  (   V4LCaps        getCapabilities(TQString dev = TQString()) const )
    IF_ANSWER  (   bool           getActivePlayback() const                     )
    IF_ANSWER  (   bool           getMuteOnPowerOff() const                     )
    IF_ANSWER  (   bool           getVolumeZeroOnPowerOff() const               )
};



INTERFACE(IV4LCfgClient, IV4LCfg)
{
public:
    IF_CON_DESTRUCTOR(IV4LCfgClient, 1)

SENDERS:
    IF_SENDER  (   sendRadioDevice (const TQString &s)                            )
    IF_SENDER  (   sendPlaybackMixer(const TQString &soundStreamClientID, const TQString &ch) )
    IF_SENDER  (   sendCaptureMixer (const TQString &soundStreamClientID, const TQString &ch) )
    IF_SENDER  (   sendDeviceVolume(float v)                                     )
    IF_SENDER  (   sendActivePlayback(bool a)                                    )
    IF_SENDER  (   sendMuteOnPowerOff(bool a)                                    )
    IF_SENDER  (   sendVolumeZeroOnPowerOff(bool a)                              )

RECEIVERS:
    IF_RECEIVER(   noticeRadioDeviceChanged(const TQString &s)                    )
    IF_RECEIVER(   noticePlaybackMixerChanged(const TQString &soundStreamClientID, const TQString &Channel)       )
    IF_RECEIVER(   noticeCaptureMixerChanged (const TQString &soundStreamClientID, const TQString &Channel)       )
    IF_RECEIVER(   noticeDeviceVolumeChanged(float v)                            )
    IF_RECEIVER(   noticeCapabilitiesChanged(const V4LCaps &)                    )
    IF_RECEIVER(   noticeActivePlaybackChanged(bool a)                           )
    IF_RECEIVER(   noticeMuteOnPowerOffChanged(bool a)                           )
    IF_RECEIVER(   noticeVolumeZeroOnPowerOffChanged(bool a)                     )

TQUERIES:
    IF_TQUERY   (   const TQString &queryRadioDevice ()                            )
    IF_TQUERY   (   const TQString &queryPlaybackMixerID ()                        )
    IF_TQUERY   (   const TQString &queryCaptureMixerID ()                         )
    IF_TQUERY   (   const TQString &queryPlaybackMixerChannel()                    )
    IF_TQUERY   (   const TQString &queryCaptureMixerChannel()                     )
    IF_TQUERY   (   float          queryDeviceVolume()                            )
    IF_TQUERY   (   V4LCaps        queryCapabilities(TQString dev = TQString()) )
    IF_TQUERY   (   bool           queryActivePlayback()                          )
    IF_TQUERY   (   bool           queryMuteOnPowerOff()                          )
    IF_TQUERY   (   bool           queryVolumeZeroOnPowerOff()                    )

RECEIVERS:
    virtual void noticeConnectedI    (cmplInterface *, bool /*pointer_valid*/);
    virtual void noticeDisconnectedI (cmplInterface *, bool /*pointer_valid*/);
};

#endif