Skip to content

new C api functions ModPlug_GetVersion and ModPlug_Tell #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.12)

project(libmodplug)

set(VERSION "0.8.9.1")
set(VERSION "0.8.10.0")

option(BUILD_SHARED_LIBS "Build Shared Library (DLL)" OFF)

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.

AC_PREREQ([2.63])

AC_INIT([libmodplug],[0.8.9.1])
AC_INIT([libmodplug],[0.8.10.0])
AC_CONFIG_SRCDIR([Makefile.am])

AM_INIT_AUTOMAKE
Expand Down
20 changes: 20 additions & 0 deletions src/modplug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ namespace ModPlug
}
}

long ModPlug_GetVersion(void)
{
return LIBMODPLUG_VERSION;
}

ModPlugFile* ModPlug_Load(const void* data, int size)
{
ModPlugFile* result = new ModPlugFile;
Expand Down Expand Up @@ -265,6 +270,21 @@ void ModPlug_Seek(ModPlugFile* file, int millisecond)
file->mSoundFile.SetCurrentPos((int)(millisecond * postime));
}

int ModPlug_Tell(ModPlugFile *file)
{
int currentPos = (int)file->mSoundFile.GetCurrentPos();
int maxpos;
int maxtime = (int)file->mSoundFile.GetSongTime() * 1000;
float postime;
maxpos = (int)file->mSoundFile.GetMaxPosition();
postime = 0.0f;
if (maxtime != 0.0f)
postime = (float)maxpos / (float)maxtime;
if (postime == 0.0f)
return 0;
return (int) ((float)currentPos / postime);
}

void ModPlug_GetSettings(ModPlug_Settings* settings)
{
memcpy(settings, &ModPlug::gSettings, sizeof(ModPlug_Settings));
Expand Down
15 changes: 15 additions & 0 deletions src/modplug.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@
extern "C" {
#endif

#define LIBMODPLUG_MAJOR 0L
#define LIBMODPLUG_MINOR 8L
#define LIBMODPLUG_REVISION 10L
#define LIBMODPLUG_PATCH 0L
#define LIBMODPLUG_VERSION \
((LIBMODPLUG_MAJOR <<24) | \
(LIBMODPLUG_MINOR <<16) | \
(LIBMODPLUG_REVISION<< 8) | \
(LIBMODPLUG_PATCH))

#if defined(_WIN32) || defined(__CYGWIN__)
# if defined(MODPLUG_BUILD) && defined(DLL_EXPORT) /* building libmodplug as a dll for windows */
# define MODPLUG_EXPORT __declspec(dllexport)
Expand All @@ -25,6 +35,8 @@ extern "C" {
#define MODPLUG_EXPORT
#endif

MODPLUG_EXPORT long ModPlug_GetVersion(void);

struct _ModPlugFile;
typedef struct _ModPlugFile ModPlugFile;

Expand Down Expand Up @@ -67,6 +79,9 @@ MODPLUG_EXPORT int ModPlug_GetLength(ModPlugFile* file);
* ModPlug_GetLength() does not report the full length. */
MODPLUG_EXPORT void ModPlug_Seek(ModPlugFile* file, int millisecond);

/* Get the absolute playing position in song, in milliseconds. */
MODPLUG_EXPORT int ModPlug_Tell(ModPlugFile* file);

enum _ModPlug_Flags
{
MODPLUG_ENABLE_OVERSAMPLING = 1 << 0, /* Enable oversampling (*highly* recommended) */
Expand Down