1 /* GSequencer - Advanced GTK Sequencer
2  * Copyright (C) 2005-2020 Joël Krähemann
3  *
4  * This file is part of GSequencer.
5  *
6  * GSequencer 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  * GSequencer 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 GSequencer.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef __AGS_FX_PLAYBACK_AUDIO_PROCESSOR_H__
21 #define __AGS_FX_PLAYBACK_AUDIO_PROCESSOR_H__
22 
23 #include <glib.h>
24 #include <glib-object.h>
25 
26 #include <ags/libags.h>
27 
28 #include <ags/audio/ags_audio.h>
29 #include <ags/audio/ags_buffer.h>
30 #include <ags/audio/ags_recall_audio_run.h>
31 
32 G_BEGIN_DECLS
33 
34 #define AGS_TYPE_FX_PLAYBACK_AUDIO_PROCESSOR                (ags_fx_playback_audio_processor_get_type())
35 #define AGS_FX_PLAYBACK_AUDIO_PROCESSOR(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_FX_PLAYBACK_AUDIO_PROCESSOR, AgsFxPlaybackAudioProcessor))
36 #define AGS_FX_PLAYBACK_AUDIO_PROCESSOR_CLASS(class)        (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_FX_PLAYBACK_AUDIO_PROCESSOR, AgsFxPlaybackAudioProcessor))
37 #define AGS_IS_FX_PLAYBACK_AUDIO_PROCESSOR(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AGS_TYPE_FX_PLAYBACK_AUDIO_PROCESSOR))
38 #define AGS_IS_FX_PLAYBACK_AUDIO_PROCESSOR_CLASS(class)     (G_TYPE_CHECK_CLASS_TYPE ((class), AGS_TYPE_FX_PLAYBACK_AUDIO_PROCESSOR))
39 #define AGS_FX_PLAYBACK_AUDIO_PROCESSOR_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), AGS_TYPE_FX_PLAYBACK_AUDIO_PROCESSOR, AgsFxPlaybackAudioProcessorClass))
40 
41 typedef struct _AgsFxPlaybackAudioProcessor AgsFxPlaybackAudioProcessor;
42 typedef struct _AgsFxPlaybackAudioProcessorClass AgsFxPlaybackAudioProcessorClass;
43 
44 /**
45  * AgsFxPlaybackAudioProcessorDataMode:
46  * @AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_PLAY: data mode play sound
47  * @AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_RECORD: data mode record sound
48  * @AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_FEED: data mode feed audio signal
49  * @AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_MASTER: data mode master audio signal
50  *
51  * Enum values to enable specific data mode of #AgsFxPlaybackAudioProcessor.
52  */
53 typedef enum{
54   AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_PLAY,
55   AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_RECORD,
56   AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_FEED,
57   AGS_FX_PLAYBACK_AUDIO_PROCESSOR_DATA_MODE_MASTER,
58 }AgsFxPlaybackAudioProcessorDataMode;
59 
60 struct _AgsFxPlaybackAudioProcessor
61 {
62   AgsRecallAudioRun recall_audio_run;
63 
64   gdouble delay_completion;
65 
66   gdouble delay_counter;
67   guint64 offset_counter;
68 
69   gdouble current_delay_counter;
70   guint64 current_offset_counter;
71 
72   guint64 x_offset;
73   guint64 current_x_offset;
74 
75   AgsTimestamp *timestamp;
76 
77   GList *playing_buffer;
78   GList *playing_audio_signal;
79 
80   GList *recording_buffer;
81   GList *recording_audio_signal;
82 
83   GList *feeding_audio_signal;
84 
85   GList *mastering_audio_signal;
86 
87   GList *capture_audio_signal;
88 };
89 
90 struct _AgsFxPlaybackAudioProcessorClass
91 {
92   AgsRecallAudioRunClass recall_audio_run;
93 
94   void (*data_put)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor,
95 		   AgsBuffer *buffer,
96 		   guint data_mode);
97   void (*data_get)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor,
98 		   AgsBuffer *buffer,
99 		   guint data_mode);
100 
101   void (*play)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
102   void (*record)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
103   void (*feed)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
104   void (*master)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
105 
106   void (*counter_change)(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
107 };
108 
109 GType ags_fx_playback_audio_processor_get_type();
110 
111 void ags_fx_playback_audio_processor_data_put(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor,
112 					      AgsBuffer *buffer,
113 					      guint data_mode);
114 void ags_fx_playback_audio_processor_data_get(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor,
115 					      AgsBuffer *buffer,
116 					      guint data_mode);
117 
118 void ags_fx_playback_audio_processor_play(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
119 void ags_fx_playback_audio_processor_record(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
120 void ags_fx_playback_audio_processor_feed(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
121 void ags_fx_playback_audio_processor_master(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
122 
123 void ags_fx_playback_audio_processor_counter_change(AgsFxPlaybackAudioProcessor *fx_playback_audio_processor);
124 
125 /*  */
126 AgsFxPlaybackAudioProcessor* ags_fx_playback_audio_processor_new(AgsAudio *audio);
127 
128 G_END_DECLS
129 
130 #endif /*__AGS_FX_PLAYBACK_AUDIO_PROCESSOR_H__*/
131