class Catalog

Information for a CD or list of audio files.

Inheritance:

Catalog


Public Fields

int* playlist
int pLen

Public Methods

const char* artist(void)
Catalog(unsigned int len0=2, unsigned int units=FRAME_PER_SEC, char *tag="Track")
Catalog(Catalog& that)
void genMagic(void)
int len(void)
unsigned long magic(void)
const char* name(unsigned int idx)
bool operator!=(Catalog that)
void operator<<=(int newmagick)
Catalog& operator=(Catalog& that)
bool operator==(Catalog that)
char* plName(unsigned int idx)
int plTime(unsigned int idx)
void resetPlaylist(void)
void setArtist(const char *ostr)
void setName(unsigned int idx, const char *ostr)
void setTime(unsigned int idx, int val)
void setTitle(const char *ostr)
int time(unsigned int idx)
const char* title(void)
~Catalog(void)

Documentation

This is a class to contain a CD or playlist's information for a catalog database. It is only a container; it does nothing towards database maintainence or modification.

NOTE 1: All class methods are inlined and defined after the class declaration. Please be sure you compile accordingly!

NOTE 2: Methods that access protected arrays do not check those indices to see if they are in range! That's your job as the programmer.

The magic number is calculated using Ti Kan's magic number algorithm, as presented in the source code for "wm2xmcd", part of his "xmcd" CD player program. See a source code distribution for "xmcd" for more info; direct all queries about the magic number to ti@amb.org.

  
  ----------------------------------------------------------
  ----------------------------------------------------------
  

int* playlist
List of indices used to create a playlist. The numbers in playlist are used by plTime() and plName() to index the list of track times and names. If playlist[i]>=len() anywhere in the list, you'll get a segmentation fault.

Do not deallocate this array; you'll cause ~Catalog() to crash.

int pLen
Length of playlist.

Catalog(unsigned int len0=2, unsigned int units=FRAME_PER_SEC, char *tag="Track")
Constructor for the Catalog class.

The constructor initializes several internal arrays and strings. These arrays must have some non-zero length, specified by len0. The default is set to 2, to prevent the destructor from segfaulting.

The other two parameters are not quite as critical. units specifies the unit of time you're using in this Catalog. It defaults to units of frames [common on CD's]; if you wanted to make a Catalog of sound files, you'd set units to the number of bytes per second in each file.

The initial names of each item are the string tag plus the item number.

Catalog(Catalog& that)
Copy Constructor for the Catalog class.

~Catalog(void)
Destructor for the Catalog class.

int len(void)
Returns:
The number of items in this Catalog.

const char* title(void)
Returns:
The title of this Catalog.

const char* artist(void)
Returns:
The artist/author of whatever this Catalog describes [CD, .midi file, etc.].

const char* name(unsigned int idx)
Returns:
The label of the idx-th item.

int time(unsigned int idx)
Returns:
The time value of the idx-th item.
See Also:
setTime

char* plName(unsigned int idx)
Equivalent to name(playlist[idx]).

int plTime(unsigned int idx)
Equivalent to time(playlist[idx]).

void resetPlaylist(void)
Resets the playlist array to its initial values. Useful if you've made lots of changes and want plName() and plTime() to start accessing items in numerical order again...

unsigned long magic(void)
Returns:
The unique magic number for this Catalog, or zero if setTime() or genMagic() have never been called.

void setTime(unsigned int idx, int val)
Sets the time value of the idx-th item to val.

Each item has associated with it a unique time-index, which typically specifies its position on the CD. If you are cataloging a list of soundfiles, you should set val to the time() of the previous item plus the length of that item.

val should always be in the units specifed when you called the constructor [i.e. frames per second, bytes per second, etc...].

This method automatically calls genMagic to update the Catalog magic-number.

void setName(unsigned int idx, const char *ostr)
Sets the label of the idx-th item to a copy of the string specified in ostr.

void setTitle(const char *ostr)
Sets the Catalog title to a copy of the string specified in ostr.

void setArtist(const char *ostr)
Sets the Catalog artist to a copy of the string specified in ostr.

void genMagic(void)
Generates the magic number for this Catalog using the times given in cTimes.

Based on the magic number generator by Ti Kan [ti@amb.org]; please direct all questions about it to him.

Catalog& operator=(Catalog& that)
Overloaded assignment operator. Copies the arrays instead of copying their pointers.

bool operator==(Catalog that)
Is true if both {bf Catalog}s have the same magic number.

bool operator!=(Catalog that)
Is true if both {bf Catalog}s don't have the same magic number.

void operator<<=(int newmagick)
An exceedingly arcane way to set the magic number by hand if you don't have the list of time-indices. Calling genMagic will undo any effects of this operator.

See Also:
setTime


This class has no child classes.
See Also:
AudDB, AudioDev

alphabetic index hierarchy of classes


Copyright 1997 by John Weiss [John.Weiss@colorado.edu] "generated by doc++"?! More like mangled ...

generated by doc++