Basic Processing Configuration Mode

The Basic Processing Configuration Mode is used to support older Mimi Processors which only supported Mimi Media Sound Personalization. This configuration allows you to specify the personalization mode and define applicators for processing parameters including isEnabled, intensity, and preset.

Session Activation with a MimiBasicProcessingConfiguration

Before activating a MimiProcessingSession, the preset Tech-Level should be read from the Mimi Processing System on the device/headphones.

Personalization Modes

Currently, two Personalization modes i.e. FineTuning (which is the recommended option) and SinglePreset are supported. The FineTuning mode provides up to three presets (up, down and default) whereas the SinglePreset mode provides one personalization preset. The presets are based on the user’s hearing profile.

Note: The three (up, down and default) FineTuning presets are available depending on the user’s hearing profile and there may be cases where it is not possible to generate the either the up preset or the down preset. In such cases. However, the default preset will be available.

An example MimiProcessingSession for a Fine Tuning type of Personalization for a Tech-level 4 Processor can be activated as follows:

do {
    // Read Tech-Level from the Mimi Processor on the device
    let fitting = MimiPersonalization.Fitting.techLevel(4) // An example fitting, yours will be defined by the Mimi Processor on the device.

    let configuration = try MimiBasicProcessingConfiguration {
        SoundPersonalization {
            FineTuning(fitting: fitting)

            Applicators {
                IsEnabled { value in
                    // Apply the isEnabled value to your audio processing system
                }

                Intensity { value in
                    // Apply the intensity value to your audio processing system
                }

                Preset { value in
                    // Apply the preset value to your audio processing system
                }
            }
        }
    }
    let session = try await MimiCore.shared.processing.activate(configuration: configuration)
} catch {
    // Handle activation failure
}

Application timeout

It is also possible to set a timeout for the application of a value in the IsEnabled, Intensity and Preset applicators. If the value application exceeds this timeout, it will cause the entire value application sequence to fail.

let configuration = try MimiBasicProcessingConfiguration {
    SoundPersonalization {
        FineTuning(fitting: fitting)

        Applicators {
            IsEnabled(timeout: 0.5) { value in
                // Apply the isEnabled value or throw an error.
                // If the timeout is exceeded, it causes the value application sequence to fail
                // and throws the MimiProcessingParameterError.applyTimeoutExceeded error.
            }

            Intensity { value in
                // Apply the intensity value to your audio processing system
            }

            Preset { value in
                // Apply the preset value to your audio processing system
            }
        }
    }
}

When the timeout elapses the SDK throws MimiProcessingParameterError.applyTimeoutExceeded, stops waiting for the applicator and moves on to the next operation on that parameter. The parameter’s value is left unchanged and its updateState reports the failure. The value may nevertheless have reached the device just as the timeout fired.

The applicator’s task is cancelled, but the SDK cannot abort code that does not observe cancellation: an applicator that is waiting for a device reply through a continuation keeps waiting. The SDK never invokes the applicator again while such an invocation is still running. The parameter’s next application waits for it to return first, so values reach the device in the order they were applied, and that wait counts towards the next application’s own timeout: while the applicator does not return, every further application fails with applyTimeoutExceeded without invoking it. If the timed-out invocation eventually succeeds, the SDK takes note that the device holds its value, although the application was reported as failed, and a later application of any other value, including the parameter’s current one, is sent to the device rather than skipped as already applied.

An applicator that never returns therefore keeps its parameter from being applied. To avoid this, an applicator should stop its own work when its task is cancelled: resume its continuation from the onCancel block of withTaskCancellationHandler, guarding the continuation so that it is resumed only once because the device reply may still arrive afterwards, or bound the transport call with a timeout of its own that is no longer than the applicator timeout. Cancelling the task that called apply also returns at once, with CancellationError, whether or not a timeout is set, and is subject to the same rules: the invocation that is already running is waited for by the next application. If the applicator was already running for the cancelled call, the parameter’s updateState stays .applying rather than reporting a failure; a call cancelled before the applicator was invoked for it still reports .failed at once. Once the applicator returns it reports .applied and value is updated, or it reports .failed with the applicator’s error; if another operation on the parameter has started in the meantime, only value is updated. An application that timed out is followed up as well: it has already reported .failed with applyTimeoutExceeded, and if the applicator then returns successfully value is updated and .applied is reported under the same conditions; if the applicator throws, the reported timeout stands. An applicator that stops because its task was cancelled must therefore throw: returning normally reports the value as applied.

Once there is an activated MimiProcessingSession, it is possible to access the processing parameters and configure them appropriately.

  • Activating a session will set the session property on the MimiProcessingController allowing the session to be easily referenced.
  • Only a single session can be activated at one time.
  • MimiProcessingController.sessionPublisher is a AnyPublisher and can be subscribed for changes that occur during the activation & deactivation of a session.

Tip: Most partner integrations will only need to use a single MimiProcessingSession that roughly aligns with the headphone connectivity lifecycle.