Lines Matching refs:tonal
143 void tonality_get_info(TonalityAnalysisState *tonal, AnalysisInfo *info_out, int len) in tonality_get_info() argument
150 pos = tonal->read_pos; in tonality_get_info()
151 curr_lookahead = tonal->write_pos-tonal->read_pos; in tonality_get_info()
155 if (len > 480 && pos != tonal->write_pos) in tonality_get_info()
161 if (pos == tonal->write_pos) in tonality_get_info()
165 OPUS_COPY(info_out, &tonal->info[pos], 1); in tonality_get_info()
166 tonal->read_subframe += len/120; in tonality_get_info()
167 while (tonal->read_subframe>=4) in tonality_get_info()
169 tonal->read_subframe -= 4; in tonality_get_info()
170 tonal->read_pos++; in tonality_get_info()
172 if (tonal->read_pos>=DETECT_SIZE) in tonality_get_info()
173 tonal->read_pos-=DETECT_SIZE; in tonality_get_info()
183 psum += tonal->pmusic[i]; in tonality_get_info()
185 psum += tonal->pspeech[i]; in tonality_get_info()
186 psum = psum*tonal->music_confidence + (1-psum)*tonal->speech_confidence; in tonality_get_info()
192 void tonality_analysis(TonalityAnalysisState *tonal, AnalysisInfo *info_out, const CELTMode *celt_m… in tonality_analysis() argument
199 float * OPUS_RESTRICT A = tonal->angle; in tonality_analysis()
200 float * OPUS_RESTRICT dA = tonal->d_angle; in tonality_analysis()
201 float * OPUS_RESTRICT d2A = tonal->d2_angle; in tonality_analysis()
227 tonal->last_transition++; in tonality_analysis()
228 alpha = 1.f/IMIN(20, 1+tonal->count); in tonality_analysis()
229 alphaE = 1.f/IMIN(50, 1+tonal->count); in tonality_analysis()
230 alphaE2 = 1.f/IMIN(1000, 1+tonal->count); in tonality_analysis()
232 if (tonal->count<4) in tonality_analysis()
233 tonal->music_prob = .5; in tonality_analysis()
235 if (tonal->count==0) in tonality_analysis()
236 tonal->mem_fill = 240; in tonality_analysis()
237 …downmix(x, &tonal->inmem[tonal->mem_fill], IMIN(len, ANALYSIS_BUF_SIZE-tonal->mem_fill), offset, c… in tonality_analysis()
238 if (tonal->mem_fill+len < ANALYSIS_BUF_SIZE) in tonality_analysis()
240 tonal->mem_fill += len; in tonality_analysis()
245 info = &tonal->info[tonal->write_pos++]; in tonality_analysis()
246 if (tonal->write_pos>=DETECT_SIZE) in tonality_analysis()
247 tonal->write_pos-=DETECT_SIZE; in tonality_analysis()
256 in[i].r = (kiss_fft_scalar)(w*tonal->inmem[i]); in tonality_analysis()
257 in[i].i = (kiss_fft_scalar)(w*tonal->inmem[N2+i]); in tonality_analysis()
258 in[N-i-1].r = (kiss_fft_scalar)(w*tonal->inmem[N-i-1]); in tonality_analysis()
259 in[N-i-1].i = (kiss_fft_scalar)(w*tonal->inmem[N+N2-i-1]); in tonality_analysis()
261 OPUS_MOVE(tonal->inmem, tonal->inmem+ANALYSIS_BUF_SIZE-240, 240); in tonality_analysis()
262 remaining = len - (ANALYSIS_BUF_SIZE-tonal->mem_fill); in tonality_analysis()
263 downmix(x, &tonal->inmem[240], remaining, offset+ANALYSIS_BUF_SIZE-tonal->mem_fill, c1, c2, C); in tonality_analysis()
264 tonal->mem_fill = 240 + remaining; in tonality_analysis()
310 if (!tonal->count) in tonality_analysis()
314 tonal->lowE[b] = 1e10; in tonality_analysis()
315 tonal->highE[b] = -1e10; in tonality_analysis()
337 tonal->E[tonal->E_count][b] = E; in tonality_analysis()
342 tonal->lowE[b] = MIN32(logE[b], tonal->lowE[b]+.01f); in tonality_analysis()
343 tonal->highE[b] = MAX32(logE[b], tonal->highE[b]-.1f); in tonality_analysis()
344 if (tonal->highE[b] < tonal->lowE[b]+1.f) in tonality_analysis()
346 tonal->highE[b]+=.5f; in tonality_analysis()
347 tonal->lowE[b]-=.5f; in tonality_analysis()
349 relativeE += (logE[b]-tonal->lowE[b])/(1e-15f+tonal->highE[b]-tonal->lowE[b]); in tonality_analysis()
354 L1 += (float)sqrt(tonal->E[i][b]); in tonality_analysis()
355 L2 += tonal->E[i][b]; in tonality_analysis()
363 band_tonality[b] = MAX16(tE/(1e-15f+E), stationarity*tonal->prev_band_tonality[b]); in tonality_analysis()
378 tonal->prev_band_tonality[b] = band_tonality[b]; in tonality_analysis()
403 tonal->meanE[b] = MAX32((1-alphaE2)*tonal->meanE[b], E); in tonality_analysis()
404 E = MAX32(E, tonal->meanE[b]); in tonality_analysis()
416 if (tonal->count<=2) in tonality_analysis()
419 tonal->Etracker = MAX32(tonal->Etracker-.03f, frame_loudness); in tonality_analysis()
420 tonal->lowECount *= (1-alphaE); in tonality_analysis()
421 if (frame_loudness < tonal->Etracker-30) in tonality_analysis()
422 tonal->lowECount += alphaE; in tonality_analysis()
434 if (tonal->count<10) in tonality_analysis()
443 frame_tonality = MAX16(frame_tonality, tonal->prev_tonality*.8f); in tonality_analysis()
444 tonal->prev_tonality = frame_tonality; in tonality_analysis()
449 tonal->E_count = (tonal->E_count+1)%NB_FRAMES; in tonality_analysis()
450 tonal->count++; in tonality_analysis()
454 …i] = -0.12299f*(BFCC[i]+tonal->mem[i+24]) + 0.49195f*(tonal->mem[i]+tonal->mem[i+16]) + 0.69693f*t… in tonality_analysis()
457 tonal->cmean[i] = (1-alpha)*tonal->cmean[i] + alpha*BFCC[i]; in tonality_analysis()
460 … features[4+i] = 0.63246f*(BFCC[i]-tonal->mem[i+24]) + 0.31623f*(tonal->mem[i]-tonal->mem[i+16]); in tonality_analysis()
462 …features[8+i] = 0.53452f*(BFCC[i]+tonal->mem[i+24]) - 0.26726f*(tonal->mem[i]+tonal->mem[i+16]) -0… in tonality_analysis()
464 if (tonal->count > 5) in tonality_analysis()
467 tonal->std[i] = (1-alpha)*tonal->std[i] + alpha*features[i]*features[i]; in tonality_analysis()
472 tonal->mem[i+24] = tonal->mem[i+16]; in tonality_analysis()
473 tonal->mem[i+16] = tonal->mem[i+8]; in tonality_analysis()
474 tonal->mem[i+8] = tonal->mem[i]; in tonality_analysis()
475 tonal->mem[i] = BFCC[i]; in tonality_analysis()
478 features[11+i] = (float)sqrt(tonal->std[i]); in tonality_analysis()
483 features[24] = tonal->lowECount; in tonality_analysis()
519 q = MAX16(.05f,MIN16(.95f,tonal->music_prob)); in tonality_analysis()
525 p0 = (1-tonal->music_prob)*(1-tau) + tonal->music_prob *tau; in tonality_analysis()
526 p1 = tonal->music_prob *(1-tau) + (1-tonal->music_prob)*tau; in tonality_analysis()
532 tonal->music_prob = p1/(p0+p1); in tonality_analysis()
533 info->music_prob = tonal->music_prob; in tonality_analysis()
540 if (tonal->count==1) in tonality_analysis()
542 tonal->pspeech[0]=.5; in tonality_analysis()
543 tonal->pmusic [0]=.5; in tonality_analysis()
547 s0 = tonal->pspeech[0] + tonal->pspeech[1]; in tonality_analysis()
548 m0 = tonal->pmusic [0] + tonal->pmusic [1]; in tonality_analysis()
550 tonal->pspeech[0] = s0*(1-tau)*speech0; in tonality_analysis()
551 tonal->pmusic [0] = m0*(1-tau)*music0; in tonality_analysis()
555 tonal->pspeech[i] = tonal->pspeech[i+1]*speech0; in tonality_analysis()
556 tonal->pmusic [i] = tonal->pmusic [i+1]*music0; in tonality_analysis()
559 tonal->pspeech[DETECT_SIZE-1] = m0*tau*speech0; in tonality_analysis()
561 tonal->pmusic [DETECT_SIZE-1] = s0*tau*music0; in tonality_analysis()
565 psum += tonal->pspeech[i] + tonal->pmusic[i]; in tonality_analysis()
569 tonal->pspeech[i] *= psum; in tonality_analysis()
570 tonal->pmusic [i] *= psum; in tonality_analysis()
572 psum = tonal->pmusic[0]; in tonality_analysis()
574 psum += tonal->pspeech[i]; in tonality_analysis()
579 if (tonal->music_prob>.9) in tonality_analysis()
582 adapt = 1.f/(++tonal->music_confidence_count); in tonality_analysis()
583 tonal->music_confidence_count = IMIN(tonal->music_confidence_count, 500); in tonality_analysis()
584 tonal->music_confidence += adapt*MAX16(-.2f,frame_probs[0]-tonal->music_confidence); in tonality_analysis()
586 if (tonal->music_prob<.1) in tonality_analysis()
589 adapt = 1.f/(++tonal->speech_confidence_count); in tonality_analysis()
590 tonal->speech_confidence_count = IMIN(tonal->speech_confidence_count, 500); in tonality_analysis()
591 tonal->speech_confidence += adapt*MIN16(.2f,frame_probs[0]-tonal->speech_confidence); in tonality_analysis()
594 if (tonal->music_confidence_count==0) in tonality_analysis()
595 tonal->music_confidence = .9f; in tonality_analysis()
596 if (tonal->speech_confidence_count==0) in tonality_analysis()
597 tonal->speech_confidence = .1f; in tonality_analysis()
600 if (tonal->last_music != (tonal->music_prob>.5f)) in tonality_analysis()
601 tonal->last_transition=0; in tonality_analysis()
602 tonal->last_music = tonal->music_prob>.5f; in tonality_analysis()