Night & AirSDKContact team

Platform guide · C and C++

Native C integration

Embed the C99 detector in an existing audio pipeline. A session owns the evidence for one recording timeline.

Submit PCM and finish

This complete function accepts a resident mono part and copies the session summary to the caller. Use a worker thread and check the returned na_status.

#include "nightair_snore.h"

na_status analyze(const float *mono, int64_t frames,
                  uint32_t rate, na_summary *out) {
    na_session *session = 0;
    na_status status = na_session_create(&session);
    if (status == NA_OK) {
        status = na_session_add_pcm(session, rate, 0, mono, frames);
    }
    if (status == NA_OK) {
        status = na_session_finish(session, out);
    }
    na_session_destroy(session);
    return status;
}

To read individual intervals, call na_session_event(session, i, &event) after a successful finish and before destroying the session. Valid indices run from zero through out->event_count - 1 when the count is positive.

Supply a seekable reader

For larger parts, submit na_session_add_part with an na_read_pcm callback. The callback receives a part-relative offset and a buffer for up to 16,384 mono float samples. Return a positive number of samples written. A zero or negative return signals a read failure. Each read of the same range must yield identical samples.

A failed addition preserves earlier parts. Serialize calls on each session and release it with na_session_destroy. Separate sessions can run concurrently. Use na_status_message for a readable error.

Check your build

The evaluation kit includes a nightair-wav executable target and a CTest parity check. The quickstart shows the build command and expected results. To compare SDK runs, log na_sdk_version(), na_model_version() and na_configuration_id().

Next guideAPI reference