Giter VIP home page Giter VIP logo

Comments (5)

protyposis avatar protyposis commented on June 8, 2024

If it crashes there must be an error message. What is it?

I just tested it in VS2019 and it works out of the box. If you look at the demo code you'll see that all it does is resample a few samples, print one line to the console (only the console, not the debug output window of your IDE), and exit.

// Print result
Console.WriteLine("{0} samples resampled to {1} samples (expected {2})",
totalInputSampleCount, totalOutputSampleCount,
sourceData.Length / inputRate * outputRate);

from src.net.

Darth-Carrotpie avatar Darth-Carrotpie commented on June 8, 2024

The thing is, that there is no message. It's just a hard crash without any messages or prompts.
My use case attempt was to convert a single input (I get a small data amount per each frame) to a required sample rate (44.1kHz to 16kHz), in order to be able to input that resampled data into a neural network.
So it's basically a real-time use case attempt:

public class SRCConverter {
    SampleRateConverter src;
    int inputSampleCount;
    int outputSampleCount;
    float[] outputBuffer = new float[2048];
    int inputRate, outputRate;

    public SRCConverter(int _inputRate, int _outputRate) {
        src = new SampleRateConverter(ConverterType.SRC_SINC_MEDIUM_QUALITY, 1);
        inputRate = _inputRate;
        outputRate = _outputRate;
    }

    public float[] SingleConversion(float[] sourceData) {
        src.SetRatio(outputRate / inputRate);
        src.Process(sourceData, 0, sourceData.Length,
            outputBuffer, 0, outputBuffer.Length,
            true, out inputSampleCount, out outputSampleCount);

        float[] output = new float[outputSampleCount];
        Array.Copy(outputBuffer, output, outputSampleCount);
        output = outputBuffer;
        return output;
    }
}

Usage:
float[] data = converter.SingleConversion(_input.audioDataSlice.ToArray());
audioDataSlice[] is quite small, around 60-70 values. Could that be the problem? Does it expect large arrays?

from src.net.

protyposis avatar protyposis commented on June 8, 2024

A small number of samples should be fine. If the number is too small you just won't get any output until you feed it more data. Then my guess would be an incompatibility with your Unity environment - can't help with that, sorry.

from src.net.

Darth-Carrotpie avatar Darth-Carrotpie commented on June 8, 2024

I see. Oh well :(
BTW, when you tested it, was it on Dot NET Standard 2.1?

from src.net.

protyposis avatar protyposis commented on June 8, 2024

<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>

from src.net.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.