File: scorealign-glue.cpp

package info (click to toggle)
audacity 2.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 44,240 kB
  • sloc: cpp: 182,841; ansic: 120,375; sh: 26,421; lisp: 7,495; makefile: 1,606; python: 240; xml: 104; perl: 31
file content (46 lines) | stat: -rw-r--r-- 1,530 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* scorealign-glue.cpp -- interface between Audacity and scorealign library
 *
 * 21-Jul-08 RBD
 */

#include <stdlib.h>
#include <string.h>
#include "allegro.h"
#include "audioreader.h"
#include "scorealign.h"
#include "scorealign-glue.h"
#include "audiomixerreader.h"


int scorealign(void *mixer, mixer_process_fn fn_ptr, int chans, double srate,
                double end_time, Alg_seq *seq, SAProgress *progress, 
                ScoreAlignParams &params)
{
    Scorealign sa;
    sa.frame_period = params.mFramePeriod;
    sa.window_size = params.mWindowSize;
    sa.silence_threshold = params.mSilenceThreshold;
    sa.force_final_alignment = (params.mForceFinalAlignment != 0.0);
    sa.ignore_silence = (params.mIgnoreSilence != 0.0);
    sa.presmooth_time = params.mPresmoothTime;
    sa.line_time = params.mLineTime;
    sa.smooth_time = params.mSmoothTime;

    Audio_mixer_reader reader(mixer, fn_ptr, chans, srate, end_time);
    reader.calculate_parameters(sa, false);
    sa.progress = progress;
    int result = sa.align_midi_to_audio(*seq, reader);

    params.mMidiStart = sa.first_x * sa.actual_frame_period_0;
    params.mMidiEnd = (sa.last_x + 1) * sa.actual_frame_period_0;
    params.mAudioStart = sa.first_y * sa.actual_frame_period_1;
    params.mAudioEnd = (sa.last_y + 1) * sa.actual_frame_period_1;

    if (result != SA_SUCCESS) {
        return result;
    }

    sa.midi_tempo_align(*seq);
    // seq has now been modified to conform to audio provided by mixer
    return SA_SUCCESS; // success
}