DTaddcallback(3dm) DTaddcallback(3dm)
DTaddcallback - set a callback for the DAT audio data parser
#include <sys/types.h>
#include <dmedia/dataudio.h>
void DTaddcallback(DTPARSER* dtp, DTDATATYPES type,
DTCALLBACKFUNC func, void* arg)
dtp A pointer to the target DTPARSER.
type The type of callback being set. DTDATATYPES is an enumerated type
defined in dataudio.h containing the following values: dt_audio,
dt_pnum, dt_index, dt_ptime, dt_atime, dt_rtime, dt_prortime,
dt_mainid, dt_sampfreq, dt_toc, dt_date, dt_catalog, dt_ident,
dt_probinary.
func A pointer to the function to be called.
arg A user supplied argument that is passed to the callback function.
DTaddcallback adds a callback for the specified parser. The parser has
callbacks for fourteen different types of data in the digital audio data
stream corresponding to the enumerated types listed above. When data of
a particular type changes in the data stream from the tape, the parser
invokes the corresponding callback passing it a pointer to the data. The
dt_audio callback is an exception to this. It is called for every
recorded frame regardless of whether the data changed.
The callback is called as follows
func(void* arg, DTDATATYPES type, void* data);
arg is the user supplied argument provided as the third parameter to
DTaddcallback. type is the particular type of callback. It is passed so
that a single function could be used for all fourteen callbacks. data is
the data returned for this type of callback. The argument is cast to
void*. Each type of callback returns a different kind of data. An
explanation of the callback types and data structures passed to them is
given below. See datframe(4) for a detailed description of each type of
data in the digital audio data stream.
dt_audio
This is the audio data. The data argument in this case is really a
short* pointing at an array containing the byte-swapped and, if
necessary, de-emphasized audio data ready to hand to ALwritesamps(3dm).
If one of the interpolation flags is set, indicating an uncorrectable
error in the audio data, the data on the corresponding channel of the
Page 1
DTaddcallback(3dm) DTaddcallback(3dm)
current frame is set to zero. If you use this callback you will want to
change the handling of floating point underflow exceptions to achieve
acceptable performance. Put the following lines of code in your program:
#include <sigfpe.h>
sigfpe_[_UNDERFL].repls = _ZERO;
handle_sigfpes(_ON, _EN_UNDERFL, NULL, _ABORT_ON_ERROR, NULL);
See DTintro(3dm) for a complete explanation.
dt_pnum
This is the number of the current program (aka track). The data type in
this case is a pointer to a struct dtprognum defined in dataudio.h as
follows:
typedef struct dtprognum {
int value; /* Program converted to integer */
struct {
unchar d1, d2, d3; /* Program in BCD digits */
} bcd;
} DTPROGNUM;
Program number AA (program number not currently valid) is represented in
the converted value by 0xaaa. Program number BB (lead-in) is represented
by 0xbbb and program number EE (lead-out) is represented by 0xeee.
dt_index
This is the index number of the current subdivision within the program.
The data type in this case is a pointer to a struct dtprognum as
described above.
dt_ptime
This is the time into the current program. The data type is a pointer to
a struct dttimepack defined in dataudio.h as follows:
struct dttimepack {
unchar id:4, flag:1, pno1:3, pno2:4, pno3:4;
struct dtpackedbcd index;
struct dttimecode tc;
unchar parity;
};
The interesting portion of this structure is the struct dttimecode
defined in dataudio.h as follows:
struct dttimecode {
unchar hhi:4, hlo:4;
unchar mhi:4, mlo:4;
Page 2
DTaddcallback(3dm) DTaddcallback(3dm)
unchar shi:4, slo:4;
unchar fhi:4, flo:4;
} ptime;
dt_atime
This is the time since the start of the tape (absolute time). The data
type is a pointer to a struct dttimepack as described above.
dt_rtime
This is a continuously increasing time code running since the start of a
recording on the tape (running time). The value at the start of the
recording is arbitrary. The data type is a pointer to a struct
dttimepack as described above.
dt_prortime
This is running time for professional use. The time information is very
similar to running time but additional information is provided to aid
conversion from IEC (SMPTE) or Pro DIO time code to DAT time code.
Additional information for these time codes is provided in the Pro Binary
pack (see below). The data type is a pointer to a struct dtprotimepack
defined in dataudio.h as follows:
struct dtprotimepack {
unchar id:4, flag:1, fill:1, sid:2;
unchar freq:2, xrate:3, msb:3;
unchar lsb;
struct dttimecode tc;
unchar parity;
};
dt_mainid
These are the bits from the ID field of the main data area on the tape.
The data type is a pointer to a struct dtmainid defined in dataudio.h as
follows:
struct dtmainid {
unchar fmtid:2;
unchar emphasis:2;
unchar sampfreq:2;
unchar numchans:2;
unchar quantization:2;
unchar trackpitch:2;
unchar copy:2;
unchar pack:2;
} mid;
dt_sampfreq
Because the sampling frequency is of particular interest, it has its own
call back. The data type is an int* pointing to an integer containing
Page 3
DTaddcallback(3dm) DTaddcallback(3dm)
one of the following values: DT_FREQ48000, DT_FREQ44100, or DT_FREQ32000.
dt_toc
This item is one entry from the table of contents. The data type is a
pointer to a struct dttocpack defined in dataudio.h as follows:
struct dttocpack {
unchar id:4, flag:1, pno1:3, pno2:4, pno3:4;
struct dtpackedbcd point;
struct dttimecode atime;
unchar parity;
};
dt_date
This is time stamp for the recording. The data type is a pointer to a
struct dtdatepack defined in dataudio.h as follows:
struct dtdatepack {
unchar id:4, dayow:4;
struct dtpackedbcd year;
struct dtpackedbcd month;
struct dtpackedbcd day;
struct dtpackedbcd hour;
struct dtpackedbcd min;
struct dtpackedbcd sec;
unchar parity;
};
dt_catalog
This is the catalog number of the tape. On the tape the catalog number
is packed in an inconvenient way. The DAT parser unpacks the data to a
more useful form. The data type is a char* pointing to an array of 13
bytes. Each byte contains 1 BCD digit in its least significant nibble.
dt_ident
This is the ISRC identification number of the recording. This
information is separated into two separate subcode packs on the tape.
The DAT parser waits until it has both pieces, which it unpacks into a
new structure, before executing this callback. The data type is a
pointer to a struct dtident defined in dataudio.h as follows:
struct dtident {
unchar country[2];
unchar owner[3];
unchar year[2];
unchar serial[5];
} ident;
Page 4
DTaddcallback(3dm) DTaddcallback(3dm)
country and owner are encoded in the six-bit code converted by DTsbtoa.
year and serial are BCD digits.
dt_probinary
This is the rest of the information for use of IEC (SMPTE) or Pro DIO
time codes. The data type is a pointer to a struct probinarypack defined
in dataudio.h as follows:
struct dtprobinarypack {
unchar id:4, fill:2, sid:2;
union {
struct bgd {
unchar fill;
unchar tcbits;
struct dtpackedbcd bg[4];
} bgd; /* binary group data of IEC time code */
struct csid {
unchar csbytes[6];
} csid; /* channel status id of Pro DIO time code */
struct cod {
unchar fill[2];
unchar cod[4];
} cod; /* alphanumeric origin data of Pro DIO */
struct cdd {
unchar fill[1];
unchar flags;
unchar cdd[4];
} cdd; /* alphanumeric destination data of Pro DIO */
} data;
unchar parity;
};
DTintro(3dm), DTaddcallback(3dm), DTatotime(3dm), DTcreateparser(3dm),
DTinctime(3dm), DTparseframe(3dm), DTremovecallback(3dm),
DTresetparser(3dm), datframe(4), sigfpe(3C)
Mark Callow
PPPPaaaaggggeeee 5555 [ Back ]
|