getOnsetsAndSynchronyWithFillin.m
Go to the documentation of this file.
1 %returns the segment onset times and an array of delay between each pair of
2 %corresponding onsets. Also takes two arrays containing segments where
3 
4 function [segs1,segs2, differences] = getOnsetsAndSynchronyWithFillin(csv1, csv2, fill1,fill2)
5 
6 
7 
8 %load the two audio segmentations
9 cello = csvread(csv1);
10 violin = csvread(csv2);
11 
12 
13 %use only the segmentation times
14 celloSegmentations = cello(:,1);
16 
21 
22 'length of fill1'
23 length(fill1)
24 'length of fill2'
25 length(fill2)
26 
27 
28 for i = 1:length(fill1)
29 
30  segNumber = fill1(1,i);
32 
33  segLength = celloSegmentations(segNumber+1) - celloSegmentations(segNumber);
34  segDivision = segLength * (fill1(2,i)/4);
36 
38  celloFillsi(i) = segNumber+1;
39 
40 end
41 
42 
43 for i = 1:length(fill2)
44 
45  segNumber = fill2(1,i);
46  thisSegment = violinSegmentations(segNumber)
47 
48  segLength = violinSegmentations(segNumber+1) - violinSegmentations(segNumber);
49  segDivision = segLength * (fill2(2,i)/4);
50  newSegPosition = thisSegment + segDivision;
51 
52  violinFills(i) = newSegPosition;
53  violinFillsi(i) = segNumber+1;
54 
55 end
56 
57 
60 
61 %NOW FILL IN THE DATA
62 
64 segs1(celloFillsi+(0:length(celloFillsi)-1)) = celloFills;
66 
68 segs2(violinFillsi+(0:length(violinFillsi)-1)) = violinFills;
70 
71 %average out the segmentation times
72 
73 
74 
75 segs1
76 segs2
77 
80 
81 differences = (segs1 - segs2);
82 
83 
84 
85 
86 
87 end
segs2(violinFillsi+(0:length(violinFillsi)-1))
N, 1 zeros()
end end
length of fill1 length(fill1) 'length of fill2'length(fill2) for i
Definition: hls.c:58
end celloFills violinFills NOW FILL IN THE DATA segs1
use only the segmentation times celloSegmentations
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);return NULL;}return ac;}in_planar=av_sample_fmt_is_planar(in_fmt);out_planar=av_sample_fmt_is_planar(out_fmt);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> out
#define FILL(wfunc)
for(j=16;j >0;--j)