Skip to content

ConstantQ #2

@Murivan

Description

@Murivan

I am having some issues with the ConstantQ Transform.
By analyzing the same file with the same chain, but with different min and max frequencies I am getting results that don't seem to be consistent.

This is a minimal example:
SignalSource source = new AudioSignalSource(new File("test.wav"));

    int windowLength = 2048;
    WindowFunction windowFunction = new WindowFunction.Hamming(windowLength);

    int hopSize = 1024;
    float minFrequency = 8.1757f;
    float maxFrequency = 12543.853f;
    int binsPerSemitone = 1;

    SignalPump<AudioBuffer> pump = new SignalPump<>(source);
    SignalPipeline<AudioBuffer, LogFrequencySpectrum> cqtPipeline = new SignalPipeline<>(
            new Mono(),                                             // if there are more than one channel, reduce them to mono
            new SlidingWindow(windowFunction.getLength(), hopSize),
            new Mapping<>(AudioBufferFunctions.createMapFunction(windowFunction)),
            new ConstantQTransform(minFrequency, maxFrequency, 12 * binsPerSemitone),
            new AbstractSignalProcessor<LogFrequencySpectrum, ArrayList<LogFrequencySpectrum>>("specID") {  // aggregate the CQTs to a spectrum with id "specID" (needed to access it in the results)
                private final ArrayList<LogFrequencySpectrum> spectrogram = new ArrayList<>();

                @Override
                protected ArrayList<LogFrequencySpectrum> processNext(LogFrequencySpectrum input) throws IOException {
                    this.spectrogram.add(input);
                    return this.spectrogram;
                }
            }
    );
    pump.add(cqtPipeline);
    Map<Object, Object> results = pump.pump();
    ArrayList<LogFrequencySpectrum> result = (ArrayList<LogFrequencySpectrum>) results.get("specID");

Thanks for helping.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions