1 /*
2  * GStreamer
3  * Copyright (C) 2008 Rov Juvano <rovjuvano@users.sourceforge.net>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef __GST_SCALETEMPO_H__
22 #define __GST_SCALETEMPO_H__
23 
24 #include <gst/gst.h>
25 #include <gst/base/gstbasetransform.h>
26 
27 G_BEGIN_DECLS
28 
29 #define GST_TYPE_SCALETEMPO            (gst_scaletempo_get_type())
30 #define GST_SCALETEMPO(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SCALETEMPO, GstScaletempo))
31 #define GST_SCALETEMPO_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  GST_TYPE_SCALETEMPO, GstScaletempoClass))
32 #define GST_IS_SCALETEMPO(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SCALETEMPO))
33 #define GST_IS_SCALETEMPO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  GST_TYPE_SCALETEMPO))
34 
35 typedef struct _GstScaletempo GstScaletempo;
36 typedef struct _GstScaletempoClass GstScaletempoClass;
37 typedef struct _GstScaletempoPrivate GstScaletempoPrivate;
38 
39 struct _GstScaletempo
40 {
41   GstBaseTransform element;
42 
43   gdouble scale;
44   gboolean reverse;
45 
46   /* parameters */
47   guint ms_stride;
48   gdouble percent_overlap;
49   guint ms_search;
50 
51   /* caps */
52   GstAudioFormat format;
53   guint samples_per_frame;      /* AKA number of channels */
54   guint bytes_per_sample;
55   guint bytes_per_frame;
56   guint sample_rate;
57 
58   /* stride */
59   gdouble frames_stride_scaled;
60   gdouble frames_stride_error;
61   guint bytes_stride;
62   gdouble bytes_stride_scaled;
63   guint bytes_queue_max;
64   guint bytes_queued;
65   guint bytes_to_slide;
66   gint8 *buf_queue;
67 
68   /* overlap */
69   guint samples_overlap;
70   guint samples_standing;
71   guint bytes_overlap;
72   guint bytes_standing;
73   gpointer buf_overlap;
74   gpointer table_blend;
75   void (*output_overlap) (GstScaletempo * scaletempo, gpointer out_buf, guint bytes_off);
76 
77   /* best overlap */
78   guint frames_search;
79   gpointer buf_pre_corr;
80   gpointer table_window;
81   guint (*best_overlap_offset) (GstScaletempo * scaletempo);
82 
83   /* gstreamer */
84   GstSegment in_segment, out_segment;
85   GstClockTime latency;
86 
87   /* threads */
88   gboolean reinit_buffers;
89 };
90 
91 struct _GstScaletempoClass
92 {
93   GstBaseTransformClass parent_class;
94 };
95 
96 GType gst_scaletempo_get_type (void);
97 
98 G_END_DECLS
99 #endif /* __GST_SCALETEMPO_H__ */
100