Skip to content

Commit

Permalink
XMF format support. Issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolcl committed Apr 29, 2023
1 parent 82ff2ab commit fca4b80
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[=========================================================================[
Copyright (c) 2022 Pedro López-Cabanillas
Copyright (c) 2022-2023 Pedro López-Cabanillas
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,7 +47,7 @@ if (BUILD_TESTING)
endif()
endif()

if (UNIX AND NOT APPLE)
if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN)
find_library(MATH_LIBRARY m)
message(STATUS "Math library: ${MATH_LIBRARY}")
else()
Expand Down Expand Up @@ -94,8 +94,8 @@ list(APPEND SOURCES
#arm-wt-22k/lib_src/eas_wavefiledata.c
arm-wt-22k/lib_src/eas_wtengine.c
arm-wt-22k/lib_src/eas_wtsynth.c
#arm-wt-22k/lib_src/eas_xmf.c
#arm-wt-22k/lib_src/eas_xmfdata.c
arm-wt-22k/lib_src/eas_xmf.c
arm-wt-22k/lib_src/eas_xmfdata.c
#arm-wt-22k/lib_src/jet.c
arm-wt-22k/lib_src/wt_22khz.c
)
Expand Down Expand Up @@ -126,7 +126,7 @@ target_compile_definitions( sonivox-objects PRIVATE
#_IMELODY_PARSER
#_RTTTL_PARSER
#_OTA_PARSER
#_XMF_PARSER
_XMF_PARSER
#JET_INTERFACE
)

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Example 3: pipe the rendered audio thru the 'lame' utility creating a MP3 file:

$ sonivoxrender ants.mid | lame -r -s 22050 - ants.mp3

You may replace "ants.mid" by another MIDI or XMF file, like "test/res/testmxmf.mxmf"

## Unit tests

The Android unit tests have been integrated in the CMake build system, with little modifications. A requirement is GoogleTest, either installed system wide or it will be downloaded from the git repository.
Expand All @@ -67,9 +69,9 @@ There are two environment variables that you may set before running the tests (m

## License

Copyright (c) 2022 Pedro López-Cabanillas.
Copyright (c) 2022-2023 Pedro López-Cabanillas.

Copyright (c) 2008-2022, The Android Open Source Project.
Copyright (c) 2008-2023, The Android Open Source Project.

Copyright (c) 2004-2006 Sonic Network Inc.

Expand Down
3 changes: 2 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[=========================================================================[
Copyright (c) 2022 Pedro López-Cabanillas
Copyright (c) 2022-2023 Pedro López-Cabanillas
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@ project( sonivoxrender LANGUAGES C )
# Alternative 1: Using CMake only and sonivox installed:
find_package ( sonivox CONFIG REQUIRED )
add_executable ( sonivoxrender sonivoxrender.c )
target_compile_definitions( sonivoxrender PRIVATE _LARGEFILE64_SOURCE )
target_link_libraries ( sonivoxrender sonivox::sonivox-static )

# Alternative 2: Using pkg-config and sonivox installed:
Expand Down
2 changes: 1 addition & 1 deletion example/sonivoxrender.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Pedro López-Cabanillas
* Copyright (c) 2022-2023, Pedro López-Cabanillas
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
13 changes: 11 additions & 2 deletions test/SonivoxTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,
ASSERT_EQ(playTimeMs, mAudioplayTimeMs)
<< "Invalid audio play time found for file: " << mInputMediaFile;

result = EAS_GetFileType(mEASDataHandle, mEASStreamHandle, &mFileType);
ASSERT_EQ(result, EAS_SUCCESS) << "Failed to get the file type";

EAS_I32 locationMs = -1;
/* EAS_ParseMetaData resets the parser to the starting of file */
result = EAS_GetLocation(mEASDataHandle, mEASStreamHandle, &locationMs);
Expand Down Expand Up @@ -163,6 +166,7 @@ class SonivoxTest : public ::testing::TestWithParam<tuple</*fileName*/ string,
EAS_PCM *mAudioBuffer;
EAS_I32 mPCMBufferSize;
const S_EAS_LIB_CONFIG *mEASConfig;
EAS_I32 mFileType;
};

static int readAt(void *handle, void *buffer, int offset, int size) {
Expand Down Expand Up @@ -299,6 +303,11 @@ TEST_P(SonivoxTest, SeekTest) {
}

TEST_P(SonivoxTest, DecodePauseResumeTest) {

if (mFileType == EAS_FILE_XMF0 || mFileType == EAS_FILE_XMF1) {
return; /* Pause and Resume are not supported by the XMF parser */
}

EAS_I32 seekPosition = mAudioplayTimeMs / 2;
// go to middle of the audio
EAS_RESULT result = EAS_Locate(mEASDataHandle, mEASStreamHandle, seekPosition, false);
Expand Down Expand Up @@ -350,8 +359,8 @@ INSTANTIATE_TEST_SUITE_P(SonivoxTestAll, SonivoxTest,
make_tuple("midi8sec.mid", 8002, 2, 22050),
make_tuple("midi_cs.mid", 2000, 2, 22050),
make_tuple("midi_gs.mid", 2000, 2, 22050),
make_tuple("ants.mid", 17233, 2, 22050)));
//make_tuple("testmxmf.mxmf", 29095, 2, 22050)));
make_tuple("ants.mid", 17233, 2, 22050),
make_tuple("testmxmf.mxmf", 29095, 2, 22050)));

int main(int argc, char **argv) {
gEnv = new SonivoxTestEnvironment();
Expand Down
Binary file added test/res/testmxmf.mxmf
Binary file not shown.

0 comments on commit fca4b80

Please sign in to comment.