libvisual  0.5.0
lv_audio_c.cpp
1 #include "config.h"
2 #include "lv_audio.h"
3 #include "lv_common.h"
4 #include <cstdarg>
5 
6 VisAudio *visual_audio_new (void)
7 {
8  return new LV::Audio;
9 }
10 
11 void visual_audio_free (VisAudio *self)
12 {
13  delete self;
14 }
15 
16 void visual_audio_input (VisAudio *self,
17  VisBuffer *buffer,
18  VisAudioSampleRateType rate,
19  VisAudioSampleFormatType format,
20  VisAudioSampleChannelType channeltype)
21 {
22  visual_return_if_fail (self != nullptr);
23  visual_return_if_fail (buffer != nullptr);
24 
25  self->input (LV::BufferPtr (buffer), rate, format, channeltype);
26 }
27 
28 void visual_audio_input_channel (VisAudio *self,
29  VisBuffer *buffer,
30  VisAudioSampleRateType rate,
31  VisAudioSampleFormatType format,
32  const char *channelid)
33 {
34  visual_return_if_fail (self != nullptr);
35  visual_return_if_fail (buffer != nullptr);
36 
37  self->input (LV::BufferPtr (buffer), rate, format, channelid);
38 }
39 
40 int visual_audio_get_sample (VisAudio *self, VisBuffer *buffer, const char *channel_name)
41 {
42  visual_return_val_if_fail (self != nullptr, FALSE);
43  visual_return_val_if_fail (buffer != nullptr, FALSE);
44 
45  return self->get_sample (LV::BufferPtr (buffer), channel_name);
46 }
47 
48 void visual_audio_get_sample_mixed_simple (VisAudio *self, VisBuffer *buffer, unsigned int channels, ...)
49 {
50  visual_return_if_fail (self != nullptr);
51  visual_return_if_fail (buffer != nullptr);
52 
53  va_list args;
54 
55  va_start (args, channels);
56  self->get_sample_mixed_simple (LV::BufferPtr (buffer), channels, args);
57  va_end (args);
58 }
59 
60 void visual_audio_get_sample_mixed (VisAudio *self, VisBuffer *buffer, int divide, unsigned int channels, ...)
61 {
62  visual_return_if_fail (self != nullptr);
63  visual_return_if_fail (buffer != nullptr);
64 
65  va_list args;
66 
67  va_start (args, channels);
68  self->get_sample_mixed (LV::BufferPtr (buffer), divide, channels, args);
69  va_end (args);
70 }
71 
72 void visual_audio_get_spectrum (VisAudio *self, VisBuffer *buffer, int samplelen, const char *channel_name, int normalised)
73 {
74  visual_return_if_fail (self != nullptr);
75  visual_return_if_fail (buffer != nullptr);
76 
77  self->get_spectrum (LV::BufferPtr (buffer), samplelen, channel_name, normalised);
78 }
79 
80 void visual_audio_get_spectrum_multiplied (VisAudio *self, VisBuffer *buffer, int samplelen, const char *channel_name, int normalised, float multiplier)
81 {
82  visual_return_if_fail (self != nullptr);
83  visual_return_if_fail (buffer != nullptr);
84 
85  self->get_spectrum (LV::BufferPtr (buffer), samplelen, channel_name, normalised, multiplier);
86 }
87 
88 void visual_audio_get_spectrum_for_sample (VisBuffer *buffer, VisBuffer *sample, int normalised)
89 {
90  visual_return_if_fail (buffer != nullptr);
91  visual_return_if_fail (sample != nullptr);
92 
93  LV::Audio::get_spectrum_for_sample (LV::BufferPtr (buffer), LV::BufferPtr (sample), normalised);
94 }
95 
96 void visual_audio_get_spectrum_for_sample_multiplied (VisBuffer *buffer, VisBuffer *sample, int normalised, float multiplier)
97 {
98  visual_return_if_fail (buffer != nullptr);
99  visual_return_if_fail (sample != nullptr);
100 
101  LV::Audio::get_spectrum_for_sample (LV::BufferPtr (buffer), LV::BufferPtr (sample), normalised, multiplier);
102 }
103 
104 void visual_audio_normalise_spectrum (VisBuffer *buffer)
105 {
106  visual_return_if_fail (buffer != nullptr);
107 
108  LV::Audio::normalise_spectrum (LV::BufferPtr (buffer));
109 }