Skip to content

Commit

Permalink
audio: codec_adapter: add Waves api
Browse files Browse the repository at this point in the history
add Waves MaxxEffect API definition.
API is required to build SOF with Waves codec.

Signed-off-by: Oleksandr Strelchenko <oleksandr.strelchenko@waves.com>
  • Loading branch information
stolx authored and lgirdwood committed Apr 7, 2021
1 parent 2c69afc commit d9a7dfd
Show file tree
Hide file tree
Showing 9 changed files with 535 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/audio/codec_adapter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ endif()
if(CONFIG_WAVES_CODEC)
add_local_sources(sof codec/waves.c)
sof_add_static_library(MaxxChrome ${CMAKE_CURRENT_LIST_DIR}/lib/release/libMaxxChrome.a)
# folder with Waves API must be among include directories
target_include_directories(sof PUBLIC ${CMAKE_CURRENT_LIST_DIR}/../../include/sof/audio/codec_adapter/codec/)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2021 Waves Audio Ltd. All rights reserved.
*/
#ifndef MAXX_EFFECT_REVISION_H
#define MAXX_EFFECT_REVISION_H

#include <stdint.h>
#include "MaxxEffect/MaxxEffect.h"
#include "MaxxEffect/MaxxStatus.h"

#ifdef __cplusplus
extern "C" {
#endif

/*******************************************************************************
* Get null-terminated revision string.
*
* @param[in] effect Initialized effect.
* @param[out] revision Revision string.
* @param[out] bytes Revision string size. Optional, use NULL if not needed.
*
* @return 0 if success, otherwise fail
******************************************************************************/
MaxxStatus_t MaxxEffect_Revision_Get(
MaxxEffect_t* effect,
const char** revision,
uint32_t* bytes);

#ifdef __cplusplus
}
#endif

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2021 Waves Audio Ltd. All rights reserved.
*/
#ifndef MAXX_EFFECT_RPC_SERVER_H
#define MAXX_EFFECT_RPC_SERVER_H

#include <stdint.h>
#include "MaxxEffect/MaxxEffect.h"
#include "MaxxEffect/MaxxStatus.h"

#ifdef __cplusplus
extern "C" {
#endif

/*******************************************************************************
* Get required buffers size for communication.
*
* @param[in] effect initialized effect
* @param[out] requestBytes request buffer size
* @param[out] responseBytes response buffer size
*
* @return 0 if success, otherwise fail
******************************************************************************/
MaxxStatus_t MaxxEffect_GetMessageMaxSize(
MaxxEffect_t* effect,
uint32_t* requestBytes,
uint32_t* responseBytes);

/*******************************************************************************
* Process request buffer and provide with the response.
*
* @param[in] effect initialized effect
* @param[in] request request buffer
* @param[in] requestBytes request buffer size
* @param[out] response response buffer
* @param[out] responseBytes response buffer size
*
* @return 0 if success, otherwise fail
******************************************************************************/
MaxxStatus_t MaxxEffect_Message(
MaxxEffect_t* effect,
const void* request,
uint32_t requestBytes,
void* response,
uint32_t* responseBytes);

#ifdef __cplusplus
}
#endif

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2021 Waves Audio Ltd. All rights reserved.
*/
/*******************************************************************************
* @page Initialization_Default Default Initialization
*
* Refer to the diagram below for the default initialization workflow.
*
* ![Default initialization workflow]
* (Initialize/Default_Initialization.svg)
*
* Example code for the default effect initialization with the interleaved
* stereo streams processing at 48 kHz with Q1.31 fixed-point data samples:
*
* ~~~{.c}
* uint32_t bytes = 0;
* MaxxEffect_t* effect = NULL;
*
* // Get required size for storing MaxxEffect_t handler
* if (0 == MaxxEffect_GetEffectSize(&bytes))
* {
* // Allocate required size for effect
* effect = (MaxxEffect_t*)malloc(bytes);
* if (NULL != effect)
* {
* // Prepare expected formats
* // Identical for both input and output streams
* MaxxStreamFormat_t const expectedFormat = {
* .sampleRate = 48000,
* .numChannels = 2,
* .samplesFormat = MAXX_BUFFER_FORMAT_Q1_31,
* .samplesLayout = MAXX_BUFFER_LAYOUT_INTERLEAVED
* };
*
* // Prepare I/O stream format arrays
* MaxxStreamFormat_t const* inputFormats[1];
* MaxxStreamFormat_t const* outputFormats[1];
* inputFormats[0] = &expectedFormat;
* outputFormats[0] = &expectedFormat;
*
* // Initialize effect with the expected IO formats
* if (0 == MaxxEffect_Initialize(effect,
* inputFormats, 1,
* outputFormats, 1))
* {
* // MaxxEffect successfully initialized
* }
* }
* }
* ~~~
******************************************************************************/
#ifndef MAXX_EFFECT_INITIALIZE_H
#define MAXX_EFFECT_INITIALIZE_H

#include <stdint.h>
#include "MaxxEffect/MaxxEffect.h"
#include "MaxxEffect/MaxxStatus.h"
#include "MaxxEffect/MaxxStream.h"

#ifdef __cplusplus
extern "C" {
#endif

/*******************************************************************************
* Provides with the required data size for holding @ref MaxxEffect_t handler.
* It is caller responsibility to allocate enough memory (bytes) for effect.
*
* @see MaxxEffect_Initialize for allocated effect initialization
*
* @param[out] bytes required data size
*
* @return 0 if success, otherwise fail
******************************************************************************/
MaxxStatus_t MaxxEffect_GetEffectSize(
uint32_t* bytes);


/*******************************************************************************
* Initializes preallocated @ref MaxxEffect_t handler to the requested scenario.
* Required scenario is determined based on the provided streams formats.
* Supported streams count is defined by specific product.
*
* @see MaxxEffect_GetEffectSize for the required effect size
*
* @param[in] effect pointer to the pre-allocated handler
* @param[in] inputFormats array of pointers to the input formats
* @param[in] inputFormatsCount number of elements in the inputFormats
* @param[in] outputFormats array of pointers to the output formats
* @param[in] outputFormatsCount number of elements in the outputFormats
*
* @return 0 if effect is initialized, non-zero error code otherwise
******************************************************************************/
MaxxStatus_t MaxxEffect_Initialize(
MaxxEffect_t* effect,
MaxxStreamFormat_t* const inputFormats[],
uint32_t inputFormatsCount,
MaxxStreamFormat_t* const outputFormats[],
uint32_t outputFormatsCount);

#ifdef __cplusplus
}
#endif

#endif
53 changes: 53 additions & 0 deletions src/include/sof/audio/codec_adapter/codec/MaxxEffect/MaxxEffect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2021 Waves Audio Ltd. All rights reserved.
*/
/*******************************************************************************
* @page CoreConcepts_MaxxEffect MaxxEffect
*
* @ref MaxxEffect_t or simply **effect** - is a Waves algorithms handler, that
* contains:
* @ref MaxxEffect_InternalData_Parameters,
* @ref MaxxEffect_InternalData_Coefficients,
* @ref MaxxEffect_InternalData_States,
* @ref MaxxEffect_InternalData_Meters, etc. required during
* effect life-cycle. It is caller responsibility to allocate enough memory
* for storing effect handler, and to properly initialize it. Refer to the
* @ref Initialization page for handler allocation and initialization.
*
* @section MaxxEffect_InternalData Data structures
* @subsection MaxxEffect_InternalData_Parameters Parameters
* Data segment with algorithms parameters representing some
* configuration available for tuning, e.g. Master Bypass, Mute, Parametric
* EQ band frequency, gain etc. *Parameters preset* is an array of parameter
* ID and float-point value (id, value) pairs. Might not be included in
* MaxxEffect handler. **Updated in the control path.**
*
* @subsection MaxxEffect_InternalData_Coefficients Coefficients
* Data segment with algorithms coefficients such as filters
* difference equations. Computed from parameters and used for processing.
* Single coefficient is represented by its ID and the corresponding buffer.
* *Coefficients preset* is an array of such pairs.
* **Updated in the control path.**
*
* @subsection MaxxEffect_InternalData_States States
* Data segment with algorithms states.
* **Updated in the data path.**
*
* @subsection MaxxEffect_InternalData_Meters Meters
* Data segment with algorithms meters representing measure of some value
* over a period of time, e.g. level, gain reduction, peak, etc.
* **Updated in the data path.**
******************************************************************************/
#ifndef MAXX_EFFECT_H
#define MAXX_EFFECT_H

/**
* Waves effect handler.
*
* @see @ref CoreConcepts_MaxxEffect
*/
typedef void MaxxEffect_t;


#endif
15 changes: 15 additions & 0 deletions src/include/sof/audio/codec_adapter/codec/MaxxEffect/MaxxStatus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2021 Waves Audio Ltd. All rights reserved.
*/
#ifndef MAXX_STATUS_H
#define MAXX_STATUS_H

#include <stdint.h>

/**
* Non-zero value represents error code type
*/
typedef int32_t MaxxStatus_t;

#endif
Loading

0 comments on commit d9a7dfd

Please sign in to comment.