mirror of
https://github.com/cookiengineer/audacity
synced 2026-01-12 07:35:51 +01:00
Extensive changes to improve NoteTrack display and (some) editing, NoteTrack playback via MIDI, and Midi-to-Audio alignment.
This commit is contained in:
@@ -7,10 +7,30 @@
|
||||
|
||||
/* Should there be a way to choose the source of time here? */
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef INT32_DEFINED
|
||||
// rather than having users install a special .h file for windows,
|
||||
// just put the required definitions inline here. portmidi.h uses
|
||||
// these too, so the definitions are (unfortunately) duplicated there
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#define INT32_DEFINED
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h> // needed for int32_t
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PMEXPORT
|
||||
#ifdef _WINDLL
|
||||
#define PMEXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define PMEXPORT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ptNoError = 0, /* success */
|
||||
@@ -21,7 +41,7 @@ typedef enum {
|
||||
} PtError;
|
||||
|
||||
|
||||
typedef long PtTimestamp;
|
||||
typedef int32_t PtTimestamp;
|
||||
|
||||
typedef void (PtCallback)( PtTimestamp timestamp, void *userData );
|
||||
|
||||
@@ -38,7 +58,7 @@ typedef void (PtCallback)( PtTimestamp timestamp, void *userData );
|
||||
return value:
|
||||
Upon success, returns ptNoError. See PtError for other values.
|
||||
*/
|
||||
PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
|
||||
PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
|
||||
|
||||
/*
|
||||
Pt_Stop() stops the timer.
|
||||
@@ -46,17 +66,17 @@ PtError Pt_Start(int resolution, PtCallback *callback, void *userData);
|
||||
return value:
|
||||
Upon success, returns ptNoError. See PtError for other values.
|
||||
*/
|
||||
PtError Pt_Stop();
|
||||
PMEXPORT PtError Pt_Stop();
|
||||
|
||||
/*
|
||||
Pt_Started() returns true iff the timer is running.
|
||||
*/
|
||||
int Pt_Started();
|
||||
PMEXPORT int Pt_Started();
|
||||
|
||||
/*
|
||||
Pt_Time() returns the current time in ms.
|
||||
*/
|
||||
PtTimestamp Pt_Time();
|
||||
PMEXPORT PtTimestamp Pt_Time();
|
||||
|
||||
/*
|
||||
Pt_Sleep() pauses, allowing other threads to run.
|
||||
@@ -65,7 +85,7 @@ PtTimestamp Pt_Time();
|
||||
of the pause may be rounded to the nearest or next clock tick
|
||||
as determined by resolution in Pt_Start().
|
||||
*/
|
||||
void Pt_Sleep(long duration);
|
||||
PMEXPORT void Pt_Sleep(int32_t duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ PtTimestamp Pt_Time()
|
||||
}
|
||||
|
||||
|
||||
void Pt_Sleep(long duration)
|
||||
void Pt_Sleep(int32_t duration)
|
||||
{
|
||||
usleep(duration * 1000);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ PtTimestamp Pt_Time()
|
||||
}
|
||||
|
||||
|
||||
void Pt_Sleep(long duration)
|
||||
void Pt_Sleep(int32_t duration)
|
||||
{
|
||||
usleep(duration * 1000);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ static void *Pt_CallbackProc(void *p)
|
||||
/* wait for a multiple of resolution ms */
|
||||
UInt64 wait_time;
|
||||
int delay = mytime++ * parameters->resolution - Pt_Time();
|
||||
long timestamp;
|
||||
PtTimestamp timestamp;
|
||||
if (delay < 0) delay = 0;
|
||||
wait_time = AudioConvertNanosToHostTime((UInt64)delay * NSEC_PER_MSEC);
|
||||
wait_time += AudioGetCurrentHostTime();
|
||||
@@ -104,6 +104,7 @@ PtError Pt_Stop()
|
||||
{
|
||||
/* printf("Pt_Stop called\n"); */
|
||||
pt_callback_proc_id++;
|
||||
pthread_join(pt_thread_pid, NULL);
|
||||
time_started_flag = FALSE;
|
||||
return ptNoError;
|
||||
}
|
||||
@@ -124,7 +125,7 @@ PtTimestamp Pt_Time()
|
||||
}
|
||||
|
||||
|
||||
void Pt_Sleep(long duration)
|
||||
void Pt_Sleep(int32_t duration)
|
||||
{
|
||||
usleep(duration * 1000);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ void CALLBACK winmm_time_callback(UINT uID, UINT uMsg, DWORD_PTR dwUser,
|
||||
}
|
||||
|
||||
|
||||
PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
|
||||
PMEXPORT PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
|
||||
{
|
||||
if (time_started_flag) return ptAlreadyStarted;
|
||||
timeBeginPeriod(resolution);
|
||||
@@ -38,7 +38,7 @@ PtError Pt_Start(int resolution, PtCallback *callback, void *userData)
|
||||
}
|
||||
|
||||
|
||||
PtError Pt_Stop()
|
||||
PMEXPORT PtError Pt_Stop()
|
||||
{
|
||||
if (!time_started_flag) return ptAlreadyStopped;
|
||||
if (time_callback && timer_id) {
|
||||
@@ -52,19 +52,19 @@ PtError Pt_Stop()
|
||||
}
|
||||
|
||||
|
||||
int Pt_Started()
|
||||
PMEXPORT int Pt_Started()
|
||||
{
|
||||
return time_started_flag;
|
||||
}
|
||||
|
||||
|
||||
PtTimestamp Pt_Time()
|
||||
PMEXPORT PtTimestamp Pt_Time()
|
||||
{
|
||||
return timeGetTime() - time_offset;
|
||||
}
|
||||
|
||||
|
||||
void Pt_Sleep(long duration)
|
||||
PMEXPORT void Pt_Sleep(int32_t duration)
|
||||
{
|
||||
Sleep(duration);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user