Skip to content

HelloWorld.c

Examples

/****************************************************************************
 *
 *      Hello World
 *      --------------
 *
 ****************************************************************************
 *
 *  Description:    Initialize an AWEOSInstance, open a tuning interface, connect to AWE Server. AWE Server will display the instance name "HiWorld"
 *
 *  Copyright: (c) 2020 DSP Concepts, Inc. All rights reserved.
 *                                  3235 Kifer Road
 *                                  Santa Clara, CA 95054-1527
 *
 * This example demonstrates initializing an AWEOSInstance and opening an integrated tuning interface. All default parameters are used, except for the instance name, which is changed to "HiWorld".
 * With this simple application, an integrated tuning socket is opened on port 15002. Run the example, and use AWE Server to connect via <Target's IP adress> and port 15002
 * This example is not realtime audio enabled, however module regression tests can be run from Matlab. (As long as they are not RT tests) 
 * 
***************************************************************************/

#include <stdio.h>
#include "AWECoreOS.h"
#include "ModuleList.h"

#define PORTNO 15002

//Step 1: Declare an AWEInstance pointer. This will be your handle that is passed in to most of the functions. Memory for the instance is allocated by aweOS_init()
AWEOSInstance *g_AWEOSInstance;

//Step 2: Declare an AWEOSConfigParameters structure. The members of this structure determine the configuration of the AWEInstance members. For this example, it will be populated with defaults
static AWEOSConfigParameters configParams; 

//Step 3: Declare a module descriptor table which will be passed into aweOS_init. This module descriptor table includes the modules as defined in ModuleList.h.
static const void* moduleDescriptorTable[] = 
{ 
    LISTOFCLASSOBJECTS 
};

//Step 4: Calculate the size of the  module descriptor table, which will be passed in to aweOS_init.
UINT32 moduleDescriptorTableSize = sizeof(moduleDescriptorTable) / sizeof(moduleDescriptorTable[0]); 

int main()
{
    printf("Entering Default Configuration Example ... \n");

    //Step 5: Populate the configParams structure with DSPC defined default values. 
    aweOS_getParamDefaults(&configParams); 

    //Step 5a. Overwrite the name to "HiWorld"
    configParams.pName = "HiWorld";

    //Step 6: Initialize the AWEInstance with the parameters that were previously set in the config structure. This will allocate the AWEInstance, assign its members, etc.
    INT32 ret = aweOS_init(&g_AWEOSInstance, &configParams, moduleDescriptorTable, moduleDescriptorTableSize); 

    //Step 7: Check if the aweOS_init succeeded. If it didn't then terminate the executable.
    if (ret != 0) 
    {
        printf("aweOS_init failed with error code %d %s. exiting application \n", ret, aweOS_errorToString(ret));
    }
    else 
    {
        printf("AWEOSInstance succesfully initialized... \n");
        //Step 8 (OPTIONAL): Open the aweOS integrated tuning interface. Note that this cannot be called before a succesful initialization. If called without succesful aweOS_init, it will fail
        INT32 interfaceRet = aweOS_tuningSocketOpen(&g_AWEOSInstance, PORTNO, 1);
        if (interfaceRet != 0)
        {
            printf("Failed to open integrated tuning interface \n");
        }
        else 
        {
            printf("Opened TCP tuning interface on port %d: Waiting for AWE Server Connection from PC... \n", PORTNO);
        }
        //Step 9: Enter main idle loop 
        while (1)
        {
            usleep(1000); 
        }
    }

    return 0;
}

Filename: HelloWorld.c


Updated on 2026-02-10 at 15:44:54 -0500