1 /**
2  * \file mlt_audio.h
3  * \brief Audio class
4  * \see mlt_audio_s
5  *
6  * Copyright (C) 2020 Meltytech, LLC
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 
23 #ifndef MLT_AUDIO_H
24 #define MLT_AUDIO_H
25 
26 #include "mlt_types.h"
27 
28 /** \brief Audio class
29  *
30  * Audio is the data object that represents audio for a period of time.
31  */
32 
33 struct mlt_audio_s
34 {
35 	void* data;
36 	int frequency;
37 	mlt_audio_format format;
38 	int samples;
39 	int channels;
40 	mlt_channel_layout layout;
41 	mlt_destructor release_data;
42 	mlt_destructor close;
43 };
44 
45 extern mlt_audio mlt_audio_new();
46 extern void mlt_audio_close( mlt_audio self );
47 extern void mlt_audio_set_values( mlt_audio self, void* data, int frequency, mlt_audio_format format, int samples, int channels );
48 extern void mlt_audio_get_values( mlt_audio self, void** data, int* frequency, mlt_audio_format* format, int* samples, int* channels );
49 extern void mlt_audio_alloc_data( mlt_audio self );
50 extern int mlt_audio_calculate_size( mlt_audio self );
51 extern int mlt_audio_plane_count( mlt_audio self );
52 extern int mlt_audio_plane_size( mlt_audio self );
53 extern void mlt_audio_get_planes( mlt_audio self, uint8_t** planes );
54 extern void mlt_audio_shrink( mlt_audio self , int samples );
55 extern void mlt_audio_reverse( mlt_audio self );
56 extern void mlt_audio_copy( mlt_audio dst, mlt_audio src, int samples, int src_start, int dst_start );
57 extern int mlt_audio_calculate_frame_samples( float fps, int frequency, int64_t position );
58 extern int64_t mlt_audio_calculate_samples_to_position( float fps, int frequency, int64_t position );
59 extern const char * mlt_audio_format_name( mlt_audio_format format );
60 extern int mlt_audio_format_size( mlt_audio_format format, int samples, int channels );
61 extern const char * mlt_audio_channel_layout_name( mlt_channel_layout layout );
62 extern mlt_channel_layout mlt_audio_channel_layout_id( const char * name );
63 extern int mlt_audio_channel_layout_channels( mlt_channel_layout layout );
64 extern mlt_channel_layout mlt_audio_channel_layout_default( int channels );
65 
66 // Deprecated functions
67 extern int mlt_sample_calculator( float fps, int frequency, int64_t position );
68 extern int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t position );
69 extern const char * mlt_channel_layout_name( mlt_channel_layout layout );
70 extern mlt_channel_layout mlt_channel_layout_id( const char * name );
71 extern int mlt_channel_layout_channels( mlt_channel_layout layout );
72 extern mlt_channel_layout mlt_channel_layout_default( int channels );
73 
74 #endif
75