This API provides functions to use sc68 libraries efficiently.
More...
This API provides functions to use sc68 libraries efficiently.
- Multi-threading issue
The API is not thread safe. Currently the 68000 emulator does not handle multi instance. Anyway the API may be used in multi-thread context as soon as you take care to play only one disk at a time.
Have a look to the xmms68 package to see how to use this API in multi-thread context.
- Quick start
char buffer[512*4];
memset(&init68, 0, sizeof(init68));
if (!sc68) goto error;
goto error;
}
}
error:
Set if no emulation pass has been runned.
#define API68_CHANGE_BIT 2 |
Set when track has changed.
Set when finish with all tracks.
#define API68_MIX_ERROR -1 |
Initialise sc68 API.
- Parameters
-
init | Initialization parameters. |
- Returns
- Pointer ti initialized API.
- Return values
-
- Warning
- Currently only one API can be initialized.
void api68_shutdown |
( |
api68_t * |
api | ) |
|
Shutdown sc68 API.
- Parameters
-
- Note
- It is safe to call with null api.
unsigned int api68_sampling_rate |
( |
api68_t * |
api, |
|
|
unsigned int |
f |
|
) |
| |
Set/Get sampling rate.
- Parameters
-
api | sc68 api. |
f | New sampling rate in hz or 0 to read current. |
- Returns
- Sampling rate (could be diffrent from requested one).
- Return values
-
void api68_set_share |
( |
api68_t * |
api, |
|
|
const char * |
path |
|
) |
| |
Set share data path.
- Parameters
-
api | sc68 api. |
path | New shared data path. |
void api68_set_user |
( |
api68_t * |
api, |
|
|
const char * |
path |
|
) |
| |
Set user data path.
- Parameters
-
api | sc68 api. |
path | New user data path. |
const char* api68_error |
( |
void |
| ) |
|
Pop and return last stacked error message.
- Returns
- Error message
- Return values
-
0 | No stacked error message |
void api68_debug |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
Display debug message.
- Parameters
-
fmt | printf() like format string. |
- See also
- debugmsg68()
int api68_process |
( |
api68_t * |
api, |
|
|
void * |
buf, |
|
|
int |
n |
|
) |
| |
Fill PCM buffer.
The api68_process() function fills the PCM buffer with the current music data. If the current track is finished and it is not the last the next one is automatically loaded. The function returns status value that report events that have occured during this pass.
- Parameters
-
api | sc68 api. |
buf | PCM buffer (must be at leat 4*n bytes). |
n | Number of sample to fill. |
- Returns
- Process status
int api68_play |
( |
api68_t * |
api, |
|
|
int |
track |
|
) |
| |
Set/Get current track.
The api68_play() function get or set current track.
If track == -1 the function returns the current track or 0 if none.
Else the function will test the requested track number. If it is 0, the disk default track will be use. If the track is out of range, the function fails and returns -1 else it returns 0. To avoid multi-threading issus the track is not changed directly but a change-track event is posted. This ecvent will be processed at the next call to the api68_process() function.
- Parameters
-
api | sc68 api. |
track | track number [-1:read current, 0:set disk default] |
- Returns
- error code or track number.
- Return values
-
0 | Success or no current track |
>0 | Current track |
-1 | Failure. |
Stop playing.
The api68_stop() function stop current playing track. Like the api68_play() function the api68_stop() function does not really stop the music but send a stop-event that will be processed by the next call to api68_process() function.
- Parameters
-
- Returns
- error code
- Return values
-
int api68_seek |
( |
api68_t * |
api, |
|
|
int |
time_ms |
|
) |
| |
Set/Get current play position.
The api68_seek() functions get or set the current play position.
If time_ms == -1 the function will returns the current play position or -1 if not currently playing.
If time_ms >= 0 the function will try to seek to the given position. If time_ms is out of range the function returns -1. If time_ms is inside the current playing track the function does not seek and returns -1. Else the function change to the track which time_ms belong and returns the time position at the beginning of this track.
The returned time is always the number of millisecond since the disk has started (not the track).
- Parameters
-
api | sc68 api. |
time_ms | new time position in ms (-1:read current time). |
- Returns
- error code
- Return values
-
Get disk/track information.
- Parameters
-
api | sc68 api |
info | track/disk information structure to be filled. |
track | track number (-1:current/default 0:disk-info). |
disk | disk to get information from (0 means API disk). |
- Returns
- error code
- Return values
-
- Warning
- API disk informations are valid as soon as the disk is loaded and must not be used after api_load() or api_close() function call. If disk was given the information are valid until the disk is freed.
int api68_verify_file |
( |
const char * |
filename | ) |
|
int api68_verify_mem |
( |
const void * |
buffer, |
|
|
int |
len |
|
) |
| |
Load an sc68 disk for playing.
int api68_load_file |
( |
api68_t * |
api, |
|
|
const char * |
filename |
|
) |
| |
int api68_load_mem |
( |
api68_t * |
api, |
|
|
const void * |
buffer, |
|
|
int |
len |
|
) |
| |
Load an sc68 disk outside the API.
Free it with api68_free() function.
api68_disk_t api68_disk_load_mem |
( |
const void * |
buffer, |
|
|
int |
len |
|
) |
| |
Change current disk.
- Parameters
-
- Returns
- error code
- Return values
-
0 | Success, disk has been loaded. |
-1 | Failure, no disk has been loaded (occurs if disk was 0). |
- Note
- Can be safely call with null api.
- Warning
- After api68_open() failure, the disk has been freed.
-
Beware not to use disk information after api68_close() call because the disk should have been destroyed.
Close current disk.
- Parameters
-
- Note
- Can be safely call with null api or if no disk has been loaded.
Get number of tracks.
- Parameters
-
- Returns
- Number of track
- Return values
-
- Note
- Could be use to check if a disk is loaded.
int api68_config_load |
( |
api68_t * |
api | ) |
|
Load config file.
- Parameters
-
int api68_config_save |
( |
api68_t * |
api | ) |
|
Save config file.
- Parameters
-
int api68_config_id |
( |
api68_t * |
api, |
|
|
const char * |
name |
|
) |
| |
Get config variable idex.
- Parameters
-
api | sc68 api |
name | name of config variable |
- Returns
- config index
- Return values
-
int api68_config_get |
( |
api68_t * |
api, |
|
|
int |
idx, |
|
|
int * |
v |
|
) |
| |
Get config variable value.
- Parameters
-
api | sc68 api |
idx | config index |
v | pointer to store config value |
- Returns
- Error code
- Return values
-
int api68_config_set |
( |
api68_t * |
api, |
|
|
int |
idx, |
|
|
int |
v |
|
) |
| |
Set config variable value.
- Parameters
-
api | sc68 api |
idx | config index |
v | new config value |
- Returns
- Error code
- Return values
-
void api68_config_apply |
( |
api68_t * |
api | ) |
|
Apply current configuration to api.
- Parameters
-
void* api68_alloc |
( |
unsigned int |
n | ) |
|
Allocate dynamic memory.
The api68_alloc() function calls the SC68alloc() function.
- Parameters
-
n | Size of buffer to allocate. |
- Returns
- pointer to allocated memory buffer.
- Return values
-
- See also
- SC68alloc()
void api68_free |
( |
void * |
data | ) |
|
Free dynamic memory.
The api68_free() function calls the SC68free() function.
- Parameters
-
data | Previously allocated memory buffer. |