Example #1
0
void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter)
{
	int height = m_back->height();
	int width = m_back->width() / 2;
	int center = m_back->width() - width;

	float const maxDB(ampToDbfs(m_fMaxPeak));
	float const minDB(ampToDbfs(m_fMinPeak));

	// We will need to divide by the span between min and max several times. It's more
	// efficient to calculate the reciprocal once and then to multiply.
	float const fullSpanReciprocal = 1 / (maxDB - minDB);


	// Draw left levels
	float const leftSpan = ampToDbfs(qMax<float>(0.0001, m_fPeakValue_L)) - minDB;
	int peak_L = height * leftSpan * fullSpanReciprocal;
	QRect drawRectL( 0, height - peak_L, width, peak_L ); // Source and target are identical
	painter.drawPixmap( drawRectL, *m_leds, drawRectL );

	float const persistentLeftPeakDBFS = ampToDbfs(qMax<float>(0.0001, m_persistentPeak_L));
	int persistentPeak_L = height * (1 - (persistentLeftPeakDBFS - minDB) * fullSpanReciprocal);
	// the LED's have a  4px padding and we don't want the peaks
	// to draw on the fader background
	if( persistentPeak_L <= 4 )
	{
		persistentPeak_L = 4;
	}
	if( persistentLeftPeakDBFS > minDB )
	{
		QColor const & peakColor = clips(m_persistentPeak_L) ? peakRed() :
			persistentLeftPeakDBFS >= -6 ? peakYellow() : peakGreen();
		painter.fillRect( QRect( 2, persistentPeak_L, 7, 1 ), peakColor );
	}


	// Draw right levels
	float const rightSpan = ampToDbfs(qMax<float>(0.0001, m_fPeakValue_R)) - minDB;
	int peak_R = height * rightSpan * fullSpanReciprocal;
	QRect const drawRectR( center, height - peak_R, width, peak_R ); // Source and target are identical
	painter.drawPixmap( drawRectR, *m_leds, drawRectR );

	float const persistentRightPeakDBFS = ampToDbfs(qMax<float>(0.0001, m_persistentPeak_R));
	int persistentPeak_R = height * (1 - (persistentRightPeakDBFS - minDB) * fullSpanReciprocal);
	// the LED's have a  4px padding and we don't want the peaks
	// to draw on the fader background
	if( persistentPeak_R <= 4 )
	{
		persistentPeak_R = 4;
	}
	if( persistentRightPeakDBFS > minDB )
	{
		QColor const & peakColor = clips(m_persistentPeak_R) ? peakRed() :
			persistentRightPeakDBFS >= -6 ? peakYellow() : peakGreen();
		painter.fillRect( QRect( 14, persistentPeak_R, 7, 1 ), peakColor );
	}
}
Example #2
0
bool cluster_aa(const QString& clips_path, const QString& detect_path, const QString& firings_out_path, const cluster_aa_opts& opts)
{
    Mda32 clips(clips_path);

    int M = clips.N1();
    int T = clips.N2();
    int L = clips.N3();

    Mda32 FF;
    {
        // do this inside a code block so memory gets released
        Mda32 clips_reshaped(M * T, L);
        int iii = 0;
        for (int ii = 0; ii < L; ii++) {
            for (int t = 0; t < T; t++) {
                for (int m = 0; m < M; m++) {
                    clips_reshaped.set(clips.value(m, t, ii), iii);
                    iii++;
                }
            }
        }

        Mda32 CC, sigma;
        pca(CC, FF, sigma, clips_reshaped, opts.num_features, false); //should we subtract the mean?
    }

    isosplit5_opts i5_opts;
    i5_opts.isocut_threshold = opts.isocut_threshold;
    i5_opts.K_init = opts.K_init;

    QVector<int> labels(L);
    isosplit5(labels.data(), opts.num_features, L, FF.dataPtr(), i5_opts);

    Mda detect(detect_path);
    int R = detect.N1();
    if (R < 3)
        R = 3;
    Mda firings(R, L);
    for (int i = 0; i < L; i++) {
        for (int r = 0; r < R; r++) {
            firings.setValue(detect.value(r, i), r, i); //important to use .value() here because otherwise it will be out of range
        }
        firings.setValue(labels[i], 2, i);
    }

    return firings.write64(firings_out_path);
}