~ubuntu-branches/ubuntu/vivid/aeolus/vivid

« back to all changes in this revision

Viewing changes to audio.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-04-19 19:12:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100419191251-hgarjfcdfl7c0ryl
Tags: 0.8.4-3
debian/patches/01-makefile.patch: Drop -march=native flag, it isn't valid
for Debian packages as the results are unpredictable, thanks to
Bastian Blank for reporting this (Closes: #578278).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    Copyright (C) 2003-2008 Fons Adriaensen <fons@kokkinizita.net>
3
 
    
4
 
    This program is free software; you can redistribute it and/or modify
5
 
    it under the terms of the GNU General Public License as published by
6
 
    the Free Software Foundation; either version 2 of the License, or
7
 
    (at your option) any later version.
8
 
 
9
 
    This program is distributed in the hope that it will be useful,
10
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
    GNU General Public License for more details.
13
 
 
14
 
    You should have received a copy of the GNU General Public License
15
 
    along with this program; if not, write to the Free Software
16
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
 
*/
18
 
 
19
 
 
20
 
#ifndef __AUDIO_H
21
 
#define __AUDIO_H
22
 
 
23
 
 
24
 
#include <stdlib.h>
25
 
#include <clthreads.h>
26
 
#ifdef __linux__
27
 
#include <clalsadrv.h>
28
 
#endif
29
 
#include <jack/jack.h>
30
 
#include "asection.h"
31
 
#include "division.h"
32
 
#include "lfqueue.h"
33
 
#include "reverb.h"
34
 
#include "global.h"
35
 
 
36
 
 
37
 
class Audio : public A_thread
38
 
{
39
 
public:
40
 
 
41
 
    Audio (const char *jname, Lfq_u32 *qnote, Lfq_u32 *qcomm);
42
 
    virtual ~Audio (void);
43
 
#ifdef __linux__
44
 
    void  init_alsa (const char *device, int fsamp, int fsize, int nfrag);
45
 
#endif
46
 
    void  init_jack (bool bform, Lfq_u8 *qmidi);
47
 
    void  start (void);
48
 
 
49
 
    const char  *appname (void) const { return _appname; }
50
 
    uint16_t    *midimap (void) const { return (uint16_t *) _midimap; }
51
 
    int  policy (void) const { return _policy; }
52
 
    int  abspri (void) const { return _abspri; }
53
 
    int  relpri (void) const { return _relpri; }
54
 
 
55
 
private:
56
 
   
57
 
    enum { VOLUME, REVSIZE, REVTIME, STPOSIT };
58
 
 
59
 
    void init_audio (void);
60
 
#ifdef __linux__
61
 
    void close_alsa (void);
62
 
#endif
63
 
    void close_jack (void);
64
 
    virtual void thr_main (void);
65
 
    void jack_shutdown (void);
66
 
    int  jack_callback (jack_nframes_t);
67
 
    void proc_jmidi (int);
68
 
    void proc_queue (Lfq_u32 *);
69
 
    void proc_synth (int);
70
 
    void proc_keys1 (void);
71
 
    void proc_keys2 (void);
72
 
    void proc_mesg (void);
73
 
 
74
 
    void key_off (int n, int b)
75
 
    {
76
 
        _keymap [n] &= ~b;
77
 
        _keymap [n] |= 128;
78
 
    }
79
 
 
80
 
    void key_on (int n, int b)
81
 
    {
82
 
        _keymap [n] |= b | 128;
83
 
    }
84
 
 
85
 
    void cond_key_off (int m, int b)
86
 
    {
87
 
        int            i;
88
 
        unsigned char  *p;
89
 
 
90
 
        for (i = 0, p = _keymap; i < NNOTES; i++, p++)
91
 
        {
92
 
            if (*p & m)
93
 
            {
94
 
                *p &= ~b;
95
 
                *p |= 128;
96
 
            }
97
 
        }
98
 
    }
99
 
 
100
 
    void cond_key_on (int m, int b)
101
 
    {
102
 
        int            i;
103
 
        unsigned char  *p;
104
 
 
105
 
        for (i = 0, p = _keymap; i < NNOTES; i++, p++)
106
 
        {
107
 
            if (*p & m)
108
 
            {
109
 
                *p |= b | 128;
110
 
            }
111
 
        }
112
 
    }
113
 
 
114
 
    static void jack_static_shutdown (void *);
115
 
    static int  jack_static_callback (jack_nframes_t, void *);
116
 
 
117
 
    const char     *_appname;
118
 
    uint16_t        _midimap [16];
119
 
    Lfq_u32        *_qnote; 
120
 
    Lfq_u32        *_qcomm; 
121
 
    Lfq_u8         *_qmidi;
122
 
    volatile bool   _running;
123
 
#ifdef __linux__
124
 
    Alsa_driver    *_alsa_handle;
125
 
#endif
126
 
    jack_client_t  *_jack_handle;
127
 
    jack_port_t    *_jack_opport [8];
128
 
    jack_port_t    *_jack_midipt;
129
 
    int             _policy;
130
 
    int             _abspri;
131
 
    int             _relpri;
132
 
    int             _jmidi_count;
133
 
    int             _jmidi_index;
134
 
    void           *_jmidi_pdata;
135
 
    int             _hold;
136
 
    bool            _bform;
137
 
    int             _nplay;
138
 
    unsigned int    _fsamp;
139
 
    unsigned int    _fsize;
140
 
    int             _nasect;
141
 
    int             _ndivis;
142
 
    Asection       *_asectp [NASECT];
143
 
    Division       *_divisp [NDIVIS];
144
 
    Reverb          _reverb;
145
 
    float          *_outbuf [8];
146
 
    unsigned char   _keymap [NNOTES];
147
 
    Fparm           _audiopar [4];
148
 
    float           _revsize;
149
 
    float           _revtime;
150
 
 
151
 
    static const char *_ports_stereo [2];
152
 
    static const char *_ports_ambis1 [4];
153
 
};
154
 
 
155
 
 
156
 
#endif
157