BEAST/BSE - Better Audio System and Sound Engine  0.8.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
bseloopfuncs.hh
Go to the documentation of this file.
00001  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
00002 #ifndef __BSE_LOOPFUNCS_H__
00003 #define __BSE_LOOPFUNCS_H__
00004 
00005 #include <bse/gsldatautils.hh>
00006 #include <bse/gslcommon.hh>
00007 
00008 G_BEGIN_DECLS
00009 
00010 
00011 typedef struct {
00012   /* block containing loop */
00013   GslLong       block_start;
00014   GslLong       block_length;
00015   /* performance/quality parameters */
00016   GslLong       analysis_points;
00017   /* assumed repetitions within block */
00018   GslLong       repetitions;
00019   GslLong       min_loop;
00020   /* resulting loop */
00021   gdouble       score;
00022   GslLong       loop_start;
00023   GslLong       loop_length;
00024   /* score details */
00025   guint         n_details;
00026   const char   *detail_names[64];
00027   double        detail_scores[64];
00028 } GslDataLoopConfig;
00029 
00030 /* mem-cached loop position and size finder. tests through all possible
00031  * loop sizes around center points determined by block/(analysis_points+1).
00032  * uses full-block comparisons (centering comparison area around the
00033  * loop) and tight neighbourhood comparisons. the full-block and
00034  * neighbourhood compraisons are normalized by the sample count to produce
00035  * a single error score. the progress counter is slightly off and will
00036  * often count to values lesser than 100%.
00037  */
00038 gboolean        gsl_data_find_loop5             (GslDataHandle          *dhandle,
00039                                                  GslDataLoopConfig      *config,
00040                                                  gpointer                pdata,
00041                                                  GslProgressFunc         pfunc);
00042 /* mem-cached loop position and size finder. tests through all possible
00043  * loop sizes around center points determined by block/(analysis_points+1).
00044  * uses full-block comparisons (centering comparison area around the
00045  * loop) and can produce non-acceptable results. looping 6 seconds in
00046  * 61 samples runs roughly 6 hours on 2500MHz.
00047  */
00048 gboolean        gsl_data_find_loop4             (GslDataHandle          *dhandle,
00049                                                  GslDataLoopConfig      *config,
00050                                                  gpointer                pdata,
00051                                                  GslProgressFunc         pfunc);
00052 /* fully mem-cached loop position/size finder.
00053  * attempts to determine optimum loop position and size by trying all
00054  * possible combinations (n^2) and doing a full block comparison on
00055  * each (*n). performance is n^3 and not suitable for practical
00056  * application. (and even then, full block comparisons are not a good
00057  * enough criterion to always reveal acceptable loop transitions).
00058  * 44100*3=132300, 132300*132300=17503290000
00059  */
00060 gboolean        gsl_data_find_loop3             (GslDataHandle     *dhandle,
00061                                                  GslDataLoopConfig *config,
00062                                                  gpointer           pdata,
00063                                                  GslProgressFunc    pfunc);
00064 /* quick hack to dump gnuplot file with diffenrent loop
00065  * positions or loop sizes
00066  */
00067 gboolean        gsl_data_find_loop2             (GslDataHandle     *dhandle,
00068                                                  GslDataLoopConfig *config,
00069                                                  gpointer           pdata,
00070                                                  GslProgressFunc    pfunc);
00071 /* dcache based head-compare loop finder,
00072  * 1) finds optimum loop length
00073  * 2) find optimum loop position
00074  * 3) reruns loop length finder around positions
00075  *    with shrinking neighbourhood comparisons
00076  */
00077 gboolean        gsl_data_find_loop1              (GslDataHandle     *dhandle,
00078                                                   GslDataLoopConfig *config,
00079                                                   gpointer           pdata,
00080                                                   GslProgressFunc    pfunc);
00081 
00082 
00083 typedef enum
00084 {
00085   GSL_DATA_TAIL_LOOP_CMP_LEAST_SQUARE,
00086   GSL_DATA_TAIL_LOOP_CMP_CORRELATION,
00087 } GslDataTailLoopCmpType;
00088 typedef struct {
00089   GslLong                min_loop;              /* minimum size */
00090   GslLong                max_loop;              /* maximum size (-1 for n_values) */
00091   GslLong                pre_loop_compare;      /* area size */
00092   GslDataTailLoopCmpType cmp_strategy;
00093   /* |-----|----------------|-------------------------------|
00094    *        pre_loop_compare loop area (min_loop..max_loop)
00095    *                        ^                               ^
00096    *                     loop_start                      loop_end
00097    */
00098 } GslDataTailLoop;
00099 /* dcache based tail loop finder derived from code from stefan */
00100 gdouble         gsl_data_find_loop0             (GslDataHandle          *dhandle,
00101                                                  const GslDataTailLoop  *cfg,
00102                                                  GslLong                *loop_start_p,
00103                                                  GslLong                *loop_end_p);
00104 /* gsl_data_find_loop0(): good loops, bad size:
00105  * # Tail Loop Finding
00106  * #  --loop <cfg>  loop finder configuration, consisting of ':'-seperated values:
00107  * #                n_samples indicating minimum loop size [4410]
00108  * #                n_samples indicating maximum loop size [-1]
00109  * #                n_samples compare area size (ahead of loop start) [8820]
00110  * TL_CFG="--loop=5000:-1:5000"
00111  */
00112 
00113 G_END_DECLS
00114 
00115 #endif  /* __BSE_LOOPFUNCS_H__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines