package net.heartshield.sensors;

/**
 * @author David Madl (git@abanbytes.eu)
 * @date 2017-05-17
 */
public interface IAudioSensorBase {
    double getFps();

    void start();

    void stop();

    byte[] getPCM();

    void setReadToBufSizeRatio(int ratio);

    enum State {
        STOPPED,
        STARTING, // internal transition state, not exposed via onState()
        RUNNING,
        STOPPING, // internal transition state, not exposed via onState()
        FAILED
    }

    interface Listener {
        /**
         * one or more samples were added
         */
        //void onData(int offset, int length);
        void onData(double[] buf);

        /** state change occurred */
        void onState(State newState);
    }

    void setListener(Listener listener);
}
