• Home
  • Raw
  • Download

Lines Matching refs:tonal

215 void tonality_analysis_init(TonalityAnalysisState *tonal, opus_int32 Fs)  in tonality_analysis_init()  argument
218 tonal->arch = opus_select_arch(); in tonality_analysis_init()
219 tonal->Fs = Fs; in tonality_analysis_init()
221 tonality_analysis_reset(tonal); in tonality_analysis_init()
224 void tonality_analysis_reset(TonalityAnalysisState *tonal) in tonality_analysis_reset() argument
227 char *start = (char*)&tonal->TONALITY_ANALYSIS_RESET_START; in tonality_analysis_reset()
228 OPUS_CLEAR(start, sizeof(TonalityAnalysisState) - (start - (char*)tonal)); in tonality_analysis_reset()
231 void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len) in tonality_get_info() argument
247 pos = tonal->read_pos; in tonality_get_info()
248 curr_lookahead = tonal->write_pos-tonal->read_pos; in tonality_get_info()
253 if (len > tonal->Fs/50 && pos != tonal->write_pos) in tonality_get_info()
259 if (pos == tonal->write_pos) in tonality_get_info()
264 OPUS_COPY(info_out, &tonal->info[pos], 1); in tonality_get_info()
275 if (pos == tonal->write_pos) in tonality_get_info()
277 tonality_max = MAX32(tonality_max, tonal->info[pos].tonality); in tonality_get_info()
278 tonality_avg += tonal->info[pos].tonality; in tonality_get_info()
280 info_out->bandwidth = IMAX(info_out->bandwidth, tonal->info[pos].bandwidth); in tonality_get_info()
290 if (pos == tonal->write_pos) in tonality_get_info()
292 info_out->bandwidth = IMAX(info_out->bandwidth, tonal->info[pos].bandwidth); in tonality_get_info()
342 vad_prob = tonal->info[vpos].activity_probability; in tonality_get_info()
344 prob_avg = MAX16(.1f, vad_prob)*tonal->info[mpos].music_prob; in tonality_get_info()
351 if (mpos == tonal->write_pos) in tonality_get_info()
356 if (vpos == tonal->write_pos) in tonality_get_info()
358 pos_vad = tonal->info[vpos].activity_probability; in tonality_get_info()
362 prob_avg += MAX16(.1f, pos_vad)*tonal->info[mpos].music_prob; in tonality_get_info()
378 for (i=0;i<IMIN(tonal->count-1, 15);i++) in tonality_get_info()
383 pmin = MIN16(pmin, tonal->info[pos].music_prob); in tonality_get_info()
384 pmax = MAX16(pmax, tonal->info[pos].music_prob); in tonality_get_info()
396 tonal->read_subframe += len/(tonal->Fs/400); in tonality_get_info()
397 while (tonal->read_subframe>=8) in tonality_get_info()
399 tonal->read_subframe -= 8; in tonality_get_info()
400 tonal->read_pos++; in tonality_get_info()
402 if (tonal->read_pos>=DETECT_SIZE) in tonality_get_info()
403 tonal->read_pos-=DETECT_SIZE; in tonality_get_info()
423 static void tonality_analysis(TonalityAnalysisState *tonal, const CELTMode *celt_mode, const void *… in tonality_analysis() argument
430 float * OPUS_RESTRICT A = tonal->angle; in tonality_analysis()
431 float * OPUS_RESTRICT dA = tonal->d_angle; in tonality_analysis()
432 float * OPUS_RESTRICT d2A = tonal->d2_angle; in tonality_analysis()
469 alpha = 1.f/IMIN(10, 1+tonal->count); in tonality_analysis()
470 alphaE = 1.f/IMIN(25, 1+tonal->count); in tonality_analysis()
472 alphaE2 = 1.f/IMIN(100, 1+tonal->count); in tonality_analysis()
473 if (tonal->count <= 1) alphaE2 = 1; in tonality_analysis()
475 if (tonal->Fs == 48000) in tonality_analysis()
480 } else if (tonal->Fs == 16000) { in tonality_analysis()
486 if (tonal->count==0) in tonality_analysis()
487 tonal->mem_fill = 240; in tonality_analysis()
488 tonal->hp_ener_accum += (float)downmix_and_resample(downmix, x, in tonality_analysis()
489 &tonal->inmem[tonal->mem_fill], tonal->downmix_state, in tonality_analysis()
490 IMIN(len, ANALYSIS_BUF_SIZE-tonal->mem_fill), offset, c1, c2, C, tonal->Fs); in tonality_analysis()
491 if (tonal->mem_fill+len < ANALYSIS_BUF_SIZE) in tonality_analysis()
493 tonal->mem_fill += len; in tonality_analysis()
498 hp_ener = tonal->hp_ener_accum; in tonality_analysis()
499 info = &tonal->info[tonal->write_pos++]; in tonality_analysis()
500 if (tonal->write_pos>=DETECT_SIZE) in tonality_analysis()
501 tonal->write_pos-=DETECT_SIZE; in tonality_analysis()
510 in[i].r = (kiss_fft_scalar)(w*tonal->inmem[i]); in tonality_analysis()
511 in[i].i = (kiss_fft_scalar)(w*tonal->inmem[N2+i]); in tonality_analysis()
512 in[N-i-1].r = (kiss_fft_scalar)(w*tonal->inmem[N-i-1]); in tonality_analysis()
513 in[N-i-1].i = (kiss_fft_scalar)(w*tonal->inmem[N+N2-i-1]); in tonality_analysis()
515 OPUS_MOVE(tonal->inmem, tonal->inmem+ANALYSIS_BUF_SIZE-240, 240); in tonality_analysis()
516 remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill); in tonality_analysis()
517 tonal->hp_ener_accum = (float)downmix_and_resample(downmix, x, in tonality_analysis()
518 &tonal->inmem[240], tonal->downmix_state, remaining, in tonality_analysis()
519 offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C, tonal->Fs); in tonality_analysis()
520 tonal->mem_fill = 240 + remaining; in tonality_analysis()
521 opus_fft(kfft, in, out, tonal->arch); in tonality_analysis()
582 if (!tonal->count) in tonality_analysis()
586 tonal->lowE[b] = 1e10; in tonality_analysis()
587 tonal->highE[b] = -1e10; in tonality_analysis()
632 tonal->E[tonal->E_count][b] = E; in tonality_analysis()
638 tonal->logE[tonal->E_count][b] = logE[b]; in tonality_analysis()
639 if (tonal->count==0) in tonality_analysis()
640 tonal->highE[b] = tonal->lowE[b] = logE[b]; in tonality_analysis()
641 if (tonal->highE[b] > tonal->lowE[b] + 7.5) in tonality_analysis()
643 if (tonal->highE[b] - logE[b] > logE[b] - tonal->lowE[b]) in tonality_analysis()
644 tonal->highE[b] -= .01f; in tonality_analysis()
646 tonal->lowE[b] += .01f; in tonality_analysis()
648 if (logE[b] > tonal->highE[b]) in tonality_analysis()
650 tonal->highE[b] = logE[b]; in tonality_analysis()
651 tonal->lowE[b] = MAX32(tonal->highE[b]-15, tonal->lowE[b]); in tonality_analysis()
652 } else if (logE[b] < tonal->lowE[b]) in tonality_analysis()
654 tonal->lowE[b] = logE[b]; in tonality_analysis()
655 tonal->highE[b] = MIN32(tonal->lowE[b]+15, tonal->highE[b]); in tonality_analysis()
657 relativeE += (logE[b]-tonal->lowE[b])/(1e-15f + (tonal->highE[b]-tonal->lowE[b])); in tonality_analysis()
662 L1 += (float)sqrt(tonal->E[i][b]); in tonality_analysis()
663 L2 += tonal->E[i][b]; in tonality_analysis()
671 band_tonality[b] = MAX16(tE/(1e-15f+E), stationarity*tonal->prev_band_tonality[b]); in tonality_analysis()
686 tonal->prev_band_tonality[b] = band_tonality[b]; in tonality_analysis()
729 tmp = tonal->logE[i][k] - tonal->logE[j][k]; in tonality_analysis()
767 tonal->meanE[b] = MAX32((1-alphaE2)*tonal->meanE[b], E); in tonality_analysis()
768 Em = MAX32(E, tonal->meanE[b]); in tonality_analysis()
778 is_masked[b] = E < (tonal->prev_bandwidth >= b+1 ? .01f : .05f)*bandwidth_mask; in tonality_analysis()
786 if (tonal->Fs == 48000) { in tonality_analysis()
790 noise_ratio = tonal->prev_bandwidth==20 ? 10.f : 30.f; in tonality_analysis()
797 tonal->meanE[b] = MAX32((1-alphaE2)*tonal->meanE[b], E); in tonality_analysis()
798 Em = MAX32(E, tonal->meanE[b]); in tonality_analysis()
802 is_masked[b] = E < (tonal->prev_bandwidth == 20 ? .01f : .05f)*bandwidth_mask; in tonality_analysis()
814 if (tonal->count<=2) in tonality_analysis()
817 tonal->Etracker = MAX32(tonal->Etracker-.003f, frame_loudness); in tonality_analysis()
818 tonal->lowECount *= (1-alphaE); in tonality_analysis()
819 if (frame_loudness < tonal->Etracker-30) in tonality_analysis()
820 tonal->lowECount += alphaE; in tonality_analysis()
833 sum += dct_table[i*16+b]*.5f*(tonal->highE[b]+tonal->lowE[b]); in tonality_analysis()
839 if (tonal->count<10) in tonality_analysis()
848 frame_tonality = MAX16(frame_tonality, tonal->prev_tonality*.8f); in tonality_analysis()
849 tonal->prev_tonality = frame_tonality; in tonality_analysis()
854 tonal->E_count = (tonal->E_count+1)%NB_FRAMES; in tonality_analysis()
855 tonal->count = IMIN(tonal->count+1, ANALYSIS_COUNT_MAX); in tonality_analysis()
859 …i] = -0.12299f*(BFCC[i]+tonal->mem[i+24]) + 0.49195f*(tonal->mem[i]+tonal->mem[i+16]) + 0.69693f*t… in tonality_analysis()
862 tonal->cmean[i] = (1-alpha)*tonal->cmean[i] + alpha*BFCC[i]; in tonality_analysis()
865 … features[4+i] = 0.63246f*(BFCC[i]-tonal->mem[i+24]) + 0.31623f*(tonal->mem[i]-tonal->mem[i+16]); in tonality_analysis()
867 …features[8+i] = 0.53452f*(BFCC[i]+tonal->mem[i+24]) - 0.26726f*(tonal->mem[i]+tonal->mem[i+16]) -0… in tonality_analysis()
869 if (tonal->count > 5) in tonality_analysis()
872 tonal->std[i] = (1-alpha)*tonal->std[i] + alpha*features[i]*features[i]; in tonality_analysis()
879 tonal->mem[i+24] = tonal->mem[i+16]; in tonality_analysis()
880 tonal->mem[i+16] = tonal->mem[i+8]; in tonality_analysis()
881 tonal->mem[i+8] = tonal->mem[i]; in tonality_analysis()
882 tonal->mem[i] = BFCC[i]; in tonality_analysis()
885 features[11+i] = (float)sqrt(tonal->std[i]) - std_feature_bias[i]; in tonality_analysis()
891 features[24] = tonal->lowECount - 0.067930f; in tonality_analysis()
894 compute_gru(&layer1, tonal->rnn_state, layer_out); in tonality_analysis()
895 compute_dense(&layer2, frame_probs, tonal->rnn_state); in tonality_analysis()
909 tonal->prev_bandwidth = bandwidth; in tonality_analysis()