Example #1
0
        D = OMPursuit.OMPursuitDictionary(path, dsfactor)

        print("Total time is %0.1f"%(time.clock()-p))

        Ac = OMPursuit.OMPAnalysisConstraintSet(mpconstrPath)

        C = OMPursuit.OMPursuitCompoundConstraint(constraint_path + '/' + constraint)

        markers = OMPursuit.OMPursuitMarkers(markerPath)
        target = OMPursuit.OMPursuitTarget(targetPath, dsfactor)
        target.zeropadSignal(D, markers)

        #omdictionary, omcompoundconstraint, omtarget, ommarkers, maxtotal, mindistance, maxsimultaneous)
        #A = OMPursuit.OMPursuitAnalysis(D, target, markers, maxit, constraint=C, mpconstraint=Ac)
        A = OMPursuit.OMPursuitAnalysis(D, target, markers, maxit, constraint=None, mpconstraint=None)
        A.constrainedMP()

        audiolab.aiffwrite(A.ompModel.signal, os.path.expanduser('~/Research/OM-Pursuit/output/cry%d.aif'%ci), A.ompModel.samplerate)
 
        f = open(os.path.expanduser('~/Research/OM-Pursuit/output/cry%d.txt'%ci), 'w')
        f.write('Dictionary : %s\n'%path)
        f.write('Constraint : %s\n'%constraint)
        f.write('Markers : %s\n'%markerPath)
        f.write('Max. iterations : %d\n'%maxit)
        f.write('Total soundgrains in model : %d'%len(A.ompModel.parameterArray))
        f.close()

        A.writeModelSdif('~/Research/OM-Pursuit/output/cry%d.sdif'%ci)
        #print(A.ompModel.parameterArray
        break
    #for ci, constraint in enumerate(os.listdir(os.path.expanduser(constraintPaths[i]))):
    for ci, constraint in enumerate(constraintPaths):
        if os.path.splitext(constraint)[1].lower() == '.sdif':

            print(constraint)

            D = OMPursuit.OMPursuitDictionary(path, dsfactor)
            markers = OMPursuit.OMPursuitMarkers(markerPaths[i])
            Ac = OMPursuit.OMPAnalysisConstraintSet(mpconstrPath)

            C = OMPursuit.OMPursuitCompoundConstraint(constraint)
            target = OMPursuit.OMPursuitTarget(targetPaths[i], dsfactor)
            target.zeropadSignal(D, markers)

            A = OMPursuit.OMPursuitAnalysis(D, target, markers, maxit, constraint=C, mpconstraint=Ac)
            A.constrainedMP()
            audiolab.aiffwrite(A.ompModel.signal, os.path.expanduser(outpath + '-%d.aif'%ci), A.ompModel.samplerate)

            #log the analysis data
            f = open(os.path.expanduser(outpath + '-%d.txt'%ci), 'w')
            f.write('Dictionary : %s\n'%path)
            f.write('Constraint : %s\n'%constraint)
            f.write('MPConstraint : %s\n'%mpconstrPath)
            f.write('Markers : %s\n'%markerPaths[i])
            f.write('Max. iterations : %d\n'%maxit)
            f.write('Total soundgrains in model : %d'%len(A.ompModel.parameterArray))
            f.close()

            A.writeModelSdif(outpath + '-%d.sdif'%ci)
Example #3
0
        Ac = OMPursuit.OMPAnalysisConstraintSet(args.mpconstraint_path)
    else: 
        Ac = None

    if args.constraint_path:
        C = OMPursuit.OMPursuitCompoundConstraint(args.constraint_path)
    else:
        C = None

    markers = OMPursuit.OMPursuitMarkers(args.marker_path)
    target = OMPursuit.OMPursuitTarget(args.target_path, args.dsf)
    target.zeropadSignal(D, markers)
                                                     
    A = OMPursuit.OMPursuitAnalysis(D, target, markers, args.max_iterations, constraint=C, mpconstraint=Ac)
    A.constrainedMP()
    audiolab.aiffwrite(A.ompModel.signal, os.path.expanduser(args.output_path), A.ompModel.samplerate)
    audiolab.aiffwrite(A.ompTarget.signal, os.path.expanduser(args.res_output_path), A.ompModel.samplerate)

    A.writeModelSdif(args.sdif_output_path)
    
    #duration of analysis procedure, target name, SRR    if args.logfile != None:
        f = open(os.path.expanduser(args.logfile), 'w')
        f.write('Dictionary : %s\n'%args.dictionary_path)
        f.write('Constraint : %s\n'%args.constraint_path)
        f.write('MP Constraint : %s\n'%args.mpconstraint_path)
        f.write('Markers : %s\n'%args.marker_path)
        f.write('Max. iterations : %d\n'%args.max_iterations)
        f.write('Total soundgrains in model : %d'%len(A.ompModel.parameterArray))
        f.close()

Example #4
0
            markers = OMPursuit.OMPursuitMarkers(markerPaths[i])
            Ac = OMPursuit.OMPAnalysisConstraintSet(mpconstrPath)

            C = OMPursuit.OMPursuitCompoundConstraint(constraint)
            target = OMPursuit.OMPursuitTarget(targetPaths[i], dsfactor)
            target.zeropadSignal(D, markers)

            A = OMPursuit.OMPursuitAnalysis(D,
                                            target,
                                            markers,
                                            maxit,
                                            constraint=C,
                                            mpconstraint=Ac)
            A.constrainedMP()
            audiolab.aiffwrite(A.ompModel.signal,
                               os.path.expanduser(outpath + '-%d.aif' % ci),
                               A.ompModel.samplerate)

            #log the analysis data
            f = open(os.path.expanduser(outpath + '-%d.txt' % ci), 'w')
            f.write('Dictionary : %s\n' % path)
            f.write('Constraint : %s\n' % constraint)
            f.write('MPConstraint : %s\n' % mpconstrPath)
            f.write('Markers : %s\n' % markerPaths[i])
            f.write('Max. iterations : %d\n' % maxit)
            f.write('Total soundgrains in model : %d' %
                    len(A.ompModel.parameterArray))
            f.close()

            A.writeModelSdif(outpath + '-%d.sdif' % ci)