Olive
audio.h
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef AUDIO_H
22 #define AUDIO_H
23 
24 #include <QVector>
25 #include <QThread>
26 #include <QWaitCondition>
27 #include <QMutex>
28 
29 //#define INT16_MAX 0x7fff
30 //#define INT16_MIN (-INT16_MAX-1)
31 
32 class QIODevice;
33 class QAudioOutput;
34 class QComboBox;
35 
36 struct Sequence;
37 
38 class AudioSenderThread : public QThread {
39  Q_OBJECT
40 public:
42  void run();
43  void stop();
44  QWaitCondition cond;
45  bool close;
46  QMutex lock;
47 public slots:
48  void notifyReceiver();
49 private:
50  QVector<qint16> samples;
51  int send_audio_to_output(qint64 offset, int max);
52 };
53 
54 double log_volume(double linear);
55 
56 extern QAudioOutput* audio_output;
57 extern QIODevice* audio_io_device;
58 extern AudioSenderThread* audio_thread;
59 extern QMutex audio_write_lock;
60 
61 #define audio_ibuffer_size 192000
62 extern qint8 audio_ibuffer[audio_ibuffer_size];
63 extern qint64 audio_ibuffer_read;
64 extern long audio_ibuffer_frame;
65 extern double audio_ibuffer_timecode;
66 extern bool audio_scrub;
67 extern bool recording;
68 extern bool audio_rendering;
69 void clear_audio_ibuffer();
70 
71 int current_audio_freq();
72 
73 bool is_audio_device_set();
74 
75 void init_audio();
76 void stop_audio();
77 qint64 get_buffer_offset_from_frame(double framerate, long frame);
78 
79 bool start_recording();
80 void stop_recording();
81 QString get_recorded_audio_filename();
82 
83 void combobox_audio_sample_rates(QComboBox* combobox);
84 
85 #endif // AUDIO_H
Definition: sequence.h:33
Definition: audio.h:38