#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <ctype.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include "fdms.h"
#include "util.h"
Defines | |
#define | SWAP(x, i, j) |
#define | SWAP_16(x) SWAP((x),0,1) |
#define | SWAP_24(x) SWAP((x),0,2) |
#define | SWAP_32(x) SWAP((x),0,3); SWAP((x),1,2) |
Functions | |
int | fdms_open (const char *path, fdms_vol **pp_vol) |
int | fdms_close (fdms_vol *vol) |
int | fdms_get_prg_capacity (fdms_vol *vol) |
int | fdms_get_prg_count (fdms_vol *vol) |
int | fdms_open_prg (fdms_vol *vol, int p, fdms_prg **pp_prg) |
int | fdms_get_trk_capacity (fdms_prg *prg) |
int | fdms_get_trk_count (fdms_prg *prg) |
size_t | fdms_get_trk_length (fdms_trk *trk) |
int | fdms_get_seg_count (fdms_trk *trk) |
size_t | fdms_get_seg_length (fdms_trk *trk, int s) |
int | fdms_read_seg_audio (char *buffer, fdms_trk *trk, int s, off_t offset, size_t count) |
int | fdms_read_trk_audio (char *buffer, fdms_trk *trk, off_t offset, size_t count) |
int | fdms_get_prg_header_raw (fdms_vol *vol, int p, char *header) |
const char * | fdms_get_prg_name (fdms_prg *prg) |
int | fdms_get_prg_info (fdms_prg *prg, struct fdms_prg_info *prg_info) |
int | fdms_get_timesig_map_raw (fdms_vol *vol, int p, char *timesig_map) |
int | fdms_get_timesig_map (fdms_prg *prg, struct fdms_sig *map) |
int | fdms_get_tempo_map_raw (fdms_vol *vol, int p, char *tempo_map) |
int | fdms_get_tempo_map (fdms_prg *prg, struct fdms_tempo *map) |
#define SWAP | ( | x, | |||
i, | |||||
j | ) |
Value:
{char t = ((char *)x)[(i)];\ ((char *)x)[(i)]=((char *)x)[(j)];\ ((char *)x)[(j)]=t;}
#define SWAP_16 | ( | x | ) | SWAP((x),0,1) |
Chang the endianness of a 16bit value.
#define SWAP_24 | ( | x | ) | SWAP((x),0,2) |
Chang the endianness of a 24bit value.
#define SWAP_32 | ( | x | ) | SWAP((x),0,3); SWAP((x),1,2) |
Chang the endianness of a 32bit value.
int fdms_close | ( | fdms_vol * | vol | ) |
Close fdms and release resources.
int fdms_get_prg_capacity | ( | fdms_vol * | vol | ) |
Get the program capacity.
This is the number of possible programs for this filesystem. Usually 128 (limited to 99 by the device).
vol | the volume handle. |
int fdms_get_prg_count | ( | fdms_vol * | vol | ) |
Get program count.
Returns the actual number of valid programs in the volume.
vol | the volume handle. |
int fdms_get_prg_header_raw | ( | fdms_vol * | vol, | |
int | p, | |||
char * | header | |||
) |
Return the raw header in the (caller-allocated) buffer header.
This method takes fdms_vol* rather than fdms_prg* in case fdms_open_prg can't parse the program header
int fdms_get_prg_info | ( | fdms_prg * | prg, | |
struct fdms_prg_info * | prg_info | |||
) |
Return program information.
const char* fdms_get_prg_name | ( | fdms_prg * | prg | ) |
Return the program name.
int fdms_get_seg_count | ( | fdms_trk * | trk | ) |
Get segment count.
A track is made up of logically consecutive segments numbered 0..n-1. This returns n.
trk | the track handle. |
size_t fdms_get_seg_length | ( | fdms_trk * | trk, | |
int | s | |||
) |
Get segment length (bytes) of segment s.
trk | the track handle. | |
s | the 0-based segment index. |
int fdms_get_tempo_map | ( | fdms_prg * | prg, | |
struct fdms_tempo * | tempo_map | |||
) |
Return tempo map.
int fdms_get_tempo_map_raw | ( | fdms_vol * | vol, | |
int | p, | |||
char * | tempo_map | |||
) |
Return the raw tempo map in the (caller-allocated) buffer tempo_map.
This method takes fdms_vol* rather than fdms_prg* in case fdms_open_prg can't parse the program header
int fdms_get_timesig_map_raw | ( | fdms_vol * | vol, | |
int | p, | |||
char * | timesig_map | |||
) |
Return the raw time sig map in the (caller-allocated) buffer timesig_map.
This method takes fdms_vol* rather than fdms_prg* in case fdms_open_prg can't parse the program header
int fdms_get_trk_capacity | ( | fdms_prg * | prg | ) |
Get track cacity.
Returns the number of tracks this program can hold. Usually 24, limited by the device to whatever it can handle.
prg | the volume handle. |
int fdms_get_trk_count | ( | fdms_prg * | prg | ) |
Get track count.
Returns the number of actual tracks in the program.
prg | the volume handle. |
size_t fdms_get_trk_length | ( | fdms_trk * | trk | ) |
Get track length (bytes).
trk | the track handle. |
int fdms_open | ( | const char * | path, | |
fdms_vol ** | pp_vol | |||
) |
Open volume.
path should point to an image or device.
Opens the device or image path, and stores a volume handle in pp_vol. This handle must be passed to fdms_close() once it is no longer needed.
path | the path to an FDMS image or device. | |
pp_vol | the volume handle will be stored here. |
Open program.
The program handle must be passed to fdms_close_prg() once it is no longer needed.
vol | the volume handle. | |
p | the 0-based program index | |
pp_prg | the program handle will be stored here. |
int fdms_read_seg_audio | ( | char * | buffer, | |
fdms_trk * | trk, | |||
int | s, | |||
off_t | offset, | |||
size_t | count | |||
) |
Read a maximum of count bytes from segment s starting at offset. Return the number of bytes actually read.
int fdms_read_trk_audio | ( | char * | buffer, | |
fdms_trk * | trk, | |||
off_t | offset, | |||
size_t | count | |||
) |
Read a maximum of count bytes from all segments of trk starting at offset. Return the number of bytes actually read.