コード例 #1
0
void
printFeatures(int frame, int sr, int output,
              Plugin::FeatureSet features, ofstream *out, bool useFrames)
{
    for (unsigned int i = 0; i < features[output].size(); ++i) {

        if (useFrames) {

            int displayFrame = frame;

            if (features[output][i].hasTimestamp) {
                displayFrame = RealTime::realTime2Frame
                    (features[output][i].timestamp, sr);
            }

            (out ? *out : cout) << displayFrame;

            if (features[output][i].hasDuration) {
                displayFrame = RealTime::realTime2Frame
                    (features[output][i].duration, sr);
                (out ? *out : cout) << "," << displayFrame;
            }

            (out ? *out : cout)  << ":";

        } else {

            RealTime rt = RealTime::frame2RealTime(frame, sr);

            if (features[output][i].hasTimestamp) {
                rt = features[output][i].timestamp;
            }

            (out ? *out : cout) << rt.toString();

            if (features[output][i].hasDuration) {
                rt = features[output][i].duration;
                (out ? *out : cout) << "," << rt.toString();
            }

            (out ? *out : cout) << ":";
        }

        for (unsigned int j = 0; j < features[output][i].values.size(); ++j) {
            (out ? *out : cout) << " " << features[output][i].values[j];
        }
        (out ? *out : cout) << " " << features[output][i].label;

        (out ? *out : cout) << endl;
    }
}
コード例 #2
0
void
printFeatures(int frame, int sr,
              const Plugin::OutputDescriptor &output, int outputNo,
              const Plugin::FeatureSet &features, ofstream *out, bool useFrames)
{
    static int featureCount = -1;
    
    if (features.find(outputNo) == features.end()) return;
    
    for (size_t i = 0; i < features.at(outputNo).size(); ++i) {

        const Plugin::Feature &f = features.at(outputNo).at(i);

        bool haveRt = false;
        RealTime rt;

        if (output.sampleType == Plugin::OutputDescriptor::VariableSampleRate) {
            rt = f.timestamp;
            haveRt = true;
        } else if (output.sampleType == Plugin::OutputDescriptor::FixedSampleRate) {
            int n = featureCount + 1;
            if (f.hasTimestamp) {
                n = int(round(toSeconds(f.timestamp) * output.sampleRate));
            }
            rt = RealTime::fromSeconds(double(n) / output.sampleRate);
            haveRt = true;
            featureCount = n;
        }
        
        if (useFrames) {

            int displayFrame = frame;

            if (haveRt) {
                displayFrame = RealTime::realTime2Frame(rt, sr);
            }

            (out ? *out : cout) << displayFrame;

            if (f.hasDuration) {
                displayFrame = RealTime::realTime2Frame(f.duration, sr);
                (out ? *out : cout) << "," << displayFrame;
            }

            (out ? *out : cout)  << ":";

        } else {

            if (!haveRt) {
                rt = RealTime::frame2RealTime(frame, sr);
            }

            (out ? *out : cout) << rt.toString();

            if (f.hasDuration) {
                rt = f.duration;
                (out ? *out : cout) << "," << rt.toString();
            }

            (out ? *out : cout) << ":";
        }

        for (unsigned int j = 0; j < f.values.size(); ++j) {
            (out ? *out : cout) << " " << f.values[j];
        }
        (out ? *out : cout) << " " << f.label;

        (out ? *out : cout) << endl;
    }
}
コード例 #3
0
ファイル: RealTime.cpp プロジェクト: c4dm/jvamp
JNIEXPORT jstring JNICALL
Java_org_vamp_1plugins_RealTime_toString(JNIEnv *env, jobject obj)
{
    RealTime rt = getRealTime(env, obj);
    return env->NewStringUTF(rt.toString().c_str());
}