summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Nelissen <marcone@google.com>2020-03-20 17:08:03 -0700
committerMarco Nelissen <marcone@google.com>2020-03-25 23:49:14 +0000
commitaf41595537b044618234fe7dd9ebfcc652de1576 (patch)
tree78e3eb65de4c980cfd4dbfc1f1559fdfacab222d
parent99c41357d1c1161d3b0976a66603418bef8aed1b (diff)
downloadsonivox-af41595537b044618234fe7dd9ebfcc652de1576.tar.gz
Remove unused code from midi engine
Bug: 151448144 Test: build, CTS Change-Id: Id8952cd036052d7f7ca71e5cedbc24f7ae2c852b
-rw-r--r--arm-wt-22k/Android.bp10
-rw-r--r--arm-wt-22k/host_src/eas.h429
-rw-r--r--arm-wt-22k/host_src/eas_main.c464
-rw-r--r--arm-wt-22k/host_src/eas_wave.c423
-rw-r--r--arm-wt-22k/host_src/eas_wave.h74
-rw-r--r--arm-wt-22k/lib_src/eas_chorus.c604
-rw-r--r--arm-wt-22k/lib_src/eas_chorusdata.c34
-rw-r--r--arm-wt-22k/lib_src/eas_chorusdata.h160
-rw-r--r--arm-wt-22k/lib_src/eas_data.h4
-rw-r--r--arm-wt-22k/lib_src/eas_ima_tables.c54
-rw-r--r--arm-wt-22k/lib_src/eas_imaadpcm.c368
-rw-r--r--arm-wt-22k/lib_src/eas_pcm.c1401
-rw-r--r--arm-wt-22k/lib_src/eas_pcm.h264
-rw-r--r--arm-wt-22k/lib_src/eas_public.c903
-rw-r--r--arm-wt-22k/lib_src/eas_smf.c5
-rw-r--r--arm-wt-22k/lib_src/eas_wavefile.c867
-rw-r--r--arm-wt-22k/lib_src/eas_wavefile.h63
-rw-r--r--arm-wt-22k/lib_src/eas_wavefiledata.c33
18 files changed, 8 insertions, 6152 deletions
diff --git a/arm-wt-22k/Android.bp b/arm-wt-22k/Android.bp
index 55fa862..ad4db48 100644
--- a/arm-wt-22k/Android.bp
+++ b/arm-wt-22k/Android.bp
@@ -1,13 +1,9 @@
cc_library {
name: "libsonivox",
srcs: [
- "lib_src/eas_chorus.c",
- "lib_src/eas_chorusdata.c",
"lib_src/eas_data.c",
"lib_src/eas_dlssynth.c",
"lib_src/eas_flog.c",
- "lib_src/eas_ima_tables.c",
- "lib_src/eas_imaadpcm.c",
"lib_src/eas_imelody.c",
"lib_src/eas_imelodydata.c",
"lib_src/eas_math.c",
@@ -38,12 +34,6 @@ cc_library {
"host_src/eas_config.c",
"host_src/eas_hostmm.c",
"host_src/eas_report.c",
-
- // not using these modules
- //"host_src/eas_main.c",
- //"host_src/eas_wave.c",
- //"lib_src/eas_wavefile.c",
- //"lib_src/eas_wavefiledata.c",
],
cflags: [
diff --git a/arm-wt-22k/host_src/eas.h b/arm-wt-22k/host_src/eas.h
index c64af49..8b41b07 100644
--- a/arm-wt-22k/host_src/eas.h
+++ b/arm-wt-22k/host_src/eas.h
@@ -169,73 +169,6 @@ EAS_PUBLIC EAS_RESULT EAS_Shutdown (EAS_DATA_HANDLE pEASData);
EAS_PUBLIC EAS_RESULT EAS_Render (EAS_DATA_HANDLE pEASData, EAS_PCM *pOut, EAS_I32 numRequested, EAS_I32 *pNumGenerated);
/*----------------------------------------------------------------------------
- * EAS_SetRepeat()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the selected stream to repeat.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * streamHandle - handle to stream
- * repeatCount - repeat count (0 = no repeat, -1 = repeat forever)
- *
- * Outputs:
- *
- * Side Effects:
- *
- * Notes:
- * 0 = no repeat
- * 1 = repeat once, i.e. play through twice
- * -1 = repeat forever
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetRepeat (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 repeatCount);
-
-/*----------------------------------------------------------------------------
- * EAS_GetRepeat()
- *----------------------------------------------------------------------------
- * Purpose:
- * Gets the current repeat count for the selected stream.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * streamHandle - handle to stream
- * pRrepeatCount - pointer to variable to hold repeat count
- *
- * Outputs:
- *
- * Side Effects:
- *
- * Notes:
- * 0 = no repeat
- * 1 = repeat once, i.e. play through twice
- * -1 = repeat forever
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetRepeat (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 *pRepeatCount);
-
-/*----------------------------------------------------------------------------
- * EAS_SetPlaybackRate()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the playback rate.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * streamHandle - handle to stream
- * rate - rate (28-bit fractional amount)
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPlaybackRate (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_U32 rate);
-#define MAX_PLAYBACK_RATE (EAS_U32)(1L << 29)
-#define MIN_PLAYBACK_RATE (EAS_U32)(1L << 27)
-
-/*----------------------------------------------------------------------------
* EAS_SetTransposition)
*----------------------------------------------------------------------------
* Purpose:
@@ -257,126 +190,6 @@ EAS_PUBLIC EAS_RESULT EAS_SetPlaybackRate (EAS_DATA_HANDLE pEASData, EAS_HANDLE
EAS_PUBLIC EAS_RESULT EAS_SetTransposition (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 transposition);
#define MAX_TRANSPOSE 12
-/*----------------------------------------------------------------------------
- * EAS_SetSynthPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the polyphony of the synthesizer. Value must be >= 1 and <= the
- * maximum number of voices. This function will pin the polyphony
- * at those limits
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * synthNum - synthesizer number (0 = onboard, 1 = DSP)
- * polyphonyCount - the desired polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetSynthPolyphony (EAS_DATA_HANDLE pEASData, EAS_I32 synthNum, EAS_I32 polyphonyCount);
-
-/*----------------------------------------------------------------------------
- * EAS_GetSynthPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current polyphony setting of the synthesizer
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * synthNum - synthesizer number (0 = onboard, 1 = DSP)
- * pPolyphonyCount - pointer to variable to receive polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetSynthPolyphony (EAS_DATA_HANDLE pEASData, EAS_I32 synthNum, EAS_I32 *pPolyphonyCount);
-
-/*----------------------------------------------------------------------------
- * EAS_SetPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the polyphony of the stream. Value must be >= 1 and <= the
- * maximum number of voices. This function will pin the polyphony
- * at those limits
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * polyphonyCount - the desired polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPolyphony (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 polyphonyCount);
-
-/*----------------------------------------------------------------------------
- * EAS_GetPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current polyphony setting of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * pPolyphonyCount - pointer to variable to receive polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetPolyphony (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 *pPolyphonyCount);
-
-/*----------------------------------------------------------------------------
- * EAS_SetPriority()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the priority of the stream. Determines which stream's voices
- * are stolen when there are insufficient voices for all notes.
- * Value must be in the range of 1-255, lower values are higher
- * priority. The default priority is 50.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * polyphonyCount - the desired polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPriority (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 priority);
-
-/*----------------------------------------------------------------------------
- * EAS_GetPriority()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current priority setting of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * pPriority - pointer to variable to receive priority
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetPriority (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 *pPriority);
/*----------------------------------------------------------------------------
* EAS_SetVolume()
@@ -400,63 +213,6 @@ EAS_PUBLIC EAS_RESULT EAS_GetPriority (EAS_DATA_HANDLE pEASData, EAS_HANDLE stre
EAS_PUBLIC EAS_RESULT EAS_SetVolume (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 volume);
/*----------------------------------------------------------------------------
- * EAS_GetVolume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the master volume for the mixer in 1dB increments.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * volume - the desired master volume
- *
- * Outputs:
- *
- *
- * Side Effects:
- * overrides any previously set master volume from sysex
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_I32 EAS_GetVolume (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle);
-
-/*----------------------------------------------------------------------------
- * EAS_SetMaxLoad()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the maximum workload the parsers will do in a single call to
- * EAS_Render. The units are currently arbitrary, but should correlate
- * well to the actual CPU cycles consumed. The primary effect is to
- * reduce the occasional peaks in CPU cycles consumed when parsing
- * dense parts of a MIDI score. Setting maxWorkLoad to zero disables
- * the workload limiting function.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * maxLoad - the desired maximum workload
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetMaxLoad (EAS_DATA_HANDLE pEASData, EAS_I32 maxLoad);
-
-/*----------------------------------------------------------------------------
- * EAS_SetMaxPCMStreams()
- *----------------------------------------------------------------------------
- * Sets the maximum number of PCM streams allowed in parsers that
- * use PCM streaming.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * maxNumStreams - maximum number of PCM streams
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetMaxPCMStreams (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 maxNumStreams);
-
-/*----------------------------------------------------------------------------
* EAS_OpenFile()
*----------------------------------------------------------------------------
* Purpose:
@@ -728,24 +484,6 @@ EAS_PUBLIC EAS_RESULT EAS_CloseMIDIStream (EAS_DATA_HANDLE pEASData, EAS_HANDLE
EAS_PUBLIC EAS_RESULT EAS_Locate (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_I32 milliseconds, EAS_BOOL offset);
/*----------------------------------------------------------------------------
- * EAS_GetRenderTime()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current playback offset
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- *
- * Outputs:
- * Gets the render time clock in msecs.
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetRenderTime (EAS_DATA_HANDLE pEASData, EAS_I32 *pTime);
-
-/*----------------------------------------------------------------------------
* EAS_GetLocation()
*----------------------------------------------------------------------------
* Purpose:
@@ -809,29 +547,6 @@ EAS_PUBLIC EAS_RESULT EAS_Pause (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHand
EAS_PUBLIC EAS_RESULT EAS_Resume (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle);
/*----------------------------------------------------------------------------
- * EAS_GetParameter()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the parameter of a module. See E_MODULES for a list of modules
- * and the header files of the modules for a list of parameters.
- *
- * Inputs:
- * psEASData - pointer to overall EAS data structure
- * module - enumerated module number
- * param - enumerated parameter number
- * pValue - pointer to variable to receive parameter value
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetParameter (EAS_DATA_HANDLE pEASData, EAS_I32 module, EAS_I32 param, EAS_I32 *pValue);
-
-/*----------------------------------------------------------------------------
* EAS_SetParameter()
*----------------------------------------------------------------------------
* Purpose:
@@ -894,150 +609,6 @@ EAS_PUBLIC EAS_RESULT EAS_MetricsReset (EAS_DATA_HANDLE pEASData);
#endif
/*----------------------------------------------------------------------------
- * EAS_SetSoundLibrary()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the location of the sound library.
- *
- * Inputs:
- * pEASData - instance data handle
- * streamHandle - file or stream handle
- * pSoundLib - pointer to sound library
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetSoundLibrary (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_SNDLIB_HANDLE pSndLib);
-
-/*----------------------------------------------------------------------------
- * EAS_SetHeaderSearchFlag()
- *----------------------------------------------------------------------------
- * By default, when EAS_OpenFile is called, the parsers check the
- * first few bytes of the file looking for a specific header. Some
- * mobile devices may add a header to the start of a file, which
- * will prevent the parser from recognizing the file. If the
- * searchFlag is set to EAS_TRUE, the parser will search the entire
- * file looking for the header. This may enable EAS to recognize
- * some files that it would ordinarily reject. The negative is that
- * it make take slightly longer to process the EAS_OpenFile request.
- *
- * Inputs:
- * pEASData - instance data handle
- * searchFlag - search flag (EAS_TRUE or EAS_FALSE)
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetHeaderSearchFlag (EAS_DATA_HANDLE pEASData, EAS_BOOL searchFlag);
-
-/*----------------------------------------------------------------------------
- * EAS_SetPlayMode()
- *----------------------------------------------------------------------------
- * Some file formats support special play modes, such as iMode partial
- * play mode. This call can be used to change the play mode. The
- * default play mode (usually straight playback) is always zero.
- *
- * Inputs:
- * pEASData - instance data handle
- * handle - file or stream handle
- * playMode - play mode (see eas_types.h for enumerations)
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPlayMode (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 playMode);
-
-#ifdef DLS_SYNTHESIZER
-/*----------------------------------------------------------------------------
- * EAS_LoadDLSCollection()
- *----------------------------------------------------------------------------
- * Purpose:
- * Downloads a DLS collection
- *
- * Inputs:
- * pEASData - instance data handle
- * streamHandle - file or stream handle
- * locator - file locator
- *
- * Outputs:
- *
- *
- * Side Effects:
- * May overlay instruments in the GM sound set
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_LoadDLSCollection (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_FILE_LOCATOR locator);
-#endif
-
-/*----------------------------------------------------------------------------
- * EAS_SetFrameBuffer()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the frame buffer pointer passed to the IPC communications functions
- *
- * Inputs:
- * pEASData - instance data handle
- * locator - file locator
- *
- * Outputs:
- *
- *
- * Side Effects:
- * May overlay instruments in the GM sound set
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetFrameBuffer (EAS_DATA_HANDLE pEASData, EAS_FRAME_BUFFER_HANDLE pFrameBuffer);
-
-#ifdef EXTERNAL_AUDIO
-/*----------------------------------------------------------------------------
- * EAS_RegExtAudioCallback()
- *----------------------------------------------------------------------------
- * Purpose:
- * Registers callback functions for audio events.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - file or stream handle
- * cbProgChgFunc - pointer to host callback function for program change
- * cbEventFunc - pointer to host callback functio for note events
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_RegExtAudioCallback (EAS_DATA_HANDLE pEASData,
- EAS_HANDLE streamHandle,
- EAS_VOID_PTR pInstData,
- EAS_EXT_PRG_CHG_FUNC cbProgChgFunc,
- EAS_EXT_EVENT_FUNC cbEventFunc);
-
-/*----------------------------------------------------------------------------
- * EAS_GetMIDIControllers()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current state of MIDI controllers on the requested channel.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - file or stream handle
- * pControl - pointer to structure to receive data
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetMIDIControllers (EAS_DATA_HANDLE pEASData, EAS_HANDLE streamHandle, EAS_U8 channel, S_MIDI_CONTROLLERS *pControl);
-#endif
-
-/*----------------------------------------------------------------------------
* EAS_SearchFile
*----------------------------------------------------------------------------
* Search file for specific sequence starting at current file
diff --git a/arm-wt-22k/host_src/eas_main.c b/arm-wt-22k/host_src/eas_main.c
deleted file mode 100644
index 5cbf064..0000000
--- a/arm-wt-22k/host_src/eas_main.c
+++ /dev/null
@@ -1,464 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_main.c
- *
- * Contents and purpose:
- * The entry point and high-level functions for the EAS Synthesizer test
- * harness.
- *
- * Copyright Sonic Network Inc. 2004
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 775 $
- * $Date: 2007-07-20 10:11:11 -0700 (Fri, 20 Jul 2007) $
- *----------------------------------------------------------------------------
-*/
-
-#ifdef _lint
-#include "lint_stdlib.h"
-#else
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#endif
-
-#include "eas.h"
-#include "eas_wave.h"
-#include "eas_report.h"
-
-/* determines how many EAS buffers to fill a host buffer */
-#define NUM_BUFFERS 8
-
-/* default file to play if no filename is specified on the command line */
-static const char defaultTestFile[] = "test.mid";
-
-EAS_I32 polyphony;
-
-/* prototypes for helper functions */
-static void StrCopy(char *dest, const char *src, EAS_I32 size);
-static EAS_BOOL ChangeFileExt(char *str, const char *ext, EAS_I32 size);
-static EAS_RESULT PlayFile (EAS_DATA_HANDLE easData, const char* filename, const char* outputFile, const S_EAS_LIB_CONFIG *pLibConfig, void *buffer, EAS_I32 bufferSize);
-static EAS_BOOL EASLibraryCheck (const S_EAS_LIB_CONFIG *pLibConfig);
-
-/* main is defined after playfile to avoid the need for two passes through lint */
-
-/*----------------------------------------------------------------------------
- * PlayFile()
- *----------------------------------------------------------------------------
- * Purpose:
- * This function plays the file requested by filename
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-
-static EAS_RESULT PlayFile (EAS_DATA_HANDLE easData, const char* filename, const char* outputFile, const S_EAS_LIB_CONFIG *pLibConfig, void *buffer, EAS_I32 bufferSize)
-{
- EAS_HANDLE handle;
- EAS_RESULT result, reportResult;
- EAS_I32 count;
- EAS_STATE state;
- EAS_I32 playTime;
- char waveFilename[256];
- WAVE_FILE *wFile;
- EAS_INT i;
- EAS_PCM *p;
- EAS_FILE file;
-
- /* determine the name of the output file */
- wFile = NULL;
- if (outputFile == NULL)
- {
- StrCopy(waveFilename, filename, sizeof(waveFilename));
- if (!ChangeFileExt(waveFilename, "wav", sizeof(waveFilename)))
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Error in output filename %s\n", waveFilename); */ }
- return EAS_FAILURE;
- }
- outputFile = waveFilename;
- }
-
- /* call EAS library to open file */
- file.path = filename;
- file.fd = 0;
- if ((reportResult = EAS_OpenFile(easData, &file, &handle)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_OpenFile returned %ld\n", reportResult); */ }
- return reportResult;
- }
-
- /* prepare to play the file */
- if ((result = EAS_Prepare(easData, handle)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_Prepare returned %ld\n", result); */ }
- reportResult = result;
- }
-
- /* get play length */
- if ((result = EAS_ParseMetaData(easData, handle, &playTime)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_ParseMetaData returned %ld\n", result); */ }
- return result;
- }
- EAS_ReportEx(_EAS_SEVERITY_NOFILTER, 0xe624f4d9, 0x00000005 , playTime / 1000, playTime % 1000);
-
- if (reportResult == EAS_SUCCESS)
- {
- /* create the output file */
- wFile = WaveFileCreate(outputFile, pLibConfig->numChannels, pLibConfig->sampleRate, sizeof(EAS_PCM) * 8);
- if (!wFile)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Unable to create output file %s\n", waveFilename); */ }
- reportResult = EAS_FAILURE;
- }
- }
-
- /* rendering loop */
- while (reportResult == EAS_SUCCESS)
- {
-
- /* we may render several buffers here to fill one host buffer */
- for (i = 0, p = buffer; i < NUM_BUFFERS; i++, p+= pLibConfig->mixBufferSize * pLibConfig->numChannels)
- {
-
- /* get the current time */
- if ((result = EAS_GetLocation(easData, handle, &playTime)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_GetLocation returned %d\n",result); */ }
- if (reportResult == EAS_SUCCESS)
- reportResult = result;
- break;
- }
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Parser time: %d.%03d\n", playTime / 1000, playTime % 1000); */ }
-
- /* render a buffer of audio */
- if ((result = EAS_Render(easData, p, pLibConfig->mixBufferSize, &count)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_Render returned %d\n",result); */ }
- if (reportResult == EAS_SUCCESS)
- reportResult = result;
- }
- }
-
- if (result == EAS_SUCCESS)
- {
- /* write it to the wave file */
- if (WaveFileWrite(wFile, buffer, bufferSize) != bufferSize)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "WaveFileWrite failed\n"); */ }
- reportResult = EAS_FAILURE;
- }
- }
-
- if (reportResult == EAS_SUCCESS)
- {
- /* check stream state */
- if ((result = EAS_State(easData, handle, &state)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_State returned %d\n", result); */ }
- reportResult = result;
- }
-
- /* is playback complete */
- if ((state == EAS_STATE_STOPPED) || (state == EAS_STATE_ERROR))
- break;
- }
- }
-
- /* close the output file */
- if (wFile)
- {
- if (!WaveFileClose(wFile))
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Error closing wave file %s\n", waveFilename); */ }
- if (reportResult == EAS_SUCCESS)
- result = EAS_FAILURE;
- }
- }
-
- /* close the input file */
- if ((result = EAS_CloseFile(easData,handle)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_Close returned %ld\n", result); */ }
- if (reportResult == EAS_SUCCESS)
- result = EAS_FAILURE;
- }
-
- return reportResult;
-} /* end PlayFile */
-
-/*----------------------------------------------------------------------------
- * main()
- *----------------------------------------------------------------------------
- * Purpose: The entry point for the EAS sample application
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-int main( int argc, char **argv )
-{
- EAS_DATA_HANDLE easData;
- const S_EAS_LIB_CONFIG *pLibConfig;
- void *buffer;
- EAS_RESULT result, playResult;
- EAS_I32 bufferSize;
- int i;
- int temp;
- FILE *debugFile;
- char *outputFile = NULL;
-
- /* set the error reporting level */
- EAS_SetDebugLevel(_EAS_SEVERITY_INFO);
- debugFile = NULL;
-
- /* process command-line arguments */
- for (i = 1; i < argc; i++)
- {
- /* check for switch */
- if (argv[i][0] == '-')
- {
- switch (argv[i][1])
- {
- case 'd':
- temp = argv[i][2];
- if ((temp >= '0') || (temp <= '9'))
- EAS_SetDebugLevel(temp);
- else
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Invalid debug level %d\n", temp); */ }
- break;
- case 'f':
- if ((debugFile = fopen(&argv[i][2],"w")) == NULL)
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Unable to create debug file %s\n", &argv[i][2]); */ }
- else
- EAS_SetDebugFile(debugFile, EAS_TRUE);
- break;
- case 'o':
- outputFile = &argv[i][2];
- break;
- case 'p':
- polyphony = atoi(&argv[i][2]);
- if (polyphony < 1)
- polyphony = 1;
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "Polyphony set to %d\n", polyphony); */ }
- break;
- default:
- break;
- }
- continue;
- }
- }
-
- /* assume success */
- playResult = EAS_SUCCESS;
-
- /* get the library configuration */
- pLibConfig = EAS_Config();
- if (!EASLibraryCheck(pLibConfig))
- return -1;
- if (polyphony > pLibConfig->maxVoices)
- polyphony = pLibConfig->maxVoices;
-
- /* calculate buffer size */
- bufferSize = pLibConfig->mixBufferSize * pLibConfig->numChannels * (EAS_I32)sizeof(EAS_PCM) * NUM_BUFFERS;
-
- /* allocate output buffer memory */
- buffer = malloc((EAS_U32)bufferSize);
- if (!buffer)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "Error allocating memory for audio buffer\n"); */ }
- return EAS_FAILURE;
- }
-
- /* initialize the EAS library */
- polyphony = pLibConfig->maxVoices;
- if ((result = EAS_Init(&easData)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "EAS_Init returned %ld - aborting!\n", result); */ }
- free(buffer);
- return result;
- }
-
- /*
- * Some debugging environments don't allow for passed parameters.
- * In this case, just play the default MIDI file "test.mid"
- */
- if (argc < 2)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "Playing '%s'\n", defaultTestFile); */ }
- if ((playResult = PlayFile(easData, defaultTestFile, NULL, pLibConfig, buffer, bufferSize)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Error %d playing file %s\n", playResult, defaultTestFile); */ }
- }
- }
- /* iterate through the list of files to be played */
- else
- {
- for (i = 1; i < argc; i++)
- {
- /* check for switch */
- if (argv[i][0] != '-')
- {
-
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "Playing '%s'\n", argv[i]); */ }
- if ((playResult = PlayFile(easData, argv[i], outputFile, pLibConfig, buffer, bufferSize)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Error %d playing file %s\n", playResult, argv[i]); */ }
- break;
- }
- }
- }
- }
-
- /* shutdown the EAS library */
- if ((result = EAS_Shutdown(easData)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "EAS_Shutdown returned %ld\n", result); */ }
- }
-
- /* free the output buffer */
- free(buffer);
-
- /* close the debug file */
- if (debugFile)
- fclose(debugFile);
-
- /* play errors take precedence over shutdown errors */
- if (playResult != EAS_SUCCESS)
- return playResult;
- return result;
-} /* end main */
-
-/*----------------------------------------------------------------------------
- * StrCopy()
- *----------------------------------------------------------------------------
- * Purpose:
- * Safe string copy
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static void StrCopy(char *dest, const char *src, EAS_I32 size)
-{
- int len;
-
- strncpy(dest, src, (size_t) size-1);
- len = (int) strlen(src);
- if (len < size)
- dest[len] = 0;
-} /* end StrCopy */
-
-/*----------------------------------------------------------------------------
- * ChangeFileExt()
- *----------------------------------------------------------------------------
- * Purpose:
- * Changes the file extension of a filename
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_BOOL ChangeFileExt(char *str, const char *ext, EAS_I32 size)
-{
- char *p;
-
- /* find the extension, if any */
- p = strrchr(str,'.');
- if (!p)
- {
- if ((EAS_I32)(strlen(str) + 5) > size)
- return EAS_FALSE;
- strcat(str,".");
- strcat(str,ext);
- return EAS_TRUE;
- }
-
- /* make sure there's room for the extension */
- p++;
- *p = 0;
- if ((EAS_I32)(strlen(str) + 4) > size)
- return EAS_FALSE;
- strcat(str,ext);
- return EAS_TRUE;
-} /* end ChangeFileExt */
-
-/*----------------------------------------------------------------------------
- * EASLibraryCheck()
- *----------------------------------------------------------------------------
- * Purpose:
- * Displays the library version and checks it against the header
- * file used to build this code.
- *
- * Inputs:
- * pLibConfig - library configuration retrieved from the library
- *
- * Outputs:
- * returns EAS_TRUE if matched
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_BOOL EASLibraryCheck (const S_EAS_LIB_CONFIG *pLibConfig)
-{
-
- /* display the library version */
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "EAS Library Version %d.%d.%d.%d\n",
- pLibConfig->libVersion >> 24,
- (pLibConfig->libVersion >> 16) & 0x0f,
- (pLibConfig->libVersion >> 8) & 0x0f,
- pLibConfig->libVersion & 0x0f); */ }
-
- /* display some info about the library build */
- if (pLibConfig->checkedVersion)
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tChecked library\n"); */ }
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tMaximum polyphony: %d\n", pLibConfig->maxVoices); */ }
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tNumber of channels: %d\n", pLibConfig->numChannels); */ }
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tSample rate: %d\n", pLibConfig->sampleRate); */ }
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tMix buffer size: %d\n", pLibConfig->mixBufferSize); */ }
- if (pLibConfig->filterEnabled)
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tFilter enabled\n"); */ }
-#ifndef _WIN32_WCE
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tLibrary Build Timestamp: %s", ctime((time_t*)&pLibConfig->buildTimeStamp)); */ }
-#endif
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "\tLibrary Build ID: %s\n", pLibConfig->buildGUID); */ }
-
- /* check it against the header file used to build this code */
- /*lint -e{778} constant expression used for display purposes may evaluate to zero */
- if (LIB_VERSION != pLibConfig->libVersion)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "Library version does not match header files. EAS Header Version %d.%d.%d.%d\n",
- LIB_VERSION >> 24,
- (LIB_VERSION >> 16) & 0x0f,
- (LIB_VERSION >> 8) & 0x0f,
- LIB_VERSION & 0x0f); */ }
- return EAS_FALSE;
- }
- return EAS_TRUE;
-} /* end EASLibraryCheck */
-
diff --git a/arm-wt-22k/host_src/eas_wave.c b/arm-wt-22k/host_src/eas_wave.c
deleted file mode 100644
index 4f6ffbd..0000000
--- a/arm-wt-22k/host_src/eas_wave.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_wave.c
- *
- * Contents and purpose:
- * This module contains .WAV file functions for the EAS synthesizer
- * test harness.
- *
- * Copyright Sonic Network Inc. 2005
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 658 $
- * $Date: 2007-04-24 13:35:49 -0700 (Tue, 24 Apr 2007) $
- *----------------------------------------------------------------------------
-*/
-
-/* lint complaints about most C library headers, so we use our own during lint step */
-#ifdef _lint
-#include "lint_stdlib.h"
-#else
-#include <stdio.h>
-#include <stdlib.h>
-#endif
-
-#include "eas_wave.h"
-
-/* .WAV file format tags */
-const EAS_U32 riffTag = 0x46464952;
-const EAS_U32 waveTag = 0x45564157;
-const EAS_U32 fmtTag = 0x20746d66;
-const EAS_U32 dataTag = 0x61746164;
-
-#ifdef _BIG_ENDIAN
-/*----------------------------------------------------------------------------
- * FlipDWord()
- *----------------------------------------------------------------------------
- * Purpose: Endian flip a DWORD for big-endian processors
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static void FlipDWord (EAS_U32 *pValue)
-{
- EAS_U8 *p;
- EAS_U32 temp;
-
- p = (EAS_U8*) pValue;
- temp = (((((p[3] << 8) | p[2]) << 8) | p[1]) << 8) | p[0];
- *pValue = temp;
-}
-
-/*----------------------------------------------------------------------------
- * FlipWord()
- *----------------------------------------------------------------------------
- * Purpose: Endian flip a WORD for big-endian processors
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static void FlipWord (EAS_U16 *pValue)
-{
- EAS_U8 *p;
- EAS_U16 temp;
-
- p = (EAS_U8*) pValue;
- temp = (p[1] << 8) | p[0];
- *pValue = temp;
-}
-
-/*----------------------------------------------------------------------------
- * FlipWaveHeader()
- *----------------------------------------------------------------------------
- * Purpose: Endian flip the wave header for big-endian processors
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static void FlipWaveHeader (WAVE_HEADER *p)
-{
-
- FlipDWord(&p->nRiffTag);
- FlipDWord(&p->nRiffSize);
- FlipDWord(&p->nWaveTag);
- FlipDWord(&p->nFmtTag);
- FlipDWord(&p->nFmtSize);
- FlipDWord(&p->nDataTag);
- FlipDWord(&p->nDataSize);
- FlipWord(&p->fc.wFormatTag);
- FlipWord(&p->fc.nChannels);
- FlipDWord(&p->fc.nSamplesPerSec);
- FlipDWord(&p->fc.nAvgBytesPerSec);
- FlipWord(&p->fc.nBlockAlign);
- FlipWord(&p->fc.wBitsPerSample);
-
-}
-#endif
-
-/*----------------------------------------------------------------------------
- * WaveFileCreate()
- *----------------------------------------------------------------------------
- * Purpose: Opens a wave file for writing and writes the header
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-
-WAVE_FILE *WaveFileCreate (const char *filename, EAS_I32 nChannels, EAS_I32 nSamplesPerSec, EAS_I32 wBitsPerSample)
-{
- WAVE_FILE *wFile;
-
- /* allocate memory */
- wFile = malloc(sizeof(WAVE_FILE));
- if (!wFile)
- return NULL;
- wFile->write = EAS_TRUE;
-
- /* create the file */
- wFile->file = fopen(filename,"wb");
- if (!wFile->file)
- {
- free(wFile);
- return NULL;
- }
-
- /* initialize PCM format .WAV file header */
- wFile->wh.nRiffTag = riffTag;
- wFile->wh.nRiffSize = sizeof(WAVE_HEADER) - 8;
- wFile->wh.nWaveTag = waveTag;
- wFile->wh.nFmtTag = fmtTag;
- wFile->wh.nFmtSize = sizeof(FMT_CHUNK);
-
- /* initalize 'fmt' chunk */
- wFile->wh.fc.wFormatTag = 1;
- wFile->wh.fc.nChannels = (EAS_U16) nChannels;
- wFile->wh.fc.nSamplesPerSec = (EAS_U32) nSamplesPerSec;
- wFile->wh.fc.wBitsPerSample = (EAS_U16) wBitsPerSample;
- wFile->wh.fc.nBlockAlign = (EAS_U16) (nChannels * (EAS_U16) (wBitsPerSample / 8));
- wFile->wh.fc.nAvgBytesPerSec = wFile->wh.fc.nBlockAlign * (EAS_U32) nSamplesPerSec;
-
- /* initialize 'data' chunk */
- wFile->wh.nDataTag = dataTag;
- wFile->wh.nDataSize = 0;
-
-#ifdef _BIG_ENDIAN
- FlipWaveHeader(&wFile->wh);
-#endif
-
- /* write the header */
- if (fwrite(&wFile->wh, sizeof(WAVE_HEADER), 1, wFile->file) != 1)
- {
- fclose(wFile->file);
- free(wFile);
- return NULL;
- }
-
-#ifdef _BIG_ENDIAN
- FlipWaveHeader(&wFile->wh);
-#endif
-
- /* return the file handle */
- return wFile;
-} /* end WaveFileCreate */
-
-/*----------------------------------------------------------------------------
- * WaveFileWrite()
- *----------------------------------------------------------------------------
- * Purpose: Writes data to the wave file
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_I32 WaveFileWrite (WAVE_FILE *wFile, void *buffer, EAS_I32 n)
-{
- EAS_I32 count;
-
- /* make sure we have an open file */
- if (wFile == NULL)
- {
- return 0;
- }
-
-#ifdef _BIG_ENDIAN
- {
- EAS_I32 i;
- EAS_U16 *p;
- p = buffer;
- i = n >> 1;
- while (i--)
- FlipWord(p++);
- }
-#endif
-
- /* write the data */
- count = (EAS_I32) fwrite(buffer, 1, (size_t) n, wFile->file);
-
- /* add the number of bytes written */
- wFile->wh.nRiffSize += (EAS_U32) count;
- wFile->wh.nDataSize += (EAS_U32) count;
-
- /* return the count of bytes written */
- return count;
-} /* end WriteWaveHeader */
-
-/*----------------------------------------------------------------------------
- * WaveFileClose()
- *----------------------------------------------------------------------------
- * Purpose: Opens a wave file for writing and writes the header
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-
-EAS_BOOL WaveFileClose (WAVE_FILE *wFile)
-{
- EAS_I32 count = 1;
-
- /* return to beginning of file and write the header */
- if (wFile->write)
- {
- if (fseek(wFile->file, 0L, SEEK_SET) == 0)
- {
-
-#ifdef _BIG_ENDIAN
- FlipWaveHeader(&wFile->wh);
-#endif
- count = (EAS_I32) fwrite(&wFile->wh, sizeof(WAVE_HEADER), 1, wFile->file);
-#ifdef _BIG_ENDIAN
- FlipWaveHeader(&wFile->wh);
-#endif
- }
- }
-
- /* close the file */
- if (fclose(wFile->file) != 0)
- count = 0;
-
- /* free the memory */
- free(wFile);
-
- /* return the file handle */
- return (count == 1 ? EAS_TRUE : EAS_FALSE);
-} /* end WaveFileClose */
-
-#ifdef _WAVE_FILE_READ
-#ifdef _BIG_ENDIAN
-#error "WaveFileOpen not currently supported on big-endian processors"
-#endif
-/*----------------------------------------------------------------------------
- * WaveFileOpen()
- *----------------------------------------------------------------------------
- * Purpose: Opens a wave file for reading and reads the header
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-
-WAVE_FILE *WaveFileOpen (const char *filename)
-{
- WAVE_FILE *wFile;
- struct
- {
- EAS_U32 tag;
- EAS_U32 size;
- } chunk;
- EAS_U32 tag;
- EAS_I32 startChunkPos;
- EAS_INT state;
- EAS_BOOL done;
-
- /* allocate memory */
- wFile = malloc(sizeof(WAVE_FILE));
- if (!wFile)
- return NULL;
-
- /* open the file */
- wFile->write = EAS_FALSE;
- wFile->file = fopen(filename,"rb");
- if (!wFile->file)
- {
- free(wFile);
- return NULL;
- }
-
- /* make lint happy */
- chunk.tag = chunk.size = 0;
- startChunkPos = 0;
-
- /* read the RIFF tag and file size */
- state = 0;
- done = EAS_FALSE;
- while (!done)
- {
-
- switch(state)
- {
- /* read the RIFF tag */
- case 0:
- if (fread(&chunk, sizeof(chunk), 1, wFile->file) != 1)
- done = EAS_TRUE;
- else
- {
- if (chunk.tag != riffTag)
- done = EAS_TRUE;
- else
- state++;
- }
- break;
-
- /* read the WAVE tag */
- case 1:
- if (fread(&tag, sizeof(tag), 1, wFile->file) != 1)
- done = EAS_TRUE;
- else
- {
- if (tag != waveTag)
- done = EAS_TRUE;
- else
- state++;
- }
- break;
-
- /* looking for fmt chunk */
- case 2:
- if (fread(&chunk, sizeof(chunk), 1, wFile->file) != 1)
- done = EAS_TRUE;
- else
- {
- startChunkPos = ftell(wFile->file);
-
- /* not fmt tag, skip it */
- if (chunk.tag != fmtTag)
- fseek(wFile->file, startChunkPos + (EAS_I32) chunk.size, SEEK_SET);
- else
- state++;
- }
- break;
-
- /* read fmt chunk */
- case 3:
- if (fread(&wFile->wh.fc, sizeof(FMT_CHUNK), 1, wFile->file) != 1)
- done = EAS_TRUE;
- else
- {
- fseek(wFile->file, startChunkPos + (EAS_I32) chunk.size, SEEK_SET);
- state++;
- }
- break;
-
- /* looking for data chunk */
- case 4:
- if (fread(&chunk, sizeof(chunk), 1, wFile->file) != 1)
- done = EAS_TRUE;
- else
- {
- startChunkPos = ftell(wFile->file);
-
- /* not data tag, skip it */
- if (chunk.tag != dataTag)
- fseek(wFile->file, startChunkPos + (EAS_I32) chunk.size, SEEK_SET);
- else
- {
- wFile->dataSize = chunk.size;
- state++;
- done = EAS_TRUE;
- }
- }
- break;
-
- default:
- done = EAS_TRUE;
- break;
- }
- }
-
- /* if not final state, an error occurred */
- if (state != 5)
- {
- fclose(wFile->file);
- free(wFile);
- return NULL;
- }
-
- /* return the file handle */
- return wFile;
-} /* end WaveFileOpen */
-#endif
-
-
-
diff --git a/arm-wt-22k/host_src/eas_wave.h b/arm-wt-22k/host_src/eas_wave.h
deleted file mode 100644
index 968782f..0000000
--- a/arm-wt-22k/host_src/eas_wave.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_wave.h
- *
- * Contents and purpose:
- * Writes output to a .WAV file
- *
- * DO NOT MODIFY THIS FILE!
- *
- * Copyright Sonic Network Inc. 2005
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 82 $
- * $Date: 2006-07-10 11:45:19 -0700 (Mon, 10 Jul 2006) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_types.h"
-
-/* sentinel */
-#ifndef _EAS_WAVE_H
-#define _EAS_WAVE_H
-
-/* .WAV file format chunk */
-typedef struct {
- EAS_U16 wFormatTag;
- EAS_U16 nChannels;
- EAS_U32 nSamplesPerSec;
- EAS_U32 nAvgBytesPerSec;
- EAS_U16 nBlockAlign;
- EAS_U16 wBitsPerSample;
-} FMT_CHUNK;
-
-/* .WAV file header */
-typedef struct {
- EAS_U32 nRiffTag;
- EAS_U32 nRiffSize;
- EAS_U32 nWaveTag;
- EAS_U32 nFmtTag;
- EAS_U32 nFmtSize;
- FMT_CHUNK fc;
- EAS_U32 nDataTag;
- EAS_U32 nDataSize;
-} WAVE_HEADER;
-
-typedef struct {
- WAVE_HEADER wh;
- FILE *file;
- EAS_BOOL write;
- EAS_U32 dataSize;
-} WAVE_FILE;
-
-WAVE_FILE *WaveFileCreate (const char *filename, EAS_I32 nChannels, EAS_I32 nSamplesPerSec, EAS_I32 wBitsPerSample);
-EAS_I32 WaveFileWrite (WAVE_FILE *wFile, void *buffer, EAS_I32 n);
-EAS_BOOL WaveFileClose (WAVE_FILE *wFile);
-WAVE_FILE *WaveFileOpen (const char *filename);
-
-#endif /* end #ifndef _EAS_WAVE_H */
-
-
-
diff --git a/arm-wt-22k/lib_src/eas_chorus.c b/arm-wt-22k/lib_src/eas_chorus.c
deleted file mode 100644
index 4a2c8d0..0000000
--- a/arm-wt-22k/lib_src/eas_chorus.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_chorus.c
- *
- * Contents and purpose:
- * Contains the implementation of the Chorus effect.
- *
- *
- * Copyright Sonic Network Inc. 2006
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 499 $
- * $Date: 2006-12-11 16:07:20 -0800 (Mon, 11 Dec 2006) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_data.h"
-#include "eas_effects.h"
-#include "eas_math.h"
-#include "eas_chorusdata.h"
-#include "eas_chorus.h"
-#include "eas_config.h"
-#include "eas_host.h"
-#include "eas_report.h"
-
-/* prototypes for effects interface */
-static EAS_RESULT ChorusInit (EAS_DATA_HANDLE pEASData, EAS_VOID_PTR *pInstData);
-static void ChorusProcess (EAS_VOID_PTR pInstData, EAS_PCM *pSrc, EAS_PCM *pDst, EAS_I32 numSamples);
-static EAS_RESULT ChorusShutdown (EAS_DATA_HANDLE pEASData, EAS_VOID_PTR pInstData);
-static EAS_RESULT ChorusGetParam (EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 *pValue);
-static EAS_RESULT ChorusSetParam (EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 value);
-
-/* common effects interface for configuration module */
-const S_EFFECTS_INTERFACE EAS_Chorus =
-{
- ChorusInit,
- ChorusProcess,
- ChorusShutdown,
- ChorusGetParam,
- ChorusSetParam
-};
-
-
-
-//LFO shape table used by the chorus, larger table would sound better
-//this is a sine wave, where 32767 = 1.0
-static const EAS_I16 EAS_chorusShape[CHORUS_SHAPE_SIZE] = {
- 0, 1608, 3212, 4808, 6393, 7962, 9512, 11309, 12539, 14010, 15446, 16846, 18204, 19519, 20787, 22005, 23170,
- 24279, 25329, 26319, 27245, 28105, 28898, 29621, 30273, 30852, 31356, 31785, 32137, 32412, 32609, 32728,
- 32767, 32728, 32609, 32412, 32137, 31785, 31356, 30852, 30273, 29621, 28898, 28105, 27245, 26319, 25329,
- 24279, 23170, 22005, 20787, 19519, 18204, 16846, 15446, 14010, 12539, 11039, 9512, 7962, 6393, 4808, 3212,
- 1608, 0, -1608, -3212, -4808, -6393, -7962, -9512, -11309, -12539, -14010, -15446, -16846, -18204, -19519,
- -20787, -22005, -23170, -24279, -25329, -26319, -27245, -28105, -28898, -29621, -30273, -30852, -31356, -31785,
- -32137, -32412, -32609, -32728, -32767, -32728, -32609, -32412, -32137, -31785, -31356, -30852, -30273, -29621,
- -28898, -28105, -27245, -26319, -25329, -24279, -23170, -22005, -20787, -19519, -18204, -16846, -15446, -14010,
- -12539, -11039, -9512, -7962, -6393, -4808, -3212, -1608
-};
-
-/*----------------------------------------------------------------------------
- * InitializeChorus()
- *----------------------------------------------------------------------------
- * Purpose: Initializes chorus parameters
- *
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusInit (EAS_DATA_HANDLE pEASData, EAS_VOID_PTR *pInstData)
-{
- S_CHORUS_OBJECT *pChorusData;
- S_CHORUS_PRESET *pPreset;
- EAS_I32 index;
-
- /* check Configuration Module for data allocation */
- if (pEASData->staticMemoryModel)
- pChorusData = EAS_CMEnumFXData(EAS_MODULE_CHORUS);
-
- /* allocate dynamic memory */
- else
- pChorusData = EAS_HWMalloc(pEASData->hwInstData, sizeof(S_CHORUS_OBJECT));
-
- if (pChorusData == NULL)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "Failed to allocate Chorus memory\n"); */ }
- return EAS_ERROR_MALLOC_FAILED;
- }
-
- /* clear the structure */
- EAS_HWMemSet(pChorusData, 0, sizeof(S_CHORUS_OBJECT));
-
- ChorusReadInPresets(pChorusData);
-
- /* set some default values */
- pChorusData->bypass = EAS_CHORUS_BYPASS_DEFAULT;
- pChorusData->preset = EAS_CHORUS_PRESET_DEFAULT;
- pChorusData->m_nLevel = EAS_CHORUS_LEVEL_DEFAULT;
- pChorusData->m_nRate = EAS_CHORUS_RATE_DEFAULT;
- pChorusData->m_nDepth = EAS_CHORUS_DEPTH_DEFAULT;
-
- //chorus rate and depth need some massaging from preset value (which is sample rate independent)
-
- //convert rate from steps of .05 Hz to value which can be used as phase increment,
- //with current CHORUS_SHAPE_SIZE and rate limits, this fits into 16 bits
- //want to compute ((shapeSize * 65536) * (storedRate/20))/sampleRate;
- //computing it as below allows rate steps to be evenly spaced
- //uses 32 bit divide, but only once when new value is selected
- pChorusData->m_nRate = (EAS_I16)
- ((((EAS_I32)CHORUS_SHAPE_SIZE<<16)/(20*(EAS_I32)_OUTPUT_SAMPLE_RATE)) * pChorusData->m_nRate);
-
- //convert depth from steps of .05 ms, to samples, with 16 bit whole part, discard fraction
- //want to compute ((depth * sampleRate)/20000)
- //use the following approximation since 105/32 is roughly 65536/20000
- /*lint -e{704} use shift for performance */
- pChorusData->m_nDepth = (EAS_I16)
- (((((EAS_I32)pChorusData->m_nDepth * _OUTPUT_SAMPLE_RATE)>>5) * 105) >> 16);
-
- pChorusData->m_nLevel = pChorusData->m_nLevel;
-
- //zero delay memory for chorus
- for (index = CHORUS_L_SIZE - 1; index >= 0; index--)
- {
- pChorusData->chorusDelayL[index] = 0;
- }
- for (index = CHORUS_R_SIZE - 1; index >= 0; index--)
- {
- pChorusData->chorusDelayR[index] = 0;
- }
-
- //init delay line index, these are used to implement circular delay buffer
- pChorusData->chorusIndexL = 0;
- pChorusData->chorusIndexR = 0;
-
- //init LFO phase
- //16 bit whole part, 16 bit fraction
- pChorusData->lfoLPhase = 0;
- pChorusData->lfoRPhase = (CHORUS_SHAPE_SIZE << 16) >> 2; // 1/4 of total, i.e. 90 degrees out of phase;
-
- //init chorus delay position
- //right now chorus delay is a compile-time value, as is sample rate
- pChorusData->chorusTapPosition = (EAS_I16)((CHORUS_DELAY_MS * _OUTPUT_SAMPLE_RATE)/1000);
-
- //now copy from the new preset into Chorus
- pPreset = &pChorusData->m_sPreset.m_sPreset[pChorusData->m_nNextChorus];
-
- pChorusData->m_nLevel = pPreset->m_nLevel;
- pChorusData->m_nRate = pPreset->m_nRate;
- pChorusData->m_nDepth = pPreset->m_nDepth;
-
- pChorusData->m_nRate = (EAS_I16)
- ((((EAS_I32)CHORUS_SHAPE_SIZE<<16)/(20*(EAS_I32)_OUTPUT_SAMPLE_RATE)) * pChorusData->m_nRate);
-
- /*lint -e{704} use shift for performance */
- pChorusData->m_nDepth = (EAS_I16)
- (((((EAS_I32)pChorusData->m_nDepth * _OUTPUT_SAMPLE_RATE)>>5) * 105) >> 16);
-
- *pInstData = pChorusData;
-
- return EAS_SUCCESS;
-} /* end ChorusInit */
-
-/*----------------------------------------------------------------------------
- * WeightedTap()
- *----------------------------------------------------------------------------
- * Purpose: Does fractional array look-up using linear interpolation
- *
- * first convert indexDesired to actual desired index by taking into account indexReference
- * then do linear interpolation between two actual samples using fractional part
- *
- * Inputs:
- * array: pointer to array of signed 16 bit values, typically either PCM data or control data
- * indexReference: the circular buffer relative offset
- * indexDesired: the fractional index we are looking up (16 bits index + 16 bits fraction)
- * indexLimit: the total size of the array, used to compute buffer wrap
- *
- * Outputs:
- * Value from the input array, linearly interpolated between two actual data values
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_I16 WeightedTap(const EAS_I16 *array, EAS_I16 indexReference, EAS_I32 indexDesired, EAS_I16 indexLimit)
-{
- EAS_I16 index;
- EAS_I16 fraction;
- EAS_I16 val1;
- EAS_I16 val2;
-
- //separate indexDesired into whole and fractional parts
- /*lint -e{704} use shift for performance */
- index = (EAS_I16)(indexDesired >> 16);
- /*lint -e{704} use shift for performance */
- fraction = (EAS_I16)((indexDesired>>1) & 0x07FFF); //just use 15 bits of fractional part
-
- //adjust whole part by indexReference
- index = indexReference - index;
- //make sure we stay within array bounds, this implements circular buffer
- while (index < 0)
- {
- index += indexLimit;
- }
-
- //get two adjacent values from the array
- val1 = array[index];
-
- //handle special case when index == 0, else typical case
- if (index == 0)
- {
- val2 = array[indexLimit-1]; //get last value from array
- }
- else
- {
- val2 = array[index-1]; //get previous value from array
- }
-
- //compute linear interpolation as (val1 + ((val2-val1)*fraction))
- return(val1 + (EAS_I16)MULT_EG1_EG1(val2-val1,fraction));
-}
-
-/*----------------------------------------------------------------------------
- * ChorusProcess()
- *----------------------------------------------------------------------------
- * Purpose: compute the chorus on the input buffer, and mix into output buffer
- *
- *
- * Inputs:
- * src: pointer to input buffer of PCM values to be processed
- * dst: pointer to output buffer of PCM values we are to sume the result with
- * bufSize: the number of sample frames (i.e. stereo samples) in the buffer
- *
- * Outputs:
- * None
- *
- *----------------------------------------------------------------------------
-*/
-//compute the chorus, and mix into output buffer
-static void ChorusProcess (EAS_VOID_PTR pInstData, EAS_PCM *pSrc, EAS_PCM *pDst, EAS_I32 numSamples)
-{
- EAS_I32 ix;
- EAS_I32 nChannelNumber;
- EAS_I16 lfoValueLeft;
- EAS_I16 lfoValueRight;
- EAS_I32 positionOffsetL;
- EAS_I32 positionOffsetR;
- EAS_PCM tapL;
- EAS_PCM tapR;
- EAS_I32 tempValue;
- EAS_PCM nInputSample;
- EAS_I32 nOutputSample;
- EAS_PCM *pIn;
- EAS_PCM *pOut;
-
- S_CHORUS_OBJECT *pChorusData;
-
- pChorusData = (S_CHORUS_OBJECT*) pInstData;
-
- //if the chorus is disabled or turned all the way down
- if (pChorusData->bypass == EAS_TRUE || pChorusData->m_nLevel == 0)
- {
- if (pSrc != pDst)
- EAS_HWMemCpy(pSrc, pDst, numSamples * NUM_OUTPUT_CHANNELS * (EAS_I32) sizeof(EAS_PCM));
- return;
- }
-
- if (pChorusData->m_nNextChorus != pChorusData->m_nCurrentChorus)
- {
- ChorusUpdate(pChorusData);
- }
-
- for (nChannelNumber = 0; nChannelNumber < NUM_OUTPUT_CHANNELS; nChannelNumber++)
- {
-
- pIn = pSrc + nChannelNumber;
- pOut = pDst + nChannelNumber;
-
- if(nChannelNumber==0)
- {
- for (ix = 0; ix < numSamples; ix++)
- {
- nInputSample = *pIn;
- pIn += NUM_OUTPUT_CHANNELS;
-
- //feed input into chorus delay line
- pChorusData->chorusDelayL[pChorusData->chorusIndexL] = nInputSample;
-
- //compute chorus lfo value using phase as fractional index into chorus shape table
- //resulting value is between -1.0 and 1.0, expressed as signed 16 bit number
- lfoValueLeft = WeightedTap(EAS_chorusShape, 0, pChorusData->lfoLPhase, CHORUS_SHAPE_SIZE);
-
- //scale chorus depth by lfo value to get relative fractional sample index
- //index is expressed as 32 bit number with 16 bit fractional part
- /*lint -e{703} use shift for performance */
- positionOffsetL = pChorusData->m_nDepth * (((EAS_I32)lfoValueLeft) << 1);
-
- //add fixed chorus delay to get actual fractional sample index
- positionOffsetL += ((EAS_I32)pChorusData->chorusTapPosition) << 16;
-
- //get tap value from chorus delay using fractional sample index
- tapL = WeightedTap(pChorusData->chorusDelayL, pChorusData->chorusIndexL, positionOffsetL, CHORUS_L_SIZE);
-
- //scale by chorus level, then sum with input buffer contents and saturate
- tempValue = MULT_EG1_EG1(tapL, pChorusData->m_nLevel);
- nOutputSample = SATURATE(tempValue + nInputSample);
-
- *pOut = (EAS_I16)SATURATE(nOutputSample);
- pOut += NUM_OUTPUT_CHANNELS;
-
-
- //increment chorus delay index and make it wrap as needed
- //this implements circular buffer
- if ((pChorusData->chorusIndexL+=1) >= CHORUS_L_SIZE)
- pChorusData->chorusIndexL = 0;
-
- //increment fractional lfo phase, and make it wrap as needed
- pChorusData->lfoLPhase += pChorusData->m_nRate;
- while (pChorusData->lfoLPhase >= (CHORUS_SHAPE_SIZE<<16))
- {
- pChorusData->lfoLPhase -= (CHORUS_SHAPE_SIZE<<16);
- }
- }
- }
- else
- {
- for (ix = 0; ix < numSamples; ix++)
- {
- nInputSample = *pIn;
- pIn += NUM_OUTPUT_CHANNELS;
-
- //feed input into chorus delay line
- pChorusData->chorusDelayR[pChorusData->chorusIndexR] = nInputSample;
-
- //compute chorus lfo value using phase as fractional index into chorus shape table
- //resulting value is between -1.0 and 1.0, expressed as signed 16 bit number
- lfoValueRight = WeightedTap(EAS_chorusShape, 0, pChorusData->lfoRPhase, CHORUS_SHAPE_SIZE);
-
- //scale chorus depth by lfo value to get relative fractional sample index
- //index is expressed as 32 bit number with 16 bit fractional part
- /*lint -e{703} use shift for performance */
- positionOffsetR = pChorusData->m_nDepth * (((EAS_I32)lfoValueRight) << 1);
-
- //add fixed chorus delay to get actual fractional sample index
- positionOffsetR += ((EAS_I32)pChorusData->chorusTapPosition) << 16;
-
- //get tap value from chorus delay using fractional sample index
- tapR = WeightedTap(pChorusData->chorusDelayR, pChorusData->chorusIndexR, positionOffsetR, CHORUS_R_SIZE);
-
- //scale by chorus level, then sum with output buffer contents and saturate
- tempValue = MULT_EG1_EG1(tapR, pChorusData->m_nLevel);
- nOutputSample = SATURATE(tempValue + nInputSample);
-
- *pOut = (EAS_I16)SATURATE(nOutputSample);
- pOut += NUM_OUTPUT_CHANNELS;
-
- //increment chorus delay index and make it wrap as needed
- //this implements circular buffer
- if ((pChorusData->chorusIndexR+=1) >= CHORUS_R_SIZE)
- pChorusData->chorusIndexR = 0;
-
- //increment fractional lfo phase, and make it wrap as needed
- pChorusData->lfoRPhase += pChorusData->m_nRate;
- while (pChorusData->lfoRPhase >= (CHORUS_SHAPE_SIZE<<16))
- {
- pChorusData->lfoRPhase -= (CHORUS_SHAPE_SIZE<<16);
- }
- }
- }
-
- }
-} /* end ChorusProcess */
-
-
-
-/*----------------------------------------------------------------------------
- * ChorusShutdown()
- *----------------------------------------------------------------------------
- * Purpose:
- * Initializes the Chorus effect.
- *
- * Inputs:
- * pInstData - handle to instance data
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusShutdown (EAS_DATA_HANDLE pEASData, EAS_VOID_PTR pInstData)
-{
- /* check Configuration Module for static memory allocation */
- if (!pEASData->staticMemoryModel)
- EAS_HWFree(pEASData->hwInstData, pInstData);
- return EAS_SUCCESS;
-} /* end ChorusShutdown */
-
-/*----------------------------------------------------------------------------
- * ChorusGetParam()
- *----------------------------------------------------------------------------
- * Purpose:
- * Get a Chorus parameter
- *
- * Inputs:
- * pInstData - handle to instance data
- * param - parameter index
- * *pValue - pointer to variable to hold retrieved value
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusGetParam (EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 *pValue)
-{
- S_CHORUS_OBJECT *p;
-
- p = (S_CHORUS_OBJECT*) pInstData;
-
- switch (param)
- {
- case EAS_PARAM_CHORUS_BYPASS:
- *pValue = (EAS_I32) p->bypass;
- break;
- case EAS_PARAM_CHORUS_PRESET:
- *pValue = (EAS_I8) p->m_nCurrentChorus;
- break;
- case EAS_PARAM_CHORUS_RATE:
- *pValue = (EAS_I32) p->m_nRate;
- break;
- case EAS_PARAM_CHORUS_DEPTH:
- *pValue = (EAS_I32) p->m_nDepth;
- break;
- case EAS_PARAM_CHORUS_LEVEL:
- *pValue = (EAS_I32) p->m_nLevel;
- break;
- default:
- return EAS_ERROR_INVALID_PARAMETER;
- }
- return EAS_SUCCESS;
-} /* end ChorusGetParam */
-
-
-/*----------------------------------------------------------------------------
- * ChorusSetParam()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set a Chorus parameter
- *
- * Inputs:
- * pInstData - handle to instance data
- * param - parameter index
- * *pValue - new paramter value
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusSetParam (EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 value)
-{
- S_CHORUS_OBJECT *p;
-
- p = (S_CHORUS_OBJECT*) pInstData;
-
- switch (param)
- {
- case EAS_PARAM_CHORUS_BYPASS:
- p->bypass = (EAS_BOOL) value;
- break;
- case EAS_PARAM_CHORUS_PRESET:
- if(value!=EAS_PARAM_CHORUS_PRESET1 && value!=EAS_PARAM_CHORUS_PRESET2 &&
- value!=EAS_PARAM_CHORUS_PRESET3 && value!=EAS_PARAM_CHORUS_PRESET4)
- return EAS_ERROR_INVALID_PARAMETER;
- p->m_nNextChorus = (EAS_I8)value;
- break;
- case EAS_PARAM_CHORUS_RATE:
- if(value<EAS_CHORUS_RATE_MIN || value>EAS_CHORUS_RATE_MAX)
- return EAS_ERROR_INVALID_PARAMETER;
- p->m_nRate = (EAS_I16) value;
- break;
- case EAS_PARAM_CHORUS_DEPTH:
- if(value<EAS_CHORUS_DEPTH_MIN || value>EAS_CHORUS_DEPTH_MAX)
- return EAS_ERROR_INVALID_PARAMETER;
- p->m_nDepth = (EAS_I16) value;
- break;
- case EAS_PARAM_CHORUS_LEVEL:
- if(value<EAS_CHORUS_LEVEL_MIN || value>EAS_CHORUS_LEVEL_MAX)
- return EAS_ERROR_INVALID_PARAMETER;
- p->m_nLevel = (EAS_I16) value;
- break;
-
- default:
- return EAS_ERROR_INVALID_PARAMETER;
- }
- return EAS_SUCCESS;
-} /* end ChorusSetParam */
-
-
-/*----------------------------------------------------------------------------
- * ChorusReadInPresets()
- *----------------------------------------------------------------------------
- * Purpose: sets global Chorus preset bank to defaults
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusReadInPresets(S_CHORUS_OBJECT *pChorusData)
-{
-
- int preset = 0;
- int defaultPreset = 0;
-
- //now init any remaining presets to defaults
- for (defaultPreset = preset; defaultPreset < CHORUS_MAX_TYPE; defaultPreset++)
- {
- S_CHORUS_PRESET *pPreset = &pChorusData->m_sPreset.m_sPreset[defaultPreset];
- if (defaultPreset == 0 || defaultPreset > CHORUS_MAX_TYPE-1)
- {
- pPreset->m_nDepth = 39;
- pPreset->m_nRate = 30;
- pPreset->m_nLevel = 32767;
- }
- else if (defaultPreset == 1)
- {
- pPreset->m_nDepth = 21;
- pPreset->m_nRate = 45;
- pPreset->m_nLevel = 25000;
- }
- else if (defaultPreset == 2)
- {
- pPreset->m_nDepth = 53;
- pPreset->m_nRate = 25;
- pPreset->m_nLevel = 32000;
- }
- else if (defaultPreset == 3)
- {
- pPreset->m_nDepth = 32;
- pPreset->m_nRate = 37;
- pPreset->m_nLevel = 29000;
- }
- }
-
- return EAS_SUCCESS;
-}
-
-
-/*----------------------------------------------------------------------------
- * ChorusUpdate
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the Chorus preset parameters as required
- *
- * Inputs:
- *
- * Outputs:
- *
- *
- * Side Effects:
- * - chorus paramters will be changed
- * - m_nCurrentRoom := m_nNextRoom
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusUpdate(S_CHORUS_OBJECT *pChorusData)
-{
- S_CHORUS_PRESET *pPreset = &pChorusData->m_sPreset.m_sPreset[pChorusData->m_nNextChorus];
-
- pChorusData->m_nLevel = pPreset->m_nLevel;
- pChorusData->m_nRate = pPreset->m_nRate;
- pChorusData->m_nDepth = pPreset->m_nDepth;
-
- pChorusData->m_nRate = (EAS_I16)
- ((((EAS_I32)CHORUS_SHAPE_SIZE<<16)/(20*(EAS_I32)_OUTPUT_SAMPLE_RATE)) * pChorusData->m_nRate);
-
- /*lint -e{704} use shift for performance */
- pChorusData->m_nDepth = (EAS_I16)
- (((((EAS_I32)pChorusData->m_nDepth * _OUTPUT_SAMPLE_RATE)>>5) * 105) >> 16);
-
- pChorusData->m_nCurrentChorus = pChorusData->m_nNextChorus;
-
- return EAS_SUCCESS;
-
-} /* end ChorusUpdate */
diff --git a/arm-wt-22k/lib_src/eas_chorusdata.c b/arm-wt-22k/lib_src/eas_chorusdata.c
deleted file mode 100644
index ec71ff8..0000000
--- a/arm-wt-22k/lib_src/eas_chorusdata.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_chorusdata.c
- *
- * Contents and purpose:
- * Contains the static data allocation for the Chorus effect
- *
- *
- * Copyright Sonic Network Inc. 2006
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 550 $
- * $Date: 2007-02-02 09:37:03 -0800 (Fri, 02 Feb 2007) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_chorusdata.h"
-
-S_CHORUS_OBJECT eas_ChorusData;
-
diff --git a/arm-wt-22k/lib_src/eas_chorusdata.h b/arm-wt-22k/lib_src/eas_chorusdata.h
deleted file mode 100644
index ec8daa4..0000000
--- a/arm-wt-22k/lib_src/eas_chorusdata.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_chorusdata.h
- *
- * Contents and purpose:
- * Contains the prototypes for the Chorus effect.
- *
- *
- * Copyright Sonic Network Inc. 2006
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 309 $
- * $Date: 2006-09-12 18:52:45 -0700 (Tue, 12 Sep 2006) $
- *----------------------------------------------------------------------------
-*/
-
-#ifndef _EAS_CHORUS_H
-#define _EAS_CHORUS_H
-
-#include "eas_types.h"
-#include "eas_audioconst.h"
-
-//defines for chorus
-
-#define EAS_CHORUS_BYPASS_DEFAULT 1
-#define EAS_CHORUS_PRESET_DEFAULT 0
-#define EAS_CHORUS_RATE_DEFAULT 30
-#define EAS_CHORUS_DEPTH_DEFAULT 39
-#define EAS_CHORUS_LEVEL_DEFAULT 32767
-
-#define EAS_CHORUS_LEVEL_MIN 0
-#define EAS_CHORUS_LEVEL_MAX 32767
-
-#define EAS_CHORUS_RATE_MIN 10
-#define EAS_CHORUS_RATE_MAX 50
-
-#define EAS_CHORUS_DEPTH_MIN 15
-#define EAS_CHORUS_DEPTH_MAX 60
-
-#define CHORUS_SIZE_MS 20
-#define CHORUS_L_SIZE ((CHORUS_SIZE_MS*_OUTPUT_SAMPLE_RATE)/1000)
-#define CHORUS_R_SIZE CHORUS_L_SIZE
-#define CHORUS_SHAPE_SIZE 128
-#define CHORUS_DELAY_MS 10
-
-#define CHORUS_MAX_TYPE 4 // any Chorus numbers larger than this are invalid
-
-typedef struct
-{
- EAS_I16 m_nRate;
- EAS_I16 m_nDepth;
- EAS_I16 m_nLevel;
-
-} S_CHORUS_PRESET;
-
-typedef struct
-{
- S_CHORUS_PRESET m_sPreset[CHORUS_MAX_TYPE]; //array of presets
-
-} S_CHORUS_PRESET_BANK;
-
-/* parameters for each Chorus */
-typedef struct
-{
- EAS_I32 lfoLPhase;
- EAS_I32 lfoRPhase;
- EAS_I16 chorusIndexL;
- EAS_I16 chorusIndexR;
- EAS_U16 chorusTapPosition;
-
- EAS_I16 m_nRate;
- EAS_I16 m_nDepth;
- EAS_I16 m_nLevel;
-
- //delay lines used by the chorus, longer would sound better
- EAS_PCM chorusDelayL[CHORUS_L_SIZE];
- EAS_PCM chorusDelayR[CHORUS_R_SIZE];
-
- EAS_BOOL bypass;
- EAS_I8 preset;
-
- EAS_I16 m_nCurrentChorus; // preset number for current Chorus
- EAS_I16 m_nNextChorus; // preset number for next Chorus
-
- S_CHORUS_PRESET pPreset;
-
- S_CHORUS_PRESET_BANK m_sPreset;
-
-} S_CHORUS_OBJECT;
-
-
-/*----------------------------------------------------------------------------
- * WeightedTap()
- *----------------------------------------------------------------------------
- * Purpose: Does fractional array look-up using linear interpolation
- *
- * first convert indexDesired to actual desired index by taking into account indexReference
- * then do linear interpolation between two actual samples using fractional part
- *
- * Inputs:
- * array: pointer to array of signed 16 bit values, typically either PCM data or control data
- * indexReference: the circular buffer relative offset
- * indexDesired: the fractional index we are looking up (16 bits index + 16 bits fraction)
- * indexLimit: the total size of the array, used to compute buffer wrap
- *
- * Outputs:
- * Value from the input array, linearly interpolated between two actual data values
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_I16 WeightedTap(const EAS_I16 *array, EAS_I16 indexReference, EAS_I32 indexDesired, EAS_I16 indexLimit);
-
-/*----------------------------------------------------------------------------
- * ChorusReadInPresets()
- *----------------------------------------------------------------------------
- * Purpose: sets global Chorus preset bank to defaults
- *
- * Inputs:
- *
- * Outputs:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusReadInPresets(S_CHORUS_OBJECT *pChorusData);
-
-/*----------------------------------------------------------------------------
- * ChorusUpdate
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the Chorus preset parameters as required
- *
- * Inputs:
- *
- * Outputs:
- *
- *
- * Side Effects:
- * - chorus paramters will be changed
- * - m_nCurrentChorus := m_nNextChorus
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT ChorusUpdate(S_CHORUS_OBJECT* pChorusData);
-
-#endif /* #ifndef _EAS_CHORUSDATA_H */
-
-
diff --git a/arm-wt-22k/lib_src/eas_data.h b/arm-wt-22k/lib_src/eas_data.h
index 7793fdb..8eb1002 100644
--- a/arm-wt-22k/lib_src/eas_data.h
+++ b/arm-wt-22k/lib_src/eas_data.h
@@ -114,8 +114,6 @@ typedef struct s_eas_data_tag
S_EAS_STREAM streams[MAX_NUMBER_STREAMS];
- S_PCM_STATE *pPCMStreams;
-
S_VOICE_MGR *pVoiceMgr;
#ifdef JET_INTERFACE
@@ -126,7 +124,9 @@ typedef struct s_eas_data_tag
EAS_I16 masterGain;
EAS_U8 masterVolume;
EAS_BOOL8 staticMemoryModel;
+#ifdef FILE_HEADER_SEARCH
EAS_BOOL8 searchHeaderFlag;
+#endif
} S_EAS_DATA;
#endif
diff --git a/arm-wt-22k/lib_src/eas_ima_tables.c b/arm-wt-22k/lib_src/eas_ima_tables.c
deleted file mode 100644
index b03b4d4..0000000
--- a/arm-wt-22k/lib_src/eas_ima_tables.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_ima_tables.c
- *
- * Contents and purpose:
- * Contains the constant tables for IMA encode/decode
- *
- * Copyright (c) 2005 Sonic Network Inc.
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 760 $
- * $Date: 2007-07-17 23:09:36 -0700 (Tue, 17 Jul 2007) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_types.h"
-
-/*----------------------------------------------------------------------------
- * ADPCM decode tables
- *----------------------------------------------------------------------------
-*/
-const EAS_I16 imaIndexTable[16] =
-{
- -1, -1, -1, -1, 2, 4, 6, 8,
- -1, -1, -1, -1, 2, 4, 6, 8
-};
-
-const EAS_I16 imaStepSizeTable[89] =
-{
- 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
- 19, 21, 23, 25, 28, 31, 34, 37, 41, 45,
- 50, 55, 60, 66, 73, 80, 88, 97, 107, 118,
- 130, 143, 157, 173, 190, 209, 230, 253, 279, 307,
- 337, 371, 408, 449, 494, 544, 598, 658, 724, 796,
- 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066,
- 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358,
- 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899,
- 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767
-};
-
diff --git a/arm-wt-22k/lib_src/eas_imaadpcm.c b/arm-wt-22k/lib_src/eas_imaadpcm.c
deleted file mode 100644
index 41280b5..0000000
--- a/arm-wt-22k/lib_src/eas_imaadpcm.c
+++ /dev/null
@@ -1,368 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_imaadpcm.c
- *
- * Contents and purpose:
- * Implements the IMA ADPCM decoder
- *
- * Copyright Sonic Network Inc. 2005
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 847 $
- * $Date: 2007-08-27 21:30:08 -0700 (Mon, 27 Aug 2007) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_data.h"
-#include "eas_host.h"
-#include "eas_pcm.h"
-#include "eas_math.h"
-#include "eas_report.h"
-
-// #define _DEBUG_IMA_ADPCM_LOCATE
-
-/*----------------------------------------------------------------------------
- * externs
- *----------------------------------------------------------------------------
-*/
-extern const EAS_I16 imaIndexTable[];
-extern const EAS_I16 imaStepSizeTable[];
-
-/*----------------------------------------------------------------------------
- * prototypes
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT IMADecoderInit (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState);
-static EAS_RESULT IMADecoderSample (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState);
-static void IMADecoderADPCM (S_DECODER_STATE *pState, EAS_U8 nibble);
-static EAS_RESULT IMADecoderLocate (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState, EAS_I32 time);
-
-/*----------------------------------------------------------------------------
- * IMA ADPCM Decoder interface
- *----------------------------------------------------------------------------
-*/
-const S_DECODER_INTERFACE IMADecoder =
-{
- IMADecoderInit,
- IMADecoderSample,
- IMADecoderLocate
-};
-
-/*----------------------------------------------------------------------------
- * IMADecoderInit()
- *----------------------------------------------------------------------------
- * Purpose:
- * Initializes the IMA ADPCM decoder
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) common decoder interface - pEASData not used */
-static EAS_RESULT IMADecoderInit (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState)
-{
- pState->decoderL.step = 0;
- pState->decoderR.step = 0;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * IMADecoderSample()
- *----------------------------------------------------------------------------
- * Purpose:
- * Decodes an IMA ADPCM sample
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT IMADecoderSample (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState)
-{
- EAS_RESULT result;
- EAS_I16 sTemp;
-
- /* if high nibble, decode */
- if (pState->hiNibble)
- {
- IMADecoderADPCM(&pState->decoderL, (EAS_U8)(pState->srcByte >> 4));
- pState->hiNibble = EAS_FALSE;
- }
-
- /* low nibble, need to fetch another byte */
- else
- {
- /* check for loop */
- if ((pState->bytesLeft == 0) && (pState->loopSamples != 0))
- {
- /* seek to start of loop */
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, pState->fileHandle, (EAS_I32) (pState->startPos + pState->loopLocation))) != EAS_SUCCESS)
- return result;
- pState->bytesLeft = pState->byteCount = (EAS_I32) pState->bytesLeftLoop;
- pState->blockCount = 0;
- pState->flags &= ~PCM_FLAGS_EMPTY;
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "IMADecoderSample: Rewind file to %d, bytesLeft = %d\n", pState->startPos, pState->bytesLeft); */ }
- }
-
- /* if start of block, fetch new predictor and step index */
- if ((pState->blockSize != 0) && (pState->blockCount == 0) && (pState->bytesLeft != 0))
- {
-
- /* get predicted sample for left channel */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
- return result;
-#ifdef _DEBUG_IMA_ADPCM
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Predictor: Was %d, now %d\n", pState->decoderL.acc, sTemp); */ }
-#endif
- pState->decoderL.acc = pState->decoderL.x1 = sTemp;
-
- /* get step index for left channel - upper 8 bits are reserved */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
- return result;
-#ifdef _DEBUG_IMA_ADPCM
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Step: Was %d, now %d\n", pState->decoderL.step, sTemp); */ }
-#endif
- pState->decoderL.step = sTemp & 0xff;
-
- if (pState->flags & PCM_FLAGS_STEREO)
- {
- /* get predicted sample for right channel */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
- return result;
- pState->decoderR.acc = pState->decoderR.x1 = sTemp;
-
- /* get step index for right channel - upper 8 bits are reserved */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, pState->fileHandle, &sTemp, EAS_FALSE)) != EAS_SUCCESS)
- return result;
-#ifdef _DEBUG_IMA_ADPCM
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "Step: Was %d, now %d\n", pState->decoderR.step, sTemp); */ }
-#endif
- pState->decoderR.step = sTemp & 0xff;
-
- pState->blockCount = pState->blockSize - 8;
- pState->bytesLeft -= 8;
- }
- else
- {
- pState->blockCount = pState->blockSize - 4;
- pState->bytesLeft -= 4;
- }
- }
- else
- {
-
- /* get another ADPCM data pair */
- if (pState->bytesLeft)
- {
-
- if ((result = EAS_HWGetByte(pEASData->hwInstData, pState->fileHandle, &pState->srcByte)) != EAS_SUCCESS)
- return result;
-
- /* decode the low nibble */
- pState->bytesLeft--;
- pState->blockCount--;
- IMADecoderADPCM(&pState->decoderL, (EAS_U8)(pState->srcByte & 0x0f));
-
- if (pState->flags & PCM_FLAGS_STEREO)
- IMADecoderADPCM(&pState->decoderR, (EAS_U8)(pState->srcByte >> 4));
- else
- pState->hiNibble = EAS_TRUE;
- }
-
- /* out of ADPCM data, generate enough samples to fill buffer */
- else
- {
- pState->decoderL.x1 = pState->decoderL.x0;
- pState->decoderR.x1 = pState->decoderR.x0;
- }
- }
- }
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * IMADecoderADPCM()
- *----------------------------------------------------------------------------
- * Purpose:
- * Decodes an IMA ADPCM sample
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static void IMADecoderADPCM (S_DECODER_STATE *pState, EAS_U8 nibble)
-{
- EAS_INT delta;
- EAS_INT stepSize;
-
- /* get stepsize from table */
- stepSize = imaStepSizeTable[pState->step];
-
- /* delta = (abs(delta) + 0.5) * step / 4 */
- delta = 0;
- if (nibble & 4)
- delta += stepSize;
-
- if (nibble & 2)
- /*lint -e{702} use shift for performance */
- delta += stepSize >> 1;
-
- if (nibble & 1)
- /*lint -e{702} use shift for performance */
- delta += stepSize >> 2;
-
- /*lint -e{702} use shift for performance */
- delta += stepSize >> 3;
-
- /* integrate the delta */
- if (nibble & 8)
- pState->acc -= delta;
- else
- pState->acc += delta;
-
- /* saturate */
- if (pState->acc > 32767)
- pState->acc = 32767;
- if (pState->acc < -32768)
- pState->acc = -32768;
- pState->x1 = (EAS_PCM) pState->acc;
-
- /* compute new step size */
- pState->step += imaIndexTable[nibble];
- if (pState->step < 0)
- pState->step = 0;
- if (pState->step > 88)
- pState->step = 88;
-
-#ifdef _DEBUG_IMA_ADPCM
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "In=%u, Pred=%d, Step=%d\n", nibble, pState->acc, imaStepSizeTable[pState->step]); */ }
-#endif
-}
-
-/*----------------------------------------------------------------------------
- * IMADecoderLocate()
- *----------------------------------------------------------------------------
- * Locate in an IMA ADPCM stream
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT IMADecoderLocate (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState, EAS_I32 time)
-{
- EAS_RESULT result;
- EAS_I32 temp;
- EAS_I32 samplesPerBlock;
- EAS_I32 secs, msecs;
-
- /* no need to calculate if time is zero */
- if (time == 0)
- temp = 0;
-
- /* not zero */
- else
- {
-
- /* can't seek if not a blocked file */
- if (pState->blockSize == 0)
- return EAS_ERROR_FEATURE_NOT_AVAILABLE;
-
- /* calculate number of samples per block */
- if (pState->flags & PCM_FLAGS_STEREO)
- samplesPerBlock = pState->blockSize - 7;
- else
- samplesPerBlock = (pState->blockSize << 1) - 7;
-
- /* break down into secs and msecs */
- secs = time / 1000;
- msecs = time - (secs * 1000);
-
- /* calculate sample number fraction from msecs */
- temp = (msecs * pState->sampleRate);
- temp = (temp >> 10) + ((temp * 49) >> 21);
-
- /* add integer sample count */
- temp += secs * pState->sampleRate;
-
-#ifdef _DEBUG_IMA_ADPCM_LOCATE
- EAS_ReportEx(_EAS_SEVERITY_NOFILTER, 0x2380b977, 0x00000006 , time, temp);
-#endif
-
- /* for looped samples, calculate position in the loop */
- if ((temp > pState->byteCount) && (pState->loopSamples != 0))
- {
- EAS_I32 numBlocks;
- EAS_I32 samplesPerLoop;
- EAS_I32 samplesInLastBlock;
-
- numBlocks = (EAS_I32) (pState->loopStart / pState->blockSize);
- samplesInLastBlock = (EAS_I32) pState->loopStart - (numBlocks * pState->blockSize);
- if (samplesInLastBlock)
- {
- if (pState->flags & PCM_FLAGS_STEREO)
- samplesInLastBlock = samplesInLastBlock - 7;
- else
- /*lint -e{703} use shift for performance */
- samplesInLastBlock = (samplesInLastBlock << 1) - 7;
- }
- samplesPerLoop = numBlocks * samplesPerBlock + samplesInLastBlock;
- temp = temp % samplesPerLoop;
-#ifdef _DEBUG_IMA_ADPCM_LOCATE
- EAS_ReportEx(_EAS_SEVERITY_NOFILTER, 0x2380b977, 0x00000007 , numBlocks, samplesPerLoop, samplesInLastBlock, temp);
-#endif
- }
-
- /* find start of block for requested sample */
- temp = (temp / samplesPerBlock) * pState->blockSize;
-#ifdef _DEBUG_IMA_ADPCM_LOCATE
- EAS_ReportEx(_EAS_SEVERITY_NOFILTER, 0x2380b977, 0x00000008 , temp);
-#endif
-
- }
-
- /* seek to new location */
- if ((result = EAS_PESeek(pEASData, pState, &temp)) != EAS_SUCCESS)
- return result;
-
-#ifdef _DEBUG_IMA_ADPCM_LOCATE
- EAS_ReportEx(_EAS_SEVERITY_NOFILTER, 0x2380b977, 0x00000009 , pState->bytesLeft);
-#endif
-
- /* reset state */
- pState->blockCount = 0;
- pState->hiNibble = EAS_FALSE;
- if ((pState->state != EAS_STATE_PAUSING) && (pState->state != EAS_STATE_PAUSED))
- pState->state = EAS_STATE_READY;
-
- return EAS_SUCCESS;
-}
-
diff --git a/arm-wt-22k/lib_src/eas_pcm.c b/arm-wt-22k/lib_src/eas_pcm.c
index ff3f6f9..66ba967 100644
--- a/arm-wt-22k/lib_src/eas_pcm.c
+++ b/arm-wt-22k/lib_src/eas_pcm.c
@@ -39,80 +39,6 @@
#define PCM_MIXER_GUARD_BITS (NUM_MIXER_GUARD_BITS + 1)
/*----------------------------------------------------------------------------
- * Decoder interfaces
- *----------------------------------------------------------------------------
-*/
-
-static EAS_RESULT LinearPCMDecode (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState);
-static EAS_RESULT LinearPCMLocate (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState, EAS_I32 time);
-
-static const S_DECODER_INTERFACE PCMDecoder =
-{
- NULL,
- LinearPCMDecode,
- LinearPCMLocate,
-};
-
-/* SMAF ADPCM decoder */
-#ifdef _SMAF_PARSER
-extern S_DECODER_INTERFACE SmafDecoder;
-#define SMAF_DECODER &SmafDecoder
-extern S_DECODER_INTERFACE Smaf7BitDecoder;
-#define SMAF_7BIT_DECODER &Smaf7BitDecoder
-#else
-#define SMAF_DECODER NULL
-#define SMAF_7BIT_DECODER NULL
-#endif
-
-/* IMA ADPCM decoder */
-#ifdef _IMA_DECODER
-extern S_DECODER_INTERFACE IMADecoder;
-#define IMA_DECODER &IMADecoder
-#else
-#define IMA_DECODER NULL
-#endif
-
-static const S_DECODER_INTERFACE * const decoders[] =
-{
- &PCMDecoder,
- SMAF_DECODER,
- IMA_DECODER,
- SMAF_7BIT_DECODER
-};
-
-/*----------------------------------------------------------------------------
- * Sample rate conversion
- *----------------------------------------------------------------------------
-*/
-
-#define SRC_RATE_MULTIPLER (0x40000000 / _OUTPUT_SAMPLE_RATE)
-
-#ifdef _LOOKUP_SAMPLE_RATE
-static const EAS_U32 srcConvRate[][2] =
-{
- 4000L, (4000L << 15) / _OUTPUT_SAMPLE_RATE,
- 8000L, (8000L << 15) / _OUTPUT_SAMPLE_RATE,
- 11025L, (11025L << 15) / _OUTPUT_SAMPLE_RATE,
- 12000L, (12000L << 15) / _OUTPUT_SAMPLE_RATE,
- 16000L, (16000L << 15) / _OUTPUT_SAMPLE_RATE,
- 22050L, (22050L << 15) / _OUTPUT_SAMPLE_RATE,
- 24000L, (24000L << 15) / _OUTPUT_SAMPLE_RATE,
- 32000L, (32000L << 15) / _OUTPUT_SAMPLE_RATE
-};
-static EAS_U32 CalcBaseFreq (EAS_U32 sampleRate);
-#define SRC_CONV_RATE_ENTRIES (sizeof(srcConvRate)/sizeof(EAS_U32)/2)
-#endif
-
-
-/* interface prototypes */
-static EAS_RESULT RenderPCMStream (S_EAS_DATA *pEASData, S_PCM_STATE *pState, EAS_I32 numSamples);
-
-
-/* local prototypes */
-static S_PCM_STATE *FindSlot (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, EAS_PCM_CALLBACK pCallbackFunc, EAS_VOID_PTR cbInstData);
-static EAS_RESULT InitPCMStream (S_EAS_DATA *pEASData, S_PCM_STATE *pState);
-
-/*----------------------------------------------------------------------------
* EAS_PEInit()
*----------------------------------------------------------------------------
* Purpose:
@@ -130,29 +56,6 @@ static EAS_RESULT InitPCMStream (S_EAS_DATA *pEASData, S_PCM_STATE *pState);
*/
EAS_RESULT EAS_PEInit (S_EAS_DATA *pEASData)
{
- S_PCM_STATE *pState;
- EAS_INT i;
-
- /* check for static memory allocation */
- if (pEASData->staticMemoryModel)
- pEASData->pPCMStreams = EAS_CMEnumData(EAS_CM_PCM_DATA);
- /* allocate dynamic memory */
- else
- pEASData->pPCMStreams = EAS_HWMalloc(pEASData->hwInstData, sizeof(S_PCM_STATE) * MAX_PCM_STREAMS);
-
- if (!pEASData->pPCMStreams)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "Failed to allocate memory for PCM streams\n"); */ }
- return EAS_ERROR_MALLOC_FAILED;
- }
-
- //zero the memory to insure complete initialization
- EAS_HWMemSet((void *)(pEASData->pPCMStreams),0, sizeof(S_PCM_STATE) * MAX_PCM_STREAMS);
-
- /* initialize the state data */
- for (i = 0, pState = pEASData->pPCMStreams; i < MAX_PCM_STREAMS; i++, pState++)
- pState->fileHandle = NULL;
-
return EAS_SUCCESS;
}
@@ -174,1309 +77,5 @@ EAS_RESULT EAS_PEInit (S_EAS_DATA *pEASData)
*/
EAS_RESULT EAS_PEShutdown (S_EAS_DATA *pEASData)
{
-
- /* free any dynamic memory */
- if (!pEASData->staticMemoryModel)
- {
- if (pEASData->pPCMStreams)
- {
- EAS_HWFree(pEASData->hwInstData, pEASData->pPCMStreams);
- pEASData->pPCMStreams = NULL;
- }
- }
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PERender()
- *----------------------------------------------------------------------------
- * Purpose:
- * Render a buffer of PCM audio
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PERender (S_EAS_DATA* pEASData, EAS_I32 numSamples)
-{
- S_PCM_STATE *pState;
- EAS_RESULT result;
- EAS_INT i;
-
- /* render all the active streams */
- for (i = 0, pState = pEASData->pPCMStreams; i < MAX_PCM_STREAMS; i++, pState++)
- {
- if ((pState->fileHandle) && (pState->state != EAS_STATE_STOPPED) && (pState->state != EAS_STATE_PAUSED))
- if ((result = RenderPCMStream(pEASData, pState, numSamples)) != EAS_SUCCESS)
- return result;
- }
- return EAS_SUCCESS;
-}
-
-
-/*----------------------------------------------------------------------------
- * EAS_PEState()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current state of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- * pState - pointer to variable to store state
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- * Notes:
- * This interface is also exposed in the internal library for use by the other modules.
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEState (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pInstData, EAS_STATE *pState)
-{
- /* return current state */
- *pState = pInstData->state;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEClose()
- *----------------------------------------------------------------------------
- * Purpose:
- * Close the file and clean up
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEClose (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState)
-{
- EAS_RESULT result;
-
- if ((result = EAS_HWCloseFile(pEASData->hwInstData, pState->fileHandle)) != EAS_SUCCESS)
- return result;
-
- pState->fileHandle = NULL;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * PCM_Reset()
- *----------------------------------------------------------------------------
- * Purpose:
- * Reset the sequencer. Used for locating backwards in the file.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEReset (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState)
-{
- EAS_RESULT result;
-
- /* reset file position to first byte of data in the stream */
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, pState->fileHandle, pState->startPos)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Error %d seeking to start of PCM file\n", result); */ }
- return result;
- }
-
- /* re-initialize stream */
- return InitPCMStream(pEASData, pState);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEOpenStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Starts up a PCM playback
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEOpenStream (S_EAS_DATA *pEASData, S_PCM_OPEN_PARAMS *pParams, EAS_PCM_HANDLE *pHandle)
-{
- EAS_RESULT result;
- S_PCM_STATE *pState;
- EAS_I32 filePos;
-
- /* make sure we support this decoder */
- if (pParams->decoder >= NUM_DECODER_MODULES)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Decoder selector out of range\n"); */ }
- return EAS_ERROR_PARAMETER_RANGE;
- }
- if (decoders[pParams->decoder] == NULL)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Decoder module not available\n"); */ }
- return EAS_ERROR_FEATURE_NOT_AVAILABLE;
- }
-
- /* find a slot for the new stream */
- if ((pState = FindSlot(pEASData, pParams->fileHandle, pParams->pCallbackFunc, pParams->cbInstData)) == NULL)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "Unable to open ADPCM stream, too many streams open\n"); */ }
- return EAS_ERROR_MAX_PCM_STREAMS;
- }
-
- /* get the current file position */
- if ((result = EAS_HWFilePos(pEASData->hwInstData, pState->fileHandle, &filePos)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_HWFilePos returned %ld\n",result); */ }
- pState->fileHandle = NULL;
- return result;
- }
-
- pState->pDecoder = decoders[pParams->decoder];
- pState->startPos = filePos;
- pState->bytesLeftLoop = pState->byteCount = pParams->size;
- pState->loopStart = pParams->loopStart;
- pState->samplesTilLoop = (EAS_I32) pState->loopStart;
- pState->loopSamples = pParams->loopSamples;
- pState->samplesInLoop = 0;
- pState->blockSize = (EAS_U16) pParams->blockSize;
- pState->flags = pParams->flags;
- pState->envData = pParams->envData;
- pState->volume = pParams->volume;
- pState->sampleRate = (EAS_U16) pParams->sampleRate;
-
- /* set the base frequency */
- pState->basefreq = (SRC_RATE_MULTIPLER * (EAS_U32) pParams->sampleRate) >> 15;
-
- /* calculate shift for frequencies > 1.0 */
- pState->rateShift = 0;
- while (pState->basefreq > 32767)
- {
- pState->basefreq = pState->basefreq >> 1;
- pState->rateShift++;
- }
-
- /* initialize */
- if ((result = InitPCMStream(pEASData, pState)) != EAS_SUCCESS)
- return result;
-
- *pHandle = pState;
-
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "EAS_PEOpenStream: StartPos=%d, byteCount = %d, loopSamples=%d\n",
- pState->startPos, pState->byteCount, pState->loopSamples); */ }
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEContinueStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Continues a PCM stream
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -e{715} reserved for future use */
-EAS_RESULT EAS_PEContinueStream (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState, EAS_I32 size)
-{
-
- /* add new samples to count */
- pState->bytesLeft += size;
- if (pState->bytesLeft > 0)
- pState->flags &= ~PCM_FLAGS_EMPTY;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEGetFileHandle()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the file handle of a stream
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEGetFileHandle (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState, EAS_FILE_HANDLE *pFileHandle)
-{
- *pFileHandle = pState->fileHandle;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEUpdateParams()
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the pitch and volume parameters for a PCM stream
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- * gainLeft - linear gain multipler in 1.15 fraction format
- * gainRight - linear gain multipler in 1.15 fraction format
- * pitch - pitch shift in cents
- * initial - initial settings, set current gain
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- * Notes
- * In mono mode, leftGain controls the output gain and rightGain is ignored
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-/*lint -esym(715, gainRight) used only in 2-channel version */
-EAS_RESULT EAS_PEUpdateParams (S_EAS_DATA* pEASData, EAS_PCM_HANDLE pState, EAS_I16 pitch, EAS_I16 gainLeft, EAS_I16 gainRight)
-{
-
- pState->gainLeft = gainLeft;
-
-#if (NUM_OUTPUT_CHANNELS == 2)
- pState->gainRight = gainRight;
-#endif
-
- pState->pitch = pitch;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PELocate()
- *----------------------------------------------------------------------------
- * Purpose:
- * This function seeks to the requested place in the file. Accuracy
- * is dependent on the sample rate and block size.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * pState - stream handle
- * time - media time in milliseconds
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PELocate (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState, EAS_I32 time)
-{
- if (pState->pDecoder->pfLocate == NULL)
- return EAS_ERROR_FEATURE_NOT_AVAILABLE;
-
- return pState->pDecoder->pfLocate(pEASData, pState, time);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEUpdateVolume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the volume parameters for a PCM stream
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- * gainLeft - linear gain multipler in 1.15 fraction format
- * gainRight - linear gain multipler in 1.15 fraction format
- * initial - initial settings, set current gain
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- * Notes
- * In mono mode, leftGain controls the output gain and rightGain is ignored
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEUpdateVolume (S_EAS_DATA* pEASData, EAS_PCM_HANDLE pState, EAS_I16 volume)
-{
- pState->volume = volume;
return EAS_SUCCESS;
}
-
-/*----------------------------------------------------------------------------
- * EAS_PEUpdatePitch()
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the pitch parameter for a PCM stream
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * pState - pointer to S_PCM_STATE for this stream
- * pitch - new pitch value in pitch cents
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEUpdatePitch (S_EAS_DATA* pEASData, EAS_PCM_HANDLE pState, EAS_I16 pitch)
-{
- pState->pitch = pitch;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEPause()
- *----------------------------------------------------------------------------
- * Purpose:
- * Mute and stop rendering a PCM stream. Sets the gain target to zero and stops the playback
- * at the end of the next audio frame.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEPause (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState)
-{
- /* set state to stopping */
- pState->state = EAS_STATE_PAUSING;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PEResume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Resume rendering a PCM stream. Sets the gain target back to its
- * previous setting and restarts playback at the end of the next audio
- * frame.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEResume (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState)
-{
- /* set state to stopping */
- pState->state = EAS_STATE_PLAY;
- return EAS_SUCCESS;
-}
-
-EAS_U32 getDecayScale(EAS_U32 index)
-{
- EAS_U32 utemp;
-
- //envelope decay segment
- switch (index)
- {
- case 0: //no decay
- utemp = 512;//32768;
- break;
- case 1: //.0156 dB per update
- utemp = 511;//32709;
- break;
- case 2: //.03125
- utemp = 510;//32649;
- break;
- case 3: //.0625
- utemp = 508;//32532;
- break;
- case 4: //.125
- utemp = 505;//32298;
- break;
- case 5: //.25
- utemp = 497;//31835;
- break;
- case 6: //.5
- utemp = 483;//30929;
- break;
- case 7: //1.0
- utemp = 456;//29193;
- break;
- case 8: //2.0
- utemp = 406;//26008;
- break;
- case 9: //4.0
- utemp = 323;//20642;
- break;
- case 10: //8.0
- utemp = 203;//13004;
- break;
- case 11: //16.0
- utemp = 81;//5160;
- break;
- case 12: //32.0
- utemp = 13;//813;
- break;
- case 13: //64.0
- utemp = 0;//20;
- break;
- case 14: //128.0
- utemp = 0;
- break;
- case 15: //256.0
- default:
- utemp = 0;
- break;
- }
- //printf("getdecayscale returned %d\n",utemp);
- return utemp;
-}
-
-EAS_U32 getAttackIncrement(EAS_U32 index)
-{
- EAS_U32 utemp;
-
- //envelope decay segment
- switch (index)
- {
- case 0:
- utemp = 32;
- break;
- case 1:
- utemp = 64;
- break;
- case 2:
- utemp = 128;
- break;
- case 3:
- utemp = 256;
- break;
- case 4:
- utemp = 512;
- break;
- case 5:
- utemp = 1024;
- break;
- case 6:
- utemp = 2048;
- break;
- case 7:
- utemp = 4096;
- break;
- case 8:
- utemp = 8192;
- break;
- case 9:
- utemp = 16384;
- break;
- case 10:
- utemp = 32768;
- break;
- case 11:
- utemp = 65536;
- break;
- case 12:
- utemp = 65536;
- break;
- case 13:
- utemp = 65536;
- break;
- case 14:
- utemp = 65535;
- break;
- case 15:
- default:
- utemp = 0;
- break;
- }
- //printf("getattackincrement returned %d\n",utemp);
- return utemp;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PERelease()
- *----------------------------------------------------------------------------
- * Purpose:
- * Put the PCM stream envelope into release.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PERelease (S_EAS_DATA *pEASData, EAS_PCM_HANDLE pState)
-{
- EAS_U32 utemp;
-
- //printf("handling note-off part of envelope\n");
- /*if the note is not ignore release or sustained*/
- if (((pState->envData >> 24) & 0x0F)==0)
- {
- /* set envelope state to release */
- pState->envState = PCM_ENV_RELEASE;
- utemp = ((pState->envData >> 20) & 0x0F);
- pState->envScale = getDecayScale(utemp); //getReleaseScale(utemp);
- }
- else
- {
- /*else change envelope state to sustain */
- pState->envState = PCM_ENV_SUSTAIN;
- utemp = ((pState->envData >> 28) & 0x0F);
- pState->envScale = getDecayScale(utemp); //getSustainScale(utemp);
- }
- //since we are in release, don't let anything hang around too long
- //printf("checking env scale, val = %d\n",((S_PCM_STATE*) handle)->envScale);
- if (pState->envScale > 505)
- pState->envScale = 505;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * FindSlot()
- *----------------------------------------------------------------------------
- * Purpose:
- * Locates an empty stream slot and assigns the file handle
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * fileHandle - file handle
- * pCallbackFunc - function to be called back upon EAS_STATE_STOPPED
- *
- * Outputs:
- * returns handle to slot or NULL if all slots are used
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static S_PCM_STATE *FindSlot (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, EAS_PCM_CALLBACK pCallbackFunc, EAS_VOID_PTR cbInstData)
-{
- EAS_INT i;
- S_PCM_STATE *pState;
-
-#ifndef NO_PCM_STEAL
- S_PCM_STATE *foundState = NULL;
- EAS_INT count = 0;
- EAS_U32 startOrder = 0xFFFFFFFF;
- S_PCM_STATE *stealState = NULL;
- EAS_U32 youngest = 0;
-
- /* find an empty slot, count total in use, and find oldest in use (lowest start order) */
- for (i = 0, pState = pEASData->pPCMStreams; i < MAX_PCM_STREAMS; i++, pState++)
- {
- /* if this one is available */
- if (pState->fileHandle == NULL)
- {
- foundState = pState;
- }
- /* else this one is in use, so see if it is the oldest, and count total in use */
- /* also find youngest */
- else
- {
- /*one more voice in use*/
- count++;
- /* is this the oldest? (lowest start order) */
- if ((pState->state != EAS_STATE_STOPPING) && (pState->startOrder < startOrder))
- {
- /* remember this one */
- stealState = pState;
- /* remember the oldest so far */
- startOrder = pState->startOrder;
- }
- /* is this the youngest? (highest start order) */
- if (pState->startOrder >= youngest)
- {
- youngest = pState->startOrder;
- }
- }
- }
-
- /* if there are too many voices active, stop the oldest one */
- if (count > PCM_STREAM_THRESHOLD)
- {
- //printf("stealing!!!\n");
- /* make sure we got one, although we should always have one at this point */
- if (stealState != NULL)
- {
- //flag this as stopping, so it will get shut off
- stealState->state = EAS_STATE_STOPPING;
- }
- }
-
- /* if there are no available open streams (we won't likely see this, due to stealing) */
- if (foundState == NULL)
- return NULL;
-
- /* save info */
- foundState->startOrder = youngest + 1;
- foundState->fileHandle = fileHandle;
- foundState->pCallback = pCallbackFunc;
- foundState->cbInstData = cbInstData;
- return foundState;
-#else
- /* find an empty slot*/
- for (i = 0; i < MAX_PCM_STREAMS; i++)
- {
- pState = &pEASData->pPCMStreams[i];
- if (pState->fileHandle != NULL)
- continue;
-
- pState->fileHandle = fileHandle;
- pState->pCallback = pCallbackFunc;
- pState->cbInstData = cbInstData;
- return pState;
- }
- return NULL;
-#endif
-}
-
-#ifdef _LOOKUP_SAMPLE_RATE
-/*----------------------------------------------------------------------------
- * CalcBaseFreq()
- *----------------------------------------------------------------------------
- * Purpose:
- * Calculates the fractional phase increment for the sample rate converter
- *
- * Inputs:
- * sampleRate - sample rate in samples/sec
- *
- * Outputs:
- * Returns fractional sample rate with a 15-bit fraction
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_U32 CalcBaseFreq (EAS_U32 sampleRate)
-{
- EAS_INT i;
-
- /* look up the conversion rate */
- for (i = 0; i < (EAS_INT)(SRC_CONV_RATE_ENTRIES); i ++)
- {
- if (srcConvRate[i][0] == sampleRate)
- return srcConvRate[i][1];
- }
-
- /* if not found in table, do it the long way */
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "Sample rate %u not in table, calculating by division\n", sampleRate); */ }
-
- return (SRC_RATE_MULTIPLER * (EAS_U32) sampleRate) >> 15;
-}
-#endif
-
-/*----------------------------------------------------------------------------
- * InitPCMStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Start an ADPCM stream playback. Decodes the header, preps the engine.
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT InitPCMStream (S_EAS_DATA *pEASData, S_PCM_STATE *pState)
-{
-
- /* initialize the data structure */
- pState->bytesLeft = pState->byteCount;
- pState->phase = 0;
- pState->srcByte = 0;
- pState->decoderL.acc = 0;
- pState->decoderL.output = 0;
- pState->decoderL.x0 = pState->decoderL.x1 = 0;
- pState->decoderL.step = 0;
- pState->decoderR.acc = 0;
- pState->decoderR.output = 0;
- pState->decoderR.x0 = pState->decoderR.x1 = 0;
- pState->decoderR.step = 0;
- pState->hiNibble = EAS_FALSE;
- pState->pitch = 0;
- pState->blockCount = 0;
- pState->gainLeft = PCM_DEFAULT_GAIN_SETTING;
-// pState->currentGainLeft = PCM_DEFAULT_GAIN_SETTING;
- pState->envValue = 0;
- pState->envState = PCM_ENV_START;
-
-#if (NUM_OUTPUT_CHANNELS == 2)
- pState->gainRight = PCM_DEFAULT_GAIN_SETTING;
-// pState->currentGainRight = PCM_DEFAULT_GAIN_SETTING;
-#endif
- pState->state = EAS_STATE_READY;
-
- /* initialize the decoder */
- if (pState->pDecoder->pfInit)
- return (*pState->pDecoder->pfInit)(pEASData, pState);
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * RenderPCMStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Decodes a buffer of ADPCM data.
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT RenderPCMStream (S_EAS_DATA *pEASData, S_PCM_STATE *pState, EAS_I32 numSamples)
-{
- EAS_RESULT result;
- EAS_U32 phaseInc;
- EAS_I32 gainLeft, gainIncLeft;
- EAS_I32 *pOut;
- EAS_I32 temp;
- EAS_U32 utemp;
-
-#if (NUM_OUTPUT_CHANNELS == 2)
- EAS_I32 gainRight, gainIncRight;
-#endif
-
-#if 0
- printf("env data: AR = %d, DR = %d, SL = %d, SR = %d, RR = %d\n",
- ((pState->envData >> 12) & 0x0F),
- ((pState->envData >> 16) & 0x0F),
- ((pState->envData >> 8) & 0x0F),
- ((pState->envData >> 28) & 0x0F),
- ((pState->envData >> 20) & 0x0F));
-#endif
-
- if (pState->envState == PCM_ENV_START)
- {
- //printf("env start\n");
- utemp = ((pState->envData >> 12) & 0x0F);
- //if fastest rate, attack is already completed
- //do the same for slowest rate, since that allows zero to be passed for default envelope
- if (utemp == 0x0F || utemp == 0x00)
- {
- //start envelope at full
- pState->envValue = (32768<<7);
- //jump right into decay
- utemp = ((pState->envData >> 16) & 0x0F);
- pState->envScale = getDecayScale(utemp);
- pState->envState = PCM_ENV_DECAY;
- pState->currentGainLeft = (EAS_I16) FMUL_15x15(pState->gainLeft, pState->volume);
- pState->currentGainRight = (EAS_I16) FMUL_15x15(pState->gainRight, pState->volume);
- }
- //else attack has a ramp
- else
- {
- //start the envelope very low
- pState->envValue = (2<<7);
- pState->currentGainLeft = 0;
- pState->currentGainRight = 0;
- //get envelope attack scaling value
- pState->envScale = getAttackIncrement(utemp);
- //go to attack state
- pState->envState = PCM_ENV_ATTACK;
- }
- }
- if (pState->envState == PCM_ENV_ATTACK)
- {
- //printf("env attack, env value = %d, env scale = %d\n",pState->envValue>>7,pState->envScale);
- //update envelope value
- pState->envValue = pState->envValue + (pState->envScale << 7);
- //check envelope level and update state if needed
- if (pState->envValue >= (32768<<7))
- {
- pState->envValue = (32768<<7);
- utemp = ((pState->envData >> 16) & 0x0F);
- pState->envScale = getDecayScale(utemp);
- pState->envState = PCM_ENV_DECAY;
- }
- }
- else if (pState->envState == PCM_ENV_DECAY)
- {
- //printf("env decay, env value = %d, env scale = %d\n",pState->envValue>>7,pState->envScale);
- //update envelope value
- pState->envValue = (pState->envValue * pState->envScale)>>9;
- //check envelope level against sustain level and update state if needed
- utemp = ((pState->envData >> 8) & 0x0F);
- if (utemp == (EAS_U32)0x0F)
- utemp = (2<<7);
- else
- {
- utemp = ((32769<<7) >> (utemp>>1));
- }
- if (pState->envValue <= utemp)
- {
- utemp = ((pState->envData >> 28) & 0x0F);
- pState->envScale = getDecayScale(utemp); //getSustainScale(utemp);
- pState->envState = PCM_ENV_SUSTAIN;
- }
- }
- else if (pState->envState == PCM_ENV_SUSTAIN)
- {
- //printf("env sustain, env value = %d, env scale = %d\n",pState->envValue>>7,pState->envScale);
- //update envelope value
- pState->envValue = (pState->envValue * pState->envScale)>>9;
- //check envelope level against bottom level and update state if needed
- if (pState->envValue <= (2<<7))
- {
- //no more decay
- pState->envScale = 512;
- pState->envState = PCM_ENV_END;
- }
- }
- else if (pState->envState == PCM_ENV_RELEASE)
- {
- //printf("env release, env value = %d, env scale = %d\n",pState->envValue>>7,pState->envScale);
- //update envelope value
- pState->envValue = (pState->envValue * pState->envScale)>>9;
- //check envelope level against bottom level and update state if needed
- if (pState->envValue <= (2<<7))
- {
- //no more decay
- pState->envScale = 512;
- pState->envState = PCM_ENV_END;
- }
- }
- else if (pState->envState == PCM_ENV_END)
- {
- //printf("env end\n");
- /* set state to stopping, already ramped down */
- pState->state = EAS_STATE_STOPPING;
- }
-
- //pState->gainLeft = (EAS_U16)((pState->gainLeft * (pState->envValue>>7))>>15);
- //pState->gainRight = (EAS_U16)((pState->gainRight * (pState->envValue>>7))>>15);
-
- /* gain to 32-bits to increase resolution on anti-zipper filter */
- /*lint -e{703} use shift for performance */
- gainLeft = (EAS_I32) pState->currentGainLeft << SYNTH_UPDATE_PERIOD_IN_BITS;
-#if (NUM_OUTPUT_CHANNELS == 2)
- /*lint -e{703} use shift for performance */
- gainRight = (EAS_I32) pState->currentGainRight << SYNTH_UPDATE_PERIOD_IN_BITS;
-#endif
-
- /* calculate a new gain increment, gain target is zero if pausing */
- if ((pState->state == EAS_STATE_PAUSING) || (pState->state == EAS_STATE_PAUSED))
- {
- gainIncLeft = -pState->currentGainLeft;
-#if (NUM_OUTPUT_CHANNELS == 2)
- gainIncRight= -pState->currentGainRight;
-#endif
- }
- else
- {
- EAS_I32 gain = FMUL_15x15(pState->envValue >> 7, pState->volume);
- gainIncLeft = FMUL_15x15(pState->gainLeft, gain) - pState->currentGainLeft;
-#if (NUM_OUTPUT_CHANNELS == 2)
- gainIncRight = FMUL_15x15(pState->gainRight, gain) - pState->currentGainRight;
-#endif
- }
-
- /* calculate phase increment */
- phaseInc = pState->basefreq;
-
- /* convert pitch cents to linear multiplier */
- if (pState->pitch)
- {
- temp = EAS_Calculate2toX(pState->pitch);
- phaseInc = FMUL_15x15(phaseInc, temp);
- }
- phaseInc = phaseInc << pState->rateShift;
-
- /* pointer to mix buffer */
- pOut = pEASData->pMixBuffer;
-
- /* render a buffer of samples */
- while (numSamples--)
- {
-
- /* interpolate an output sample */
- pState->decoderL.output = pState->decoderL.x0 + FMUL_15x15((pState->decoderL.x1 - pState->decoderL.x0), pState->phase & PHASE_FRAC_MASK);
-
- /* stereo output */
-#if (NUM_OUTPUT_CHANNELS == 2)
-
- /* stereo stream? */
- if (pState->flags & PCM_FLAGS_STEREO)
- pState->decoderR.output = pState->decoderR.x0 + FMUL_15x15((pState->decoderR.x1 - pState->decoderR.x0), pState->phase & PHASE_FRAC_MASK);
-
- /* gain scale and mix */
- /*lint -e{704} use shift instead of division */
- *pOut++ += (pState->decoderL.output * (gainLeft >> SYNTH_UPDATE_PERIOD_IN_BITS)) >> PCM_MIXER_GUARD_BITS;
- gainLeft += gainIncLeft;
-
- /*lint -e{704} use shift instead of division */
- if (pState->flags & PCM_FLAGS_STEREO)
- *pOut++ += (pState->decoderR.output * (gainRight >> SYNTH_UPDATE_PERIOD_IN_BITS)) >> PCM_MIXER_GUARD_BITS;
- else
- *pOut++ += (pState->decoderL.output * (gainRight >> SYNTH_UPDATE_PERIOD_IN_BITS)) >> PCM_MIXER_GUARD_BITS;
-
- gainRight += gainIncRight;
-
- /* mono output */
-#else
- /* if stereo stream, decode right channel and mix to mono */
- if (pState->flags & PCM_FLAGS_STEREO)
- {
- pState->decoderR.output= pState->decoderR.x0 + FMUL_15x15((pState->decoderR.x1 - pState->decoderR.x0), pState->phase & PHASE_FRAC_MASK);
-
- /* for mono, sum stereo ADPCM to mono */
- /*lint -e{704} use shift instead of division */
- *pOut++ += ((pState->decoderL.output + pState->decoderR.output) * (gainLeft >> SYNTH_UPDATE_PERIOD_IN_BITS)) >> PCM_MIXER_GUARD_BITS;
- }
- else
- /*lint -e{704} use shift instead of division */
- *pOut++ += (pState->decoderL.output * (gainLeft >> SYNTH_UPDATE_PERIOD_IN_BITS)) >> PCM_MIXER_GUARD_BITS;
-
- gainLeft += gainIncLeft;
-#endif
-
- /* advance phase accumulator */
- pState->phase += phaseInc;
-
- /* if integer part of phase accumulator is non-zero, advance to next sample */
- while (pState->phase & ~PHASE_FRAC_MASK)
- {
- pState->decoderL.x0 = pState->decoderL.x1;
- pState->decoderR.x0 = pState->decoderR.x1;
-
- /* give the source a chance to continue the stream */
- if (!pState->bytesLeft && pState->pCallback && ((pState->flags & PCM_FLAGS_EMPTY) == 0))
- {
- pState->flags |= PCM_FLAGS_EMPTY;
- (*pState->pCallback)(pEASData, pState->cbInstData, pState, EAS_STATE_EMPTY);
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "RenderPCMStream: After empty callback, bytesLeft = %d\n", pState->bytesLeft); */ }
- }
-
- /* decode the next sample */
- if ((result = (*pState->pDecoder->pfDecodeSample)(pEASData, pState)) != EAS_SUCCESS)
- return result;
-
- /* adjust phase by one sample */
- pState->phase -= (1L << NUM_PHASE_FRAC_BITS);
- }
-
- }
-
- /* save new gain */
- /*lint -e{704} use shift instead of division */
- pState->currentGainLeft = (EAS_I16) (gainLeft >> SYNTH_UPDATE_PERIOD_IN_BITS);
-
-#if (NUM_OUTPUT_CHANNELS == 2)
- /*lint -e{704} use shift instead of division */
- pState->currentGainRight = (EAS_I16) (gainRight >> SYNTH_UPDATE_PERIOD_IN_BITS);
-#endif
-
- /* if pausing, set new state and notify */
- if (pState->state == EAS_STATE_PAUSING)
- {
- pState->state = EAS_STATE_PAUSED;
- if (pState->pCallback)
- (*pState->pCallback)(pEASData, pState->cbInstData, pState, pState->state);
- }
-
- /* if out of data, set stopped state and notify */
- if (pState->bytesLeft == 0 || pState->state == EAS_STATE_STOPPING)
- {
- pState->state = EAS_STATE_STOPPED;
-
- /* do callback unless the file has already been closed */
- if (pState->pCallback && pState->fileHandle)
- (*pState->pCallback)(pEASData, pState->cbInstData, pState, pState->state);
- }
-
- if (pState->state == EAS_STATE_READY)
- pState->state = EAS_STATE_PLAY;
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * LinearPCMDecode()
- *----------------------------------------------------------------------------
- * Purpose:
- * Decodes a PCM sample
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT LinearPCMDecode (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState)
-{
- EAS_RESULT result;
- EAS_HW_DATA_HANDLE hwInstData;
-
- hwInstData = ((S_EAS_DATA*) pEASData)->hwInstData;
-
- /* if out of data, check for loop */
- if ((pState->bytesLeft == 0) && (pState->loopSamples != 0))
- {
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, pState->fileHandle, (EAS_I32) (pState->startPos + pState->loopLocation))) != EAS_SUCCESS)
- return result;
- pState->bytesLeft = pState->byteCount = (EAS_I32) pState->bytesLeftLoop;
- pState->flags &= ~PCM_FLAGS_EMPTY;
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "LinearPCMDecode: Rewind file to %d, bytesLeft = %d\n", pState->startPos, pState->bytesLeft); */ }
- }
-
- if (pState->bytesLeft)
- {
-
- /* check format byte for 8-bit samples */
- if (pState->flags & PCM_FLAGS_8_BIT)
- {
- /* fetch left or mono sample */
- if ((result = EAS_HWGetByte(hwInstData, pState->fileHandle, &pState->srcByte)) != EAS_SUCCESS)
- return result;
-
- /* if unsigned */
- if (pState->flags & PCM_FLAGS_UNSIGNED)
- {
- /*lint -e{734} converting unsigned 8-bit to signed 16-bit */
- pState->decoderL.x1 = (EAS_PCM)(((EAS_PCM) pState->srcByte << 8) ^ 0x8000);
- }
- else
- {
- /*lint -e{734} converting signed 8-bit to signed 16-bit */
- pState->decoderL.x1 = (EAS_PCM)((EAS_PCM) pState->srcByte << 8);
- }
- pState->bytesLeft--;
-
- /* fetch right sample */
- if(pState->flags & PCM_FLAGS_STEREO)
- {
- if ((result = EAS_HWGetByte(hwInstData, pState->fileHandle, &pState->srcByte)) != EAS_SUCCESS)
- return result;
-
- /* if unsigned */
- if (pState->flags & PCM_FLAGS_UNSIGNED)
- {
- /*lint -e{734} converting unsigned 8-bit to signed 16-bit */
- pState->decoderR.x1 = (EAS_PCM)(((EAS_PCM) pState->srcByte << 8) ^ 0x8000);
- }
- else
- {
- /*lint -e{734} converting signed 8-bit to signed 16-bit */
- pState->decoderR.x1 = (EAS_PCM)((EAS_PCM) pState->srcByte << 8);
- }
- pState->bytesLeft--;
- }
- }
-
- /* must be 16-bit samples */
- else
- {
- //unsigned 16 bit currently not supported
- if (pState->flags & PCM_FLAGS_UNSIGNED)
- {
- return EAS_ERROR_INVALID_PCM_TYPE;
- }
-
- /* fetch left or mono sample */
- if ((result = EAS_HWGetWord(hwInstData, pState->fileHandle, &pState->decoderL.x1, EAS_FALSE)) != EAS_SUCCESS)
- return result;
- pState->bytesLeft -= 2;
-
- /* fetch right sample */
- if(pState->flags & PCM_FLAGS_STEREO)
- {
- if ((result = EAS_HWGetWord(hwInstData, pState->fileHandle, &pState->decoderR.x1, EAS_FALSE)) != EAS_SUCCESS)
- return result;
- pState->bytesLeft -= 2;
- }
- }
- }
-
- /* no more data, force zero samples */
- else
- pState->decoderL.x1 = pState->decoderR.x1 = 0;
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * LinearPCMLocate()
- *----------------------------------------------------------------------------
- * Purpose:
- * Locate in a linear PCM stream
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT LinearPCMLocate (EAS_DATA_HANDLE pEASData, S_PCM_STATE *pState, EAS_I32 time)
-{
- EAS_RESULT result;
- EAS_I32 temp;
- EAS_I32 secs, msecs;
- EAS_INT shift;
-
- /* calculate size of sample frame */
- if (pState->flags & PCM_FLAGS_8_BIT)
- shift = 0;
- else
- shift = 1;
- if (pState->flags & PCM_FLAGS_STEREO)
- shift++;
-
- /* break down into secs and msecs */
- secs = time / 1000;
- msecs = time - (secs * 1000);
-
- /* calculate sample number fraction from msecs */
- temp = (msecs * pState->sampleRate);
- temp = (temp >> 10) + ((temp * 49) >> 21);
-
- /* add integer sample count */
- temp += secs * pState->sampleRate;
-
- /* calculate the position based on sample frame size */
- /*lint -e{703} use shift for performance */
- temp <<= shift;
-
- /* past end of sample? */
- if (temp > (EAS_I32) pState->loopStart)
- {
- /* if not looped, flag error */
- if (pState->loopSamples == 0)
- {
- pState->bytesLeft = 0;
- pState->flags |= PCM_FLAGS_EMPTY;
- return EAS_ERROR_LOCATE_BEYOND_END;
- }
-
- /* looped sample - calculate position in loop */
- while (temp > (EAS_I32) pState->loopStart)
- temp -= (EAS_I32) pState->loopStart;
- }
-
- /* seek to new position */
- if ((result = EAS_PESeek(pEASData, pState, &temp)) != EAS_SUCCESS)
- return result;
-
- /* reset state */
- if ((pState->state != EAS_STATE_PAUSING) && (pState->state != EAS_STATE_PAUSED))
- pState->state = EAS_STATE_READY;
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_PESeek
- *----------------------------------------------------------------------------
- * Purpose:
- * Locate to a particular byte in a PCM stream
- *----------------------------------------------------------------------------
- * This bit is tricky because the chunks may not be contiguous,
- * so we have to rely on the parser to position in the file. We
- * do this by seeking to the end of each chunk and simulating an
- * empty buffer condition until we get to where we want to go.
- *
- * A better solution would be a parser API for re-positioning,
- * but there isn't time at the moment to re-factor all the
- * parsers to support a new API.
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PESeek (S_EAS_DATA *pEASData, S_PCM_STATE *pState, EAS_I32 *pLocation)
-{
- EAS_RESULT result;
-
- /* seek to start of audio */
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, pState->fileHandle, pState->startPos)) != EAS_SUCCESS)
- {
- pState->state = EAS_STATE_ERROR;
- return result;
- }
- pState->bytesLeft = pState->bytesLeftLoop;
-
- /* skip through chunks until we find the right chunk */
- while (*pLocation > (EAS_I32) pState->bytesLeft)
- {
- /* seek to end of audio chunk */
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "EAS_PESeek: Seek to offset = %d\n", pState->bytesLeft); */ }
- if ((result = EAS_HWFileSeekOfs(pEASData->hwInstData, pState->fileHandle, pState->bytesLeft)) != EAS_SUCCESS)
- {
- pState->state = EAS_STATE_ERROR;
- return result;
- }
- *pLocation -= pState->bytesLeft;
- pState->bytesLeft = 0;
- pState->flags |= PCM_FLAGS_EMPTY;
-
- /* retrieve more data */
- if (pState->pCallback)
- (*pState->pCallback)(pEASData, pState->cbInstData, pState, EAS_STATE_EMPTY);
-
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "EAS_PESeek: bytesLeft=%d, byte location = %d\n", pState->bytesLeft, *pLocation); */ }
-
- /* no more samples */
- if (pState->bytesLeft == 0)
- return EAS_ERROR_LOCATE_BEYOND_END;
- }
-
- /* seek to new offset in current chunk */
- if (*pLocation > 0)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_DETAIL, "EAS_PESeek: Seek to offset = %d\n", *pLocation); */ }
- if ((result = EAS_HWFileSeekOfs(pEASData->hwInstData, pState->fileHandle, *pLocation)) != EAS_SUCCESS)
- {
- pState->state = EAS_STATE_ERROR;
- return result;
- }
-
- /* if not streamed, calculate number of bytes left */
- if (pState->flags & PCM_FLAGS_STREAMING)
- pState->bytesLeft = 0x7fffffff;
- else
- pState->bytesLeft -= *pLocation;
- }
- return EAS_SUCCESS;
-}
-
diff --git a/arm-wt-22k/lib_src/eas_pcm.h b/arm-wt-22k/lib_src/eas_pcm.h
index 4fc77e9..b870f54 100644
--- a/arm-wt-22k/lib_src/eas_pcm.h
+++ b/arm-wt-22k/lib_src/eas_pcm.h
@@ -37,23 +37,6 @@
typedef struct s_pcm_state_tag *EAS_PCM_HANDLE;
typedef void (*EAS_PCM_CALLBACK) (EAS_DATA_HANDLE pEASData, EAS_VOID_PTR cbInstData, EAS_PCM_HANDLE pcmHandle, EAS_STATE state);
-/* parameters for EAS_PEOpenStream */
-typedef struct s_pcm_open_params_tag
-{
- EAS_FILE_HANDLE fileHandle;
- EAS_I32 decoder;
- EAS_U32 sampleRate;
- EAS_I32 size;
- EAS_U32 loopStart;
- EAS_U32 loopSamples;
- EAS_I32 blockSize;
- EAS_U32 flags;
- EAS_U32 envData;
- EAS_I16 volume;
- EAS_PCM_CALLBACK pCallbackFunc;
- EAS_VOID_PTR cbInstData;
- } S_PCM_OPEN_PARAMS;
-
/*----------------------------------------------------------------------------
* EAS_PEInit()
*----------------------------------------------------------------------------
@@ -91,60 +74,6 @@ EAS_RESULT EAS_PEInit (EAS_DATA_HANDLE pEASData);
EAS_RESULT EAS_PEShutdown (EAS_DATA_HANDLE pEASData);
/*----------------------------------------------------------------------------
- * EAS_PEOpenStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Starts up a PCM playback
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEOpenStream (EAS_DATA_HANDLE pEASData, S_PCM_OPEN_PARAMS *pParams, EAS_PCM_HANDLE *pHandle);
-
-/*----------------------------------------------------------------------------
- * EAS_PEContinueStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Continues a PCM stream
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEContinueStream (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle, EAS_I32 size);
-
-/*----------------------------------------------------------------------------
- * EAS_PEGetFileHandle()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the file handle of a stream
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEGetFileHandle (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle, EAS_FILE_HANDLE *pFileHandle);
-
-/*----------------------------------------------------------------------------
* EAS_PERender()
*----------------------------------------------------------------------------
* Purpose:
@@ -162,198 +91,5 @@ EAS_RESULT EAS_PEGetFileHandle (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle,
*/
EAS_RESULT EAS_PERender (EAS_DATA_HANDLE pEASData, EAS_I32 numSamples);
-/*----------------------------------------------------------------------------
- * EAS_PEUpdateParams()
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the pitch and volume parameters using MIDI controls
- *
- * Inputs:
- *
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEUpdateParams (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I16 pitch, EAS_I16 gainLeft, EAS_I16 gainRight);
-
-/*----------------------------------------------------------------------------
- * EAS_PELocate()
- *----------------------------------------------------------------------------
- * Purpose:
- * This function seeks to the requested place in the file. Accuracy
- * is dependent on the sample rate and block size.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * pState - stream handle
- * time - media time in milliseconds
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PELocate (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I32 time);
-
-/*----------------------------------------------------------------------------
- * EAS_PEUpdateVolume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the volume parameters for a PCM stream
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- * gainLeft - linear gain multipler in 1.15 fraction format
- * gainRight - linear gain multipler in 1.15 fraction format
- * initial - initial settings, set current gain
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- * Notes
- * In mono mode, leftGain controls the output gain and rightGain is ignored
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEUpdateVolume (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I16 volume);
-
-/*----------------------------------------------------------------------------
- * EAS_PEUpdatePitch()
- *----------------------------------------------------------------------------
- * Purpose:
- * Update the pitch parameter for a PCM stream
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * pState - pointer to S_PCM_STATE for this stream
- * pitch - new pitch value in pitch cents
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_RESULT EAS_PEUpdatePitch (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE pState, EAS_I16 pitch);
-
-/*----------------------------------------------------------------------------
- * EAS_PEState()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current state of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- * pState - pointer to variable to store state
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- * Notes:
- * This interface is also exposed in the internal library for use by the other modules.
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEState (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle, EAS_STATE *pState);
-
-/*----------------------------------------------------------------------------
- * EAS_PEClose()
- *----------------------------------------------------------------------------
- * Purpose:
- * Close the file and clean up
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEClose (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
-
-/*----------------------------------------------------------------------------
- * EAS_PEReset()
- *----------------------------------------------------------------------------
- * Purpose:
- * Reset the sequencer. Used for locating backwards in the file.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEReset (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
-
-/*----------------------------------------------------------------------------
- * EAS_PEPause()
- *----------------------------------------------------------------------------
- * Purpose:
- * Mute and pause rendering a PCM stream. Sets the gain target to zero and stops the playback
- * at the end of the next audio frame.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEPause (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
-
-/*----------------------------------------------------------------------------
- * EAS_PEResume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Resume rendering a PCM stream. Sets the gain target back to its
- * previous setting and restarts playback at the end of the next audio
- * frame.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PEResume (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
-
-/*----------------------------------------------------------------------------
- * EAS_PERelease()
- *----------------------------------------------------------------------------
- * Purpose:
- * Put the PCM stream envelope into release.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_PCM_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_RESULT EAS_PERelease (EAS_DATA_HANDLE pEASData, EAS_PCM_HANDLE handle);
-
#endif /* end _EAS_PCM_H */
diff --git a/arm-wt-22k/lib_src/eas_public.c b/arm-wt-22k/lib_src/eas_public.c
index 19481b5..4efc9ff 100644
--- a/arm-wt-22k/lib_src/eas_public.c
+++ b/arm-wt-22k/lib_src/eas_public.c
@@ -683,95 +683,6 @@ EAS_PUBLIC EAS_RESULT EAS_OpenFile (EAS_DATA_HANDLE pEASData, EAS_FILE_LOCATOR l
return EAS_ERROR_UNRECOGNIZED_FORMAT;
}
-#ifdef MMAPI_SUPPORT
-/*----------------------------------------------------------------------------
- * EAS_MMAPIToneControl()
- *----------------------------------------------------------------------------
- * Purpose:
- * Opens a ToneControl file for audio playback.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * pHandle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_MMAPIToneControl (EAS_DATA_HANDLE pEASData, EAS_FILE_LOCATOR locator, EAS_HANDLE *ppStream)
-{
- EAS_RESULT result;
- EAS_FILE_HANDLE fileHandle;
- EAS_VOID_PTR streamHandle;
- S_FILE_PARSER_INTERFACE *pParserModule;
- EAS_INT streamNum;
-
- /* check if the tone control parser is available */
- *ppStream = NULL;
- streamHandle = NULL;
- pParserModule = EAS_CMEnumOptModules(EAS_MODULE_MMAPI_TONE_CONTROL);
- if (pParserModule == NULL)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_MMAPIToneControl: ToneControl parser not available\n"); */ }
- return EAS_ERROR_FEATURE_NOT_AVAILABLE;
- }
-
- /* open the file */
- if ((result = EAS_HWOpenFile(pEASData->hwInstData, locator, &fileHandle, EAS_FILE_READ)) != EAS_SUCCESS)
- return result;
-
- /* allocate a stream */
- if ((streamNum = EAS_AllocateStream(pEASData)) < 0)
- return EAS_ERROR_MAX_STREAMS_OPEN;
-
- /* see if ToneControl parser recognizes it */
- if ((result = (*pParserModule->pfCheckFileType)(pEASData, fileHandle, &streamHandle, 0L)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "CheckFileType returned error %ld\n", result); */ }
- return result;
- }
-
- /* parser accepted the file, return the handle */
- if (streamHandle)
- {
-
- /* save the parser pointer and file handle */
- EAS_InitStream(&pEASData->streams[streamNum], pParserModule, streamHandle);
- *ppStream = &pEASData->streams[streamNum];
- return EAS_SUCCESS;
- }
-
- /* parser did not recognize the file, close it and return an error */
- EAS_HWCloseFile(pEASData->hwInstData, fileHandle);
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_WARNING, "No parser recognized the requested file\n"); */ }
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetWaveFmtChunk
- *----------------------------------------------------------------------------
- * Helper function to retrieve WAVE file fmt chunk for MMAPI
- *----------------------------------------------------------------------------
- * pEASData - pointer to EAS persistent data object
- * pStream - stream handle
- * pFmtChunk - pointer to variable to receive current setting
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetWaveFmtChunk (S_EAS_DATA *pEASData, EAS_HANDLE pStream, EAS_VOID_PTR *ppFmtChunk)
-{
- EAS_RESULT result;
- EAS_I32 value;
-
- if ((result = EAS_GetStreamParameter(pEASData, pStream, PARSER_DATA_FORMAT, &value)) != EAS_SUCCESS)
- return result;
- *ppFmtChunk = (EAS_VOID_PTR) value;
- return EAS_SUCCESS;
-}
-#endif
-
/*----------------------------------------------------------------------------
* EAS_GetFileType
*----------------------------------------------------------------------------
@@ -1019,13 +930,6 @@ EAS_PUBLIC EAS_RESULT EAS_Render (EAS_DATA_HANDLE pEASData, EAS_PCM *pOut, EAS_I
(*pEASData->pMetricsModule->pfStartTimer)(pEASData->pMetricsData, EAS_PM_STREAM_TIME);
#endif
- /* render PCM audio */
- if ((result = EAS_PERender(pEASData, numRequested)) != EAS_SUCCESS)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_ERROR, "EAS_PERender returned error %ld\n", result); */ }
- return result;
- }
-
#ifdef _METRICS_ENABLED
/* stop the stream timer */
if (pEASData->pMetricsData)
@@ -1098,101 +1002,6 @@ EAS_PUBLIC EAS_RESULT EAS_Render (EAS_DATA_HANDLE pEASData, EAS_PCM *pOut, EAS_I
}
/*----------------------------------------------------------------------------
- * EAS_SetRepeat()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the selected stream to repeat.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * handle - handle to stream
- * repeatCount - repeat count
- *
- * Outputs:
- *
- * Side Effects:
- *
- * Notes:
- * 0 = no repeat
- * 1 = repeat once, i.e. play through twice
- * -1 = repeat forever
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_PUBLIC EAS_RESULT EAS_SetRepeat (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 repeatCount)
-{
- pStream->repeatCount = repeatCount;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetRepeat()
- *----------------------------------------------------------------------------
- * Purpose:
- * Gets the current repeat count for the selected stream.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * handle - handle to stream
- * pRrepeatCount - pointer to variable to hold repeat count
- *
- * Outputs:
- *
- * Side Effects:
- *
- * Notes:
- * 0 = no repeat
- * 1 = repeat once, i.e. play through twice
- * -1 = repeat forever
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_PUBLIC EAS_RESULT EAS_GetRepeat (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 *pRepeatCount)
-{
- *pRepeatCount = pStream->repeatCount;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetPlaybackRate()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the playback rate.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * handle - handle to stream
- * rate - rate (28-bit fractional amount)
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-EAS_PUBLIC EAS_RESULT EAS_SetPlaybackRate (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_U32 rate)
-{
-
- /* check range */
- if ((rate < (1 << 27)) || (rate > (1 << 29)))
- return EAS_ERROR_INVALID_PARAMETER;
-
- /* calculate new frame length
- *
- * NOTE: The maximum frame length we can accomodate based on a
- * maximum rate of 2.0 (2^28) is 2047 (2^13-1). To accomodate a
- * longer frame length or a higher maximum rate, the fixed point
- * divide below will need to be adjusted
- */
- pStream->frameLength = (AUDIO_FRAME_LENGTH * (rate >> 8)) >> 20;
-
- /* notify stream of new playback rate */
- EAS_SetStreamParameter(pEASData, pStream, PARSER_DATA_PLAYBACK_RATE, (EAS_I32) rate);
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
* EAS_SetTransposition)
*----------------------------------------------------------------------------
* Purpose:
@@ -1415,60 +1224,6 @@ EAS_PUBLIC EAS_RESULT EAS_ParseMetaData (EAS_DATA_HANDLE pEASData, EAS_HANDLE pS
}
/*----------------------------------------------------------------------------
- * EAS_RegisterMetaDataCallback()
- *----------------------------------------------------------------------------
- * Purpose:
- * Registers a metadata callback function for parsed metadata.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - file or stream handle
- * cbFunc - pointer to host callback function
- * metaDataBuffer - pointer to metadata buffer
- * metaDataBufSize - maximum size of the metadata buffer
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_RegisterMetaDataCallback (
- EAS_DATA_HANDLE pEASData,
- EAS_HANDLE pStream,
- EAS_METADATA_CBFUNC cbFunc,
- char *metaDataBuffer,
- EAS_I32 metaDataBufSize,
- EAS_VOID_PTR pUserData)
-{
- S_METADATA_CB metadata;
-
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-
- /* register callback function */
- metadata.callback = cbFunc;
- metadata.buffer = metaDataBuffer;
- metadata.bufferSize = metaDataBufSize;
- metadata.pUserData = pUserData;
- return EAS_SetStreamParameter(pEASData, pStream, PARSER_DATA_METADATA_CB, (EAS_I32) &metadata);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetNoteCount ()
- *----------------------------------------------------------------------------
- * Returns the total number of notes played in this stream
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetNoteCount (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 *pNoteCount)
-{
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntGetStrmParam(pEASData, pStream, PARSER_DATA_NOTE_COUNT, pNoteCount);
-}
-
-/*----------------------------------------------------------------------------
* EAS_CloseFile()
*----------------------------------------------------------------------------
* Purpose:
@@ -1505,156 +1260,6 @@ EAS_PUBLIC EAS_RESULT EAS_CloseFile (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStrea
}
/*----------------------------------------------------------------------------
- * EAS_OpenMIDIStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Opens a raw MIDI stream allowing the host to route MIDI cable data directly to the synthesizer
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * pHandle - pointer to variable to hold file or stream handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_OpenMIDIStream (EAS_DATA_HANDLE pEASData, EAS_HANDLE *ppStream, EAS_HANDLE streamHandle)
-{
- EAS_RESULT result;
- S_INTERACTIVE_MIDI *pMIDIStream;
- EAS_INT streamNum;
-
- /* initialize some pointers */
- *ppStream = NULL;
-
- /* allocate a stream */
- if ((streamNum = EAS_AllocateStream(pEASData)) < 0)
- return EAS_ERROR_MAX_STREAMS_OPEN;
-
- /* check Configuration Module for S_EAS_DATA allocation */
- if (pEASData->staticMemoryModel)
- pMIDIStream = EAS_CMEnumData(EAS_CM_MIDI_STREAM_DATA);
- else
- pMIDIStream = EAS_HWMalloc(pEASData->hwInstData, sizeof(S_INTERACTIVE_MIDI));
-
- /* allocate dynamic memory */
- if (!pMIDIStream)
- {
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_FATAL, "Failed to allocate MIDI stream data\n"); */ }
- return EAS_ERROR_MALLOC_FAILED;
- }
-
- /* zero the memory to insure complete initialization */
- EAS_HWMemSet(pMIDIStream, 0, sizeof(S_INTERACTIVE_MIDI));
- EAS_InitStream(&pEASData->streams[streamNum], NULL, pMIDIStream);
-
- /* instantiate a new synthesizer */
- if (streamHandle == NULL)
- {
- result = VMInitMIDI(pEASData, &pMIDIStream->pSynth);
- }
-
- /* use an existing synthesizer */
- else
- {
- EAS_I32 value;
- result = EAS_GetStreamParameter(pEASData, streamHandle, PARSER_DATA_SYNTH_HANDLE, &value);
- pMIDIStream->pSynth = (S_SYNTH*) value;
- VMIncRefCount(pMIDIStream->pSynth);
- }
- if (result != EAS_SUCCESS)
- {
- EAS_CloseMIDIStream(pEASData, &pEASData->streams[streamNum]);
- return result;
- }
-
- /* initialize the MIDI stream data */
- EAS_InitMIDIStream(&pMIDIStream->stream);
-
- *ppStream = (EAS_HANDLE) &pEASData->streams[streamNum];
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_WriteMIDIStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Send data to the MIDI stream device
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - stream handle
- * pBuffer - pointer to buffer
- * count - number of bytes to write
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_WriteMIDIStream (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_U8 *pBuffer, EAS_I32 count)
-{
- S_INTERACTIVE_MIDI *pMIDIStream;
- EAS_RESULT result;
-
- pMIDIStream = (S_INTERACTIVE_MIDI*) pStream->handle;
-
- if (count <= 0)
- return EAS_ERROR_PARAMETER_RANGE;
-
- /* send the entire buffer */
- while (count--)
- {
- if ((result = EAS_ParseMIDIStream(pEASData, pMIDIStream->pSynth, &pMIDIStream->stream, *pBuffer++, eParserModePlay)) != EAS_SUCCESS)
- return result;
- }
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_CloseMIDIStream()
- *----------------------------------------------------------------------------
- * Purpose:
- * Closes a raw MIDI stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - stream handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_CloseMIDIStream (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream)
-{
- S_INTERACTIVE_MIDI *pMIDIStream;
-
- pMIDIStream = (S_INTERACTIVE_MIDI*) pStream->handle;
-
- /* close synth */
- if (pMIDIStream->pSynth != NULL)
- {
- VMMIDIShutdown(pEASData, pMIDIStream->pSynth);
- pMIDIStream->pSynth = NULL;
- }
-
- /* release allocated memory */
- if (!pEASData->staticMemoryModel)
- EAS_HWFree(((S_EAS_DATA*) pEASData)->hwInstData, pMIDIStream);
-
- pStream->handle = NULL;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
* EAS_State()
*----------------------------------------------------------------------------
* Purpose:
@@ -1709,152 +1314,6 @@ EAS_PUBLIC EAS_RESULT EAS_State (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, E
}
/*----------------------------------------------------------------------------
- * EAS_SetPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the polyphony of the stream. A value of 0 allows the stream
- * to use all voices (set by EAS_SetSynthPolyphony).
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * polyphonyCount - the desired polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPolyphony (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 polyphonyCount)
-{
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntSetStrmParam(pEASData, pStream, PARSER_DATA_POLYPHONY, polyphonyCount);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current polyphony setting of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * pPolyphonyCount - pointer to variable to receive polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetPolyphony (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 *pPolyphonyCount)
-{
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntGetStrmParam(pEASData, pStream, PARSER_DATA_POLYPHONY, pPolyphonyCount);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetSynthPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the polyphony of the synth . Value must be >= 1 and <= the
- * maximum number of voices. This function will pin the polyphony
- * at those limits
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * synthNum - synthesizer number (0 = onboard, 1 = DSP)
- * polyphonyCount - the desired polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetSynthPolyphony (EAS_DATA_HANDLE pEASData, EAS_I32 synthNum, EAS_I32 polyphonyCount)
-{
- return VMSetSynthPolyphony(pEASData->pVoiceMgr, synthNum, polyphonyCount);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetSynthPolyphony()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current polyphony setting of the synth
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * synthNum - synthesizer number (0 = onboard, 1 = DSP)
- * pPolyphonyCount - pointer to variable to receive polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetSynthPolyphony (EAS_DATA_HANDLE pEASData, EAS_I32 synthNum, EAS_I32 *pPolyphonyCount)
-{
- return VMGetSynthPolyphony(pEASData->pVoiceMgr, synthNum, pPolyphonyCount);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetPriority()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the priority of the stream. Determines which stream's voices
- * are stolen when there are insufficient voices for all notes.
- * Value must be in the range of 1-15, lower values are higher
- * priority.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * polyphonyCount - the desired polyphony count
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPriority (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 priority)
-{
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntSetStrmParam(pEASData, pStream, PARSER_DATA_PRIORITY, priority);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetPriority()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current priority setting of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * pPriority - pointer to variable to receive priority
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetPriority (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 *pPriority)
-{
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntGetStrmParam(pEASData, pStream, PARSER_DATA_PRIORITY, pPriority);
-}
-
-/*----------------------------------------------------------------------------
* EAS_SetVolume()
*----------------------------------------------------------------------------
* Purpose:
@@ -1916,81 +1375,6 @@ EAS_PUBLIC EAS_RESULT EAS_SetVolume (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStrea
}
/*----------------------------------------------------------------------------
- * EAS_GetVolume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the master volume for the synthesizer. The default volume setting is
- * 50. The volume range is 0 to 100;
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * volume - the desired master volume
- * handle - file or stream handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- * overrides any previously set master volume from sysex
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_I32 EAS_GetVolume (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream)
-{
- if (pStream == NULL)
- return pEASData->masterVolume;
-
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return pStream->volume;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetMaxLoad()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the maximum workload the parsers will do in a single call to
- * EAS_Render. The units are currently arbitrary, but should correlate
- * well to the actual CPU cycles consumed. The primary effect is to
- * reduce the occasional peaks in CPU cycles consumed when parsing
- * dense parts of a MIDI score.
- *
- * Inputs:
- * pEASData - handle to data for this instance
- * maxLoad - the desired maximum workload
- *
- * Outputs:
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetMaxLoad (EAS_DATA_HANDLE pEASData, EAS_I32 maxLoad)
-{
- VMSetWorkload(pEASData->pVoiceMgr, maxLoad);
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetMaxPCMStreams()
- *----------------------------------------------------------------------------
- * Sets the maximum number of PCM streams allowed in parsers that
- * use PCM streaming.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * streamHandle - handle returned by EAS_OpenFile
- * maxNumStreams - maximum number of PCM streams
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetMaxPCMStreams (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 maxNumStreams)
-{
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntSetStrmParam(pEASData, pStream, PARSER_DATA_MAX_PCM_STREAMS, maxNumStreams);
-}
-
-/*----------------------------------------------------------------------------
* EAS_Locate()
*----------------------------------------------------------------------------
* Purpose:
@@ -2101,28 +1485,6 @@ EAS_PUBLIC EAS_RESULT EAS_GetLocation (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStr
}
/*----------------------------------------------------------------------------
- * EAS_GetRenderTime()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current playback offset
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- *
- * Outputs:
- * Gets the render time clock in msecs.
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetRenderTime (EAS_DATA_HANDLE pEASData, EAS_I32 *pTime)
-{
- *pTime = pEASData->renderTime >> 8;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
* EAS_Pause()
*----------------------------------------------------------------------------
* Purpose:
@@ -2240,41 +1602,6 @@ EAS_PUBLIC EAS_RESULT EAS_Resume (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream)
}
/*----------------------------------------------------------------------------
- * EAS_GetParameter()
- *----------------------------------------------------------------------------
- * Purpose:
- * Set the parameter of a module. See E_MODULES for a list of modules
- * and the header files of the modules for a list of parameters.
- *
- * Inputs:
- * psEASData - pointer to overall EAS data structure
- * handle - file or stream handle
- * module - enumerated module number
- * param - enumerated parameter number
- * pValue - pointer to variable to receive parameter value
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetParameter (EAS_DATA_HANDLE pEASData, EAS_I32 module, EAS_I32 param, EAS_I32 *pValue)
-{
-
- if (module >= NUM_EFFECTS_MODULES)
- return EAS_ERROR_INVALID_MODULE;
-
- if (pEASData->effectsModules[module].effectData == NULL)
- return EAS_ERROR_INVALID_MODULE;
-
- return (*pEASData->effectsModules[module].effect->pFGetParam)
- (pEASData->effectsModules[module].effectData, param, pValue);
-}
-
-/*----------------------------------------------------------------------------
* EAS_SetParameter()
*----------------------------------------------------------------------------
* Purpose:
@@ -2360,234 +1687,7 @@ EAS_PUBLIC EAS_RESULT EAS_MetricsReset (EAS_DATA_HANDLE pEASData)
}
#endif
-/*----------------------------------------------------------------------------
- * EAS_SetSoundLibrary()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the location of the sound library.
- *
- * Inputs:
- * pEASData - instance data handle
- * pSoundLib - pointer to sound library
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetSoundLibrary (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_SNDLIB_HANDLE pSndLib)
-{
- if (pStream)
- {
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- return EAS_IntSetStrmParam(pEASData, pStream, PARSER_DATA_EAS_LIBRARY, (EAS_I32) pSndLib);
- }
-
- return VMSetGlobalEASLib(pEASData->pVoiceMgr, pSndLib);
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetHeaderSearchFlag()
- *----------------------------------------------------------------------------
- * By default, when EAS_OpenFile is called, the parsers check the
- * first few bytes of the file looking for a specific header. Some
- * mobile devices may add a header to the start of a file, which
- * will prevent the parser from recognizing the file. If the
- * searchFlag is set to EAS_TRUE, the parser will search the entire
- * file looking for the header. This may enable EAS to recognize
- * some files that it would ordinarily reject. The negative is that
- * it make take slightly longer to process the EAS_OpenFile request.
- *
- * Inputs:
- * pEASData - instance data handle
- * searchFlag - search flag (EAS_TRUE or EAS_FALSE)
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetHeaderSearchFlag (EAS_DATA_HANDLE pEASData, EAS_BOOL searchFlag)
-{
- pEASData->searchHeaderFlag = (EAS_BOOL8) searchFlag;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_SetPlayMode()
- *----------------------------------------------------------------------------
- * Some file formats support special play modes, such as iMode partial
- * play mode. This call can be used to change the play mode. The
- * default play mode (usually straight playback) is always zero.
- *
- * Inputs:
- * pEASData - instance data handle
- * handle - file or stream handle
- * playMode - play mode (see file parser for specifics)
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetPlayMode (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_I32 playMode)
-{
- return EAS_IntSetStrmParam(pEASData, pStream, PARSER_DATA_PLAY_MODE, playMode);
-}
-
-#ifdef DLS_SYNTHESIZER
-/*----------------------------------------------------------------------------
- * EAS_LoadDLSCollection()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the location of the sound library.
- *
- * Inputs:
- * pEASData - instance data handle
- * pSoundLib - pointer to sound library
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_LoadDLSCollection (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_FILE_LOCATOR locator)
-{
- EAS_FILE_HANDLE fileHandle;
- EAS_RESULT result;
- EAS_DLSLIB_HANDLE pDLS;
-
- if (pStream != NULL)
- {
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
- }
-
- /* open the file */
- if ((result = EAS_HWOpenFile(pEASData->hwInstData, locator, &fileHandle, EAS_FILE_READ)) != EAS_SUCCESS)
- return result;
-
- /* parse the file */
- result = DLSParser(pEASData->hwInstData, fileHandle, 0, &pDLS);
- EAS_HWCloseFile(pEASData->hwInstData, fileHandle);
-
- if (result == EAS_SUCCESS)
- {
-
- /* if a stream pStream is specified, point it to the DLS collection */
- if (pStream)
- result = EAS_IntSetStrmParam(pEASData, pStream, PARSER_DATA_DLS_COLLECTION, (EAS_I32) pDLS);
-
- /* global DLS load */
- else
- result = VMSetGlobalDLSLib(pEASData, pDLS);
- }
-
- return result;
-}
-#endif
-
-#ifdef EXTERNAL_AUDIO
-/*----------------------------------------------------------------------------
- * EAS_RegExtAudioCallback()
- *----------------------------------------------------------------------------
- * Purpose:
- * Registers callback functions for audio events.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - file or stream handle
- * cbProgChgFunc - pointer to host callback function for program change
- * cbEventFunc - pointer to host callback functio for note events
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_RegExtAudioCallback (EAS_DATA_HANDLE pEASData,
- EAS_HANDLE pStream,
- EAS_VOID_PTR pInstData,
- EAS_EXT_PRG_CHG_FUNC cbProgChgFunc,
- EAS_EXT_EVENT_FUNC cbEventFunc)
-{
- S_SYNTH *pSynth;
-
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-
- if (EAS_GetStreamParameter(pEASData, pStream, PARSER_DATA_SYNTH_HANDLE, (EAS_I32*) &pSynth) != EAS_SUCCESS)
- return EAS_ERROR_INVALID_PARAMETER;
-
- if (pSynth == NULL)
- return EAS_ERROR_INVALID_PARAMETER;
-
- VMRegExtAudioCallback(pSynth, pInstData, cbProgChgFunc, cbEventFunc);
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * EAS_GetMIDIControllers()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current state of MIDI controllers on the requested channel.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - file or stream handle
- * pControl - pointer to structure to receive data
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_GetMIDIControllers (EAS_DATA_HANDLE pEASData, EAS_HANDLE pStream, EAS_U8 channel, S_MIDI_CONTROLLERS *pControl)
-{
- S_SYNTH *pSynth;
-
- if (!EAS_StreamReady(pEASData, pStream))
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-
- if (EAS_GetStreamParameter(pEASData, pStream, PARSER_DATA_SYNTH_HANDLE, (EAS_I32*) &pSynth) != EAS_SUCCESS)
- return EAS_ERROR_INVALID_PARAMETER;
-
- if (pSynth == NULL)
- return EAS_ERROR_INVALID_PARAMETER;
-
- VMGetMIDIControllers(pSynth, channel, pControl);
- return EAS_SUCCESS;
-}
-#endif
-
-#ifdef _SPLIT_ARCHITECTURE
-/*----------------------------------------------------------------------------
- * EAS_SetFrameBuffer()
- *----------------------------------------------------------------------------
- * Purpose:
- * Sets the frame buffer pointer passed to the IPC communications functions
- *
- * Inputs:
- * pEASData - instance data handle
- * locator - file locator
- *
- * Outputs:
- *
- *
- * Side Effects:
- * May overlay instruments in the GM sound set
- *
- *----------------------------------------------------------------------------
-*/
-EAS_PUBLIC EAS_RESULT EAS_SetFrameBuffer (EAS_DATA_HANDLE pEASData, EAS_FRAME_BUFFER_HANDLE pFrameBuffer)
-{
- if (pEASData->pVoiceMgr)
- pEASData->pVoiceMgr->pFrameBuffer = pFrameBuffer;
- return EAS_SUCCESS;
-}
-#endif
-
+#ifdef FILE_HEADER_SEARCH
/*----------------------------------------------------------------------------
* EAS_SearchFile
*----------------------------------------------------------------------------
@@ -2634,5 +1734,6 @@ EAS_RESULT EAS_SearchFile (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, con
}
return EAS_SUCCESS;
}
+#endif
diff --git a/arm-wt-22k/lib_src/eas_smf.c b/arm-wt-22k/lib_src/eas_smf.c
index 96ce167..5ad33fe 100644
--- a/arm-wt-22k/lib_src/eas_smf.c
+++ b/arm-wt-22k/lib_src/eas_smf.c
@@ -114,6 +114,7 @@ EAS_RESULT SMF_CheckFileType (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle,
if ((result = EAS_HWFileSeek(pEASData->hwInstData, fileHandle, offset)) != EAS_SUCCESS)
return result;
+#ifdef FILE_HEADER_SEARCH
/* search through file for header - slow method */
if (pEASData->searchHeaderFlag)
{
@@ -123,7 +124,9 @@ EAS_RESULT SMF_CheckFileType (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle,
}
/* read the first 4 bytes of the file - quick method */
- else {
+ else
+#endif
+ {
EAS_U8 header[4];
EAS_I32 count;
if ((result = EAS_HWReadFile(pEASData->hwInstData, fileHandle, header, sizeof(header), &count)) != EAS_SUCCESS)
diff --git a/arm-wt-22k/lib_src/eas_wavefile.c b/arm-wt-22k/lib_src/eas_wavefile.c
deleted file mode 100644
index f24bde2..0000000
--- a/arm-wt-22k/lib_src/eas_wavefile.c
+++ /dev/null
@@ -1,867 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_wavefile.c
- *
- * Contents and purpose:
- * This file implements the wave file parser.
- *
- * Copyright Sonic Network Inc. 2005
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 852 $
- * $Date: 2007-09-04 11:43:49 -0700 (Tue, 04 Sep 2007) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_data.h"
-#include "eas_report.h"
-#include "eas_host.h"
-#include "eas_config.h"
-#include "eas_parser.h"
-#include "eas_pcm.h"
-#include "eas_wavefile.h"
-
-/* lint is choking on the ARM math.h file, so we declare the log10 function here */
-extern double log10(double x);
-
-/* increase gain to compensate for loss in mixer */
-#define WAVE_GAIN_OFFSET 6
-
-/* constant for 1200 / log10(2.0) */
-#define PITCH_CENTS_CONVERSION 3986.313714
-
-/*----------------------------------------------------------------------------
- * WAVE file defines
- *----------------------------------------------------------------------------
-*/
-/* RIFF chunks */
-#define CHUNK_TYPE(a,b,c,d) ( \
- ( ((EAS_U32)(a) & 0xFF) << 24 ) \
- + ( ((EAS_U32)(b) & 0xFF) << 16 ) \
- + ( ((EAS_U32)(c) & 0xFF) << 8 ) \
- + ( ((EAS_U32)(d) & 0xFF) ) )
-
-#define CHUNK_RIFF CHUNK_TYPE('R','I','F','F')
-#define CHUNK_WAVE CHUNK_TYPE('W','A','V','E')
-#define CHUNK_FMT CHUNK_TYPE('f','m','t',' ')
-#define CHUNK_DATA CHUNK_TYPE('d','a','t','a')
-#define CHUNK_LIST CHUNK_TYPE('L','I','S','T')
-#define CHUNK_INFO CHUNK_TYPE('I','N','F','O')
-#define CHUNK_INAM CHUNK_TYPE('I','N','A','M')
-#define CHUNK_ICOP CHUNK_TYPE('I','C','O','P')
-#define CHUNK_IART CHUNK_TYPE('I','A','R','T')
-
-/* wave file format identifiers */
-#define WAVE_FORMAT_PCM 0x0001
-#define WAVE_FORMAT_IMA_ADPCM 0x0011
-
-/* file size for streamed file */
-#define FILE_SIZE_STREAMING 0x80000000
-
-/*----------------------------------------------------------------------------
- * prototypes
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveCheckFileType (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, EAS_VOID_PTR *pHandle, EAS_I32 offset);
-static EAS_RESULT WavePrepare (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData);
-static EAS_RESULT WaveState (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_STATE *pState);
-static EAS_RESULT WaveClose (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData);
-static EAS_RESULT WaveReset (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData);
-static EAS_RESULT WaveLocate (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 time, EAS_BOOL *pParserLocate);
-static EAS_RESULT WavePause (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData);
-static EAS_RESULT WaveResume (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData);
-static EAS_RESULT WaveSetData (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 value);
-static EAS_RESULT WaveGetData (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 *pValue);
-static EAS_RESULT WaveParseHeader (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, S_WAVE_STATE *pWaveData);
-static EAS_RESULT WaveGetMetaData (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 *pMediaLength);
-
-#ifdef MMAPI_SUPPORT
-static EAS_RESULT SaveFmtChunk (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, S_WAVE_STATE *pWaveData, EAS_I32 size);
-#endif
-
-/*----------------------------------------------------------------------------
- *
- * EAS_Wave_Parser
- *
- * This structure contains the functional interface for the Wave file parser
- *----------------------------------------------------------------------------
-*/
-const S_FILE_PARSER_INTERFACE EAS_Wave_Parser =
-{
- WaveCheckFileType,
- WavePrepare,
- NULL,
- NULL,
- WaveState,
- WaveClose,
- WaveReset,
- WavePause,
- WaveResume,
- WaveLocate,
- WaveSetData,
- WaveGetData,
- WaveGetMetaData
-};
-
-/*----------------------------------------------------------------------------
- * WaveCheckFileType()
- *----------------------------------------------------------------------------
- * Purpose:
- * Check the file type to see if we can parse it
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveCheckFileType (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, EAS_VOID_PTR *pHandle, EAS_I32 offset)
-{
- S_WAVE_STATE *pWaveData;
-
- /* zero the memory to insure complete initialization */
- *pHandle = NULL;
-
- /* read the file header */
- if (WaveParseHeader(pEASData, fileHandle, NULL) == EAS_SUCCESS)
- {
-
- /* check for static memory allocation */
- if (pEASData->staticMemoryModel)
- pWaveData = EAS_CMEnumData(EAS_CM_WAVE_DATA);
- else
- pWaveData = EAS_HWMalloc(pEASData->hwInstData, sizeof(S_WAVE_STATE));
- if (!pWaveData)
- return EAS_ERROR_MALLOC_FAILED;
- EAS_HWMemSet(pWaveData, 0, sizeof(S_WAVE_STATE));
-
- /* return a pointer to the instance data */
- pWaveData->fileHandle = fileHandle;
- pWaveData->fileOffset = offset;
- *pHandle = pWaveData;
- }
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * WavePrepare()
- *----------------------------------------------------------------------------
- * Purpose:
- * Prepare to parse the file.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WavePrepare (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData)
-{
- S_WAVE_STATE *pWaveData;
- EAS_RESULT result;
-
- /* validate parser state */
- pWaveData = (S_WAVE_STATE*) pInstData;
- if (pWaveData->streamHandle != NULL)
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-
- /* back to start of file */
- pWaveData->time = 0;
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, pWaveData->fileHandle, pWaveData->fileOffset)) != EAS_SUCCESS)
- return result;
-
- /* parse the file header */
- if ((result = WaveParseHeader(pEASData, pWaveData->fileHandle, pWaveData)) != EAS_SUCCESS)
- return result;
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * WaveState()
- *----------------------------------------------------------------------------
- * Purpose:
- * Returns the current state of the stream
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- * pState - pointer to variable to store state
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- * Notes:
- * This interface is also exposed in the internal library for use by the other modules.
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveState (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_STATE *pState)
-{
- S_WAVE_STATE *pWaveData;
-
- /* return current state */
- pWaveData = (S_WAVE_STATE*) pInstData;
- if (pWaveData->streamHandle)
- return EAS_PEState(pEASData, pWaveData->streamHandle, pState);
-
- /* if no stream handle, and time is not zero, we are done */
- if (pWaveData->time > 0)
- *pState = EAS_STATE_STOPPED;
- else
- *pState = EAS_STATE_OPEN;
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * WaveClose()
- *----------------------------------------------------------------------------
- * Purpose:
- * Close the file and clean up
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveClose (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData)
-{
- S_WAVE_STATE *pWaveData;
- EAS_RESULT result;
-
- pWaveData = (S_WAVE_STATE*) pInstData;
-
- /* close the stream */
- if (pWaveData->streamHandle)
- {
- if ((result = EAS_PEClose(pEASData, pWaveData->streamHandle)) != EAS_SUCCESS)
- return result;
- pWaveData->streamHandle = NULL;
- }
-
- /* if using dynamic memory, free it */
- if (!pEASData->staticMemoryModel)
- {
-
-#ifdef MMAPI_SUPPORT
- /* need to free the fmt chunk */
- if (pWaveData->fmtChunk != NULL)
- EAS_HWFree(pEASData->hwInstData, pWaveData->fmtChunk);
-#endif
-
- /* free the instance data */
- EAS_HWFree(pEASData->hwInstData, pWaveData);
-
- }
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * WaveReset()
- *----------------------------------------------------------------------------
- * Purpose:
- * Reset the sequencer. Used for locating backwards in the file.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveReset (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData)
-{
- EAS_PCM_HANDLE streamHandle;
-
- /* reset to first byte of data in the stream */
- streamHandle = ((S_WAVE_STATE*)pInstData)->streamHandle;
- if (streamHandle)
- return EAS_PEReset(pEASData, streamHandle);
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-}
-
-/*----------------------------------------------------------------------------
- * WaveLocate()
- *----------------------------------------------------------------------------
- * Purpose:
- * Rewind/fast-forward in file.
- *
- * Inputs:
- * pEASData - pointer to overall EAS data structure
- * handle - pointer to file handle
- * time - time (in msecs)
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pParserLocate) reserved for future use */
-static EAS_RESULT WaveLocate (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 time, EAS_BOOL *pParserLocate)
-{
- EAS_PCM_HANDLE streamHandle;
-
- /* reset to first byte of data in the stream */
- streamHandle = ((S_WAVE_STATE*)pInstData)->streamHandle;
- if (streamHandle)
- return EAS_PELocate(pEASData, streamHandle, time);
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-}
-
-/*----------------------------------------------------------------------------
- * WavePause()
- *----------------------------------------------------------------------------
- * Purpose:
- * Mute and stop rendering a PCM stream. Sets the gain target to zero and stops the playback
- * at the end of the next audio frame.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_WAVE_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-static EAS_RESULT WavePause (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData)
-{
- EAS_PCM_HANDLE streamHandle;
-
- /* pause the stream */
- streamHandle = ((S_WAVE_STATE*)pInstData)->streamHandle;
- if (streamHandle)
- return EAS_PEPause(pEASData, streamHandle);
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-}
-
-/*----------------------------------------------------------------------------
- * WaveResume()
- *----------------------------------------------------------------------------
- * Purpose:
- * Resume rendering a PCM stream. Sets the gain target back to its
- * previous setting and restarts playback at the end of the next audio
- * frame.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_WAVE_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-static EAS_RESULT WaveResume (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData)
-{
- EAS_PCM_HANDLE streamHandle;
-
- /* resume the stream */
- streamHandle = ((S_WAVE_STATE*)pInstData)->streamHandle;
- if (streamHandle)
- return EAS_PEResume(pEASData, streamHandle);
- return EAS_ERROR_NOT_VALID_IN_THIS_STATE;
-}
-
-/*----------------------------------------------------------------------------
- * WaveSetData()
- *----------------------------------------------------------------------------
- * Purpose:
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_WAVE_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveSetData (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 value)
-{
- S_WAVE_STATE *pWaveData = (S_WAVE_STATE*) pInstData;
-
- switch (param)
- {
- /* set metadata callback */
- case PARSER_DATA_METADATA_CB:
- EAS_HWMemCpy(&pWaveData->metadata, (void*) value, sizeof(S_METADATA_CB));
- return EAS_SUCCESS;
-
- case PARSER_DATA_PLAYBACK_RATE:
- value = (EAS_I32) (PITCH_CENTS_CONVERSION * log10((double) value / (double) (1 << 28)));
- return EAS_PEUpdatePitch(pEASData, pWaveData->streamHandle, (EAS_I16) value);
-
- case PARSER_DATA_VOLUME:
- return EAS_PEUpdateVolume(pEASData, pWaveData->streamHandle, (EAS_I16) value);
-
- default:
- return EAS_ERROR_INVALID_PARAMETER;
- }
-}
-
-/*----------------------------------------------------------------------------
- * WaveGetData()
- *----------------------------------------------------------------------------
- * Purpose:
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_WAVE_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-/*lint -esym(715, pEASData) reserved for future use */
-static EAS_RESULT WaveGetData (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 param, EAS_I32 *pValue)
-{
- S_WAVE_STATE *pWaveData;
-
- pWaveData = (S_WAVE_STATE*) pInstData;
- switch (param)
- {
- /* return file type as WAVE */
- case PARSER_DATA_FILE_TYPE:
- *pValue = pWaveData->fileType;
- break;
-
-#ifdef MMAPI_SUPPORT
- /* return pointer to 'fmt' chunk */
- case PARSER_DATA_FORMAT:
- *pValue = (EAS_I32) pWaveData->fmtChunk;
- break;
-#endif
-
- case PARSER_DATA_GAIN_OFFSET:
- *pValue = WAVE_GAIN_OFFSET;
- break;
-
- default:
- return EAS_ERROR_INVALID_PARAMETER;
- }
-
- return EAS_SUCCESS;
-}
-
-/*----------------------------------------------------------------------------
- * WaveParseHeader()
- *----------------------------------------------------------------------------
- * Purpose:
- * Parse the WAVE file header.
- *
- * Inputs:
- * pEASData - pointer to EAS library instance data
- * handle - pointer to S_WAVE_STATE for this stream
- *
- * Outputs:
- *
- *
- * Side Effects:
- *
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveParseHeader (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, S_WAVE_STATE *pWaveData)
-{
- S_PCM_OPEN_PARAMS params;
- EAS_RESULT result;
- EAS_U32 tag;
- EAS_U32 fileSize;
- EAS_U32 size;
- EAS_I32 pos;
- EAS_I32 audioOffset;
- EAS_U16 usTemp;
- EAS_BOOL parseDone;
- EAS_U32 avgBytesPerSec;
-
- /* init some data (and keep lint happy) */
- params.sampleRate = 0;
- params.size = 0;
- audioOffset = 0;
- params.decoder = 0;
- params.blockSize = 0;
- params.pCallbackFunc = NULL;
- params.cbInstData = NULL;
- params.loopSamples = 0;
- params.fileHandle = fileHandle;
- params.volume = 0x7fff;
- params.envData = 0;
- avgBytesPerSec = 8000;
-
- /* check for 'RIFF' tag */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &tag, EAS_TRUE)) != EAS_FALSE)
- return result;
- if (tag != CHUNK_RIFF)
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
-
- /* get size */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &fileSize, EAS_FALSE)) != EAS_FALSE)
- return result;
-
- /* check for 'WAVE' tag */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &tag, EAS_TRUE)) != EAS_FALSE)
- return result;
- if (tag != CHUNK_WAVE)
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
-
- /* this is enough to say we recognize the file */
- if (pWaveData == NULL)
- return EAS_SUCCESS;
-
- /* check for streaming mode */
- pWaveData->flags = 0;
- pWaveData->mediaLength = -1;
- pWaveData->infoChunkPos = -1;
- pWaveData->infoChunkSize = -1;
- if (fileSize== FILE_SIZE_STREAMING)
- {
- pWaveData->flags |= PCM_FLAGS_STREAMING;
- fileSize = 0x7fffffff;
- }
-
- /* find out where we're at */
- if ((result = EAS_HWFilePos(pEASData->hwInstData, fileHandle, &pos)) != EAS_SUCCESS)
- return result;
- fileSize -= 4;
-
- parseDone = EAS_FALSE;
- for (;;)
- {
- /* get tag and size for next chunk */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &tag, EAS_TRUE)) != EAS_FALSE)
- return result;
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &size, EAS_FALSE)) != EAS_FALSE)
- return result;
-
- /* process chunk */
- pos += 8;
- switch (tag)
- {
- case CHUNK_FMT:
-
-#ifdef MMAPI_SUPPORT
- if ((result = SaveFmtChunk(pEASData, fileHandle, pWaveData, (EAS_I32) size)) != EAS_SUCCESS)
- return result;
-#endif
-
- /* get audio format */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, fileHandle, &usTemp, EAS_FALSE)) != EAS_FALSE)
- return result;
- if (usTemp == WAVE_FORMAT_PCM)
- {
- params.decoder = EAS_DECODER_PCM;
- pWaveData->fileType = EAS_FILE_WAVE_PCM;
- }
- else if (usTemp == WAVE_FORMAT_IMA_ADPCM)
- {
- params.decoder = EAS_DECODER_IMA_ADPCM;
- pWaveData->fileType = EAS_FILE_WAVE_IMA_ADPCM;
- }
- else
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
-
- /* get number of channels */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, fileHandle, &usTemp, EAS_FALSE)) != EAS_FALSE)
- return result;
- if (usTemp == 2)
- pWaveData->flags |= PCM_FLAGS_STEREO;
- else if (usTemp != 1)
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
-
- /* get sample rate */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &params.sampleRate, EAS_FALSE)) != EAS_FALSE)
- return result;
-
- /* get stream rate */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &avgBytesPerSec, EAS_FALSE)) != EAS_FALSE)
- return result;
-
- /* get block alignment */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, fileHandle, &usTemp, EAS_FALSE)) != EAS_FALSE)
- return result;
- params.blockSize = usTemp;
-
- /* get bits per sample */
- if ((result = EAS_HWGetWord(pEASData->hwInstData, fileHandle, &usTemp, EAS_FALSE)) != EAS_FALSE)
- return result;
-
- /* PCM, must be 8 or 16 bit samples */
- if (params.decoder == EAS_DECODER_PCM)
- {
- if (usTemp == 8)
- pWaveData->flags |= PCM_FLAGS_8_BIT | PCM_FLAGS_UNSIGNED;
- else if (usTemp != 16)
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
- }
-
- /* for IMA ADPCM, we only support mono 4-bit ADPCM */
- else
- {
- if ((usTemp != 4) || (pWaveData->flags & PCM_FLAGS_STEREO))
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
- }
-
- break;
-
- case CHUNK_DATA:
- audioOffset = pos;
- if (pWaveData->flags & PCM_FLAGS_STREAMING)
- {
- params.size = 0x7fffffff;
- parseDone = EAS_TRUE;
- }
- else
- {
- params.size = (EAS_I32) size;
- params.loopStart = size;
- /* use more accurate method if possible */
- if (size <= (0x7fffffff / 1000))
- pWaveData->mediaLength = (EAS_I32) ((size * 1000) / avgBytesPerSec);
- else
- pWaveData->mediaLength = (EAS_I32) (size / (avgBytesPerSec / 1000));
- }
- break;
-
- case CHUNK_LIST:
- /* get the list type */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, fileHandle, &tag, EAS_TRUE)) != EAS_FALSE)
- return result;
- if (tag == CHUNK_INFO)
- {
- pWaveData->infoChunkPos = pos + 4;
- pWaveData->infoChunkSize = (EAS_I32) size - 4;
- }
- break;
-
- default:
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "WaveParseHeader: %c%c%c%c chunk - %d byte(s) ignored\n",
- (char) (tag >> 24), (char) (tag >> 16), (char) (tag >> 8), (char) tag, size); */ }
- break;
- }
-
- if (parseDone)
- break;
-
- /* subtract header size */
- fileSize -= 8;
-
- /* account for zero-padding on odd length chunks */
- if (size & 1)
- size++;
-
- /* this check works for files with odd length last chunk and no zero-pad */
- if (size >= fileSize)
- {
- if (size > fileSize)
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "WaveParseHeader: '%c%c%c%c' chunk size exceeds length of file or is not zero-padded\n",
- (char) (tag >> 24), (char) (tag >> 16), (char) (tag >> 8), (char) tag, size); */ }
- break;
- }
-
- /* subtract size of data chunk (including any zero-pad) */
- fileSize -= size;
-
- /* seek to next chunk */
- pos += (EAS_I32) size;
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, fileHandle, pos)) != EAS_SUCCESS)
- return result;
- }
-
- /* check for valid header */
- if ((params.sampleRate == 0) || (params.size == 0))
- return EAS_ERROR_UNRECOGNIZED_FORMAT;
-
- /* save the pertinent information */
- pWaveData->audioOffset = audioOffset;
- params.flags = pWaveData->flags;
-
- /* seek to data */
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, fileHandle, audioOffset)) != EAS_SUCCESS)
- return result;
-
- /* open a stream in the PCM engine */
- return EAS_PEOpenStream(pEASData, &params, &pWaveData->streamHandle);
-}
-
-/*----------------------------------------------------------------------------
- * WaveGetMetaData()
- *----------------------------------------------------------------------------
- * Purpose:
- * Process the INFO chunk and return metadata to host
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT WaveGetMetaData (S_EAS_DATA *pEASData, EAS_VOID_PTR pInstData, EAS_I32 *pMediaLength)
-{
- S_WAVE_STATE *pWaveData;
- EAS_RESULT result;
- EAS_I32 pos;
- EAS_U32 size;
- EAS_I32 infoSize;
- EAS_U32 tag;
- EAS_I32 restorePos;
- E_EAS_METADATA_TYPE metaType;
- EAS_I32 metaLen;
-
- /* get current position so we can restore it */
- pWaveData = (S_WAVE_STATE*) pInstData;
-
- /* return media length */
- *pMediaLength = pWaveData->mediaLength;
-
- /* did we encounter an INFO chunk? */
- if (pWaveData->infoChunkPos < 0)
- return EAS_SUCCESS;
-
- if ((result = EAS_HWFilePos(pEASData->hwInstData, pWaveData->fileHandle, &restorePos)) != EAS_SUCCESS)
- return result;
-
- /* offset to start of first chunk in INFO chunk */
- pos = pWaveData->infoChunkPos;
- infoSize = pWaveData->infoChunkSize;
-
- /* read all the chunks in the INFO chunk */
- for (;;)
- {
-
- /* seek to next chunk */
- if ((result = EAS_HWFileSeek(pEASData->hwInstData, pWaveData->fileHandle, pos)) != EAS_SUCCESS)
- return result;
-
- /* get tag and size for next chunk */
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, pWaveData->fileHandle, &tag, EAS_TRUE)) != EAS_FALSE)
- return result;
- if ((result = EAS_HWGetDWord(pEASData->hwInstData, pWaveData->fileHandle, &size, EAS_FALSE)) != EAS_FALSE)
- return result;
-
- /* process chunk */
- pos += 8;
- metaType = EAS_METADATA_UNKNOWN;
- switch (tag)
- {
- case CHUNK_INAM:
- metaType = EAS_METADATA_TITLE;
- break;
-
- case CHUNK_IART:
- metaType = EAS_METADATA_AUTHOR;
- break;
-
- case CHUNK_ICOP:
- metaType = EAS_METADATA_COPYRIGHT;
- break;
-
- default:
- { /* dpp: EAS_ReportEx(_EAS_SEVERITY_INFO, "WaveParseHeader: %c%c%c%c chunk - %d byte(s) ignored\n",
- (char) (tag >> 24), (char) (tag >> 16), (char) (tag >> 8), (char) tag, size); */ }
- break;
- }
-
- /* process known metadata */
- if (metaType != EAS_METADATA_UNKNOWN)
- {
- metaLen = pWaveData->metadata.bufferSize - 1;
- if (metaLen > (EAS_I32) size)
- metaLen = (EAS_I32) size;
- if ((result = EAS_HWReadFile(pEASData->hwInstData, pWaveData->fileHandle, pWaveData->metadata.buffer, metaLen, &metaLen)) != EAS_SUCCESS)
- return result;
- pWaveData->metadata.buffer[metaLen] = 0;
- pWaveData->metadata.callback(metaType, pWaveData->metadata.buffer, pWaveData->metadata.pUserData);
- }
-
- /* subtract this block */
- if (size & 1)
- size++;
- infoSize -= (EAS_I32) size + 8;
- if (infoSize == 0)
- break;
- pos += (EAS_I32) size;
- }
-
-
- /* restore original position */
- return EAS_HWFileSeek(pEASData->hwInstData, pWaveData->fileHandle, restorePos);
-}
-
-#ifdef MMAPI_SUPPORT
-/*----------------------------------------------------------------------------
- * SaveFmtChunk()
- *----------------------------------------------------------------------------
- * Purpose:
- * Save the fmt chunk for the MMAPI library
- *----------------------------------------------------------------------------
-*/
-static EAS_RESULT SaveFmtChunk (S_EAS_DATA *pEASData, EAS_FILE_HANDLE fileHandle, S_WAVE_STATE *pWaveData, EAS_I32 fmtSize)
-{
- EAS_RESULT result;
- EAS_I32 pos;
- EAS_I32 count;
-
- /* save current file position */
- if ((result = EAS_HWFilePos(pEASData->hwInstData, fileHandle, &pos)) != EAS_SUCCESS)
- return result;
-
- /* allocate a chunk of memory */
- pWaveData->fmtChunk = EAS_HWMalloc(pEASData->hwInstData, fmtSize);
- if (!pWaveData->fmtChunk)
- return EAS_ERROR_MALLOC_FAILED;
-
- /* read the fmt chunk into memory */
- if ((result = EAS_HWReadFile(pEASData->hwInstData, fileHandle, pWaveData->fmtChunk, fmtSize, &count)) != EAS_SUCCESS)
- return result;
- if (count != fmtSize)
- return EAS_ERROR_FILE_READ_FAILED;
-
- /* restore file position */
- return EAS_HWFileSeek(pEASData->hwInstData, fileHandle, pos);
-}
-#endif
-
diff --git a/arm-wt-22k/lib_src/eas_wavefile.h b/arm-wt-22k/lib_src/eas_wavefile.h
deleted file mode 100644
index f8814a8..0000000
--- a/arm-wt-22k/lib_src/eas_wavefile.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_wavefile.h
- *
- * Contents and purpose:
- * Static data block for wave file parser.
- *
- * Copyright Sonic Network Inc. 2005
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 439 $
- * $Date: 2006-10-26 11:53:18 -0700 (Thu, 26 Oct 2006) $
- *----------------------------------------------------------------------------
-*/
-
-#ifndef _EAS_WAVEFILE_H
-#define _EAS_WAVEFILE_H
-
-#include "eas_data.h"
-#include "eas_pcm.h"
-
-/*----------------------------------------------------------------------------
- *
- * S_WAVE_STATE
- *
- * This structure contains the WAVE file parser state information
- *----------------------------------------------------------------------------
-*/
-typedef struct s_wave_state_tag
-{
- EAS_FILE_HANDLE fileHandle;
- EAS_PCM_HANDLE streamHandle;
- S_METADATA_CB metadata;
- EAS_U32 time;
- EAS_I32 fileOffset;
- EAS_I32 audioOffset;
- EAS_I32 mediaLength;
- EAS_U32 audioSize;
- EAS_U32 flags;
- EAS_I16 fileType;
-#ifdef MMAPI_SUPPORT
- EAS_VOID_PTR fmtChunk;
-#endif
- EAS_I32 infoChunkPos;
- EAS_I32 infoChunkSize;
-} S_WAVE_STATE;
-
-#endif
-
diff --git a/arm-wt-22k/lib_src/eas_wavefiledata.c b/arm-wt-22k/lib_src/eas_wavefiledata.c
deleted file mode 100644
index c224a6c..0000000
--- a/arm-wt-22k/lib_src/eas_wavefiledata.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*----------------------------------------------------------------------------
- *
- * File:
- * eas_wavefiledata.c
- *
- * Contents and purpose:
- * Static data block for wave file parser.
- *
- * Copyright Sonic Network Inc. 2005
-
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *----------------------------------------------------------------------------
- * Revision Control:
- * $Revision: 547 $
- * $Date: 2007-01-31 16:30:17 -0800 (Wed, 31 Jan 2007) $
- *----------------------------------------------------------------------------
-*/
-
-#include "eas_wavefile.h"
-
-S_WAVE_STATE eas_WaveData;
-