TTS Project Journal

The Voice Library

← 5: Output

The LCV library consists of the following functions:

void cLCV(LCV &don, char *pat, int fl_chead=0);
int rhLCV(LCV &host, const char* guest);
int rdLCV(LCV &host, const char* guest);

int eatLVS(LCV &amoeba, const char* bctrum, int fl_meas=0);
int eatLVS(LCV &amoeba, const char** bctra, int fl_meas=0);
int eatRaw(LCV &amoeba, vosamp &vacu, const char* bctrum);
int eatRaw(LCV &amoeba, LVS &pheno, const char* bctrum);
int eatRaw(LCV &amoeba, LVS &pheno, const char** bctra);

void takeOutBack(LCV &pedo);

The read and copy functions are self-explanatory, but in any case nearly identical to their analogues in the LVS library. The eat functions are routines for loading a sample file into the LCV, and are the main way of building a LCV. The & argument prefix indicates that the data is passed by reference, which insures that data is not copied, saving space, and that operations refer to the same data from outside the function, making changes to it from within permanent.

eatLVS() works by reading the LVS data found at the bacterium filepath into a vosamp container using the LVS library functions. This intermediary container, the vacuole is then pushed into the LCV's clips vector. Though not currently operational, the fl_meas flag would control whether the LVS's size accumulates in the LCV's sdata variable.

eatLVS() is overloaded with a second version taking bacteria, an *array of filepath *strings. This enables batch loading of LVSs, simplifying automated LCV generation. I used batch loading to easily create test.lcv (See Output) from the directory of a folder containing only samples.

The eatRaw()s mostly follow after the eatLVS()s, but the LCV does not support raw data as a format by itself. Without storing the metadata to indicate features such as its size and bitrate, using the data is difficult to impossible, and what can be accomplished is guesswork. Hence, as with the raw data loading routines of the LVS library, the data is actually loaded into an LVS, and the metadata is provided by the user.

Still, one has a choice of how the user, or rather the writer of the interface between the user and the program, must feed the function this data. Simply passing it the variables via its arguments (e.g., eat(44100,16bitPCM)) allows the programmer to use the function without knowing how to create an LVS, easing the learning curve for programming with the library. However, this in turn requires to memorize the order in which file characteristics must be specified, which is already stricter than memorizing the names of the LVSs variables, as well as their displacement of the function's other relevant variables. In addition, some variables of the LVS do not always need to be specified, but entry of these would be obligatory for every loaded file so as to maintain the function's arity.

Thus I choose to have the user-programmer create and fill out a temporary LVS to pass into the function, rather than fully encapsulate the mechanism. The remaining eatRaw() taking vosamp &vacu does this one step further, and gives the user-programmer some control over the data management aspect of the mechanism. The eatRaw() taking bacteria demonstrates how this control can be functional by only creating one vacuole temporary that is reused by all the samples being loaded, circumventing many unnecessary constructions and destructions.

Finally, takeOutBack() does what must be done with your data when you no longer need that LCV. It is best you don't think about it.

Outside of the main library is the POSIX-only function (for now at least), eatBatchRaw(), which, as described above, takes the index of a folder and loads each listed file starting with a partial name as an LVS (with the same characteristics save size).

The following program created and saved an LVS using this function. It is adapted from the program that created test.lcv. If you know the paths to the files to be loaded beforehand, you can easily replace clade and eatBatchRaw() with an array of filepaths and eatRaw(). It uses Fleece, a class which can be found on the programming main page, for encapsulated filepath management.

fleece pathI(argv[0]); //argv[0] is the full filepath of the program"Input"); //Open folder
fleece pathO(argv[0]);"Output");

//Fill in LCV header
struct LCV t_lcv;
t_lcv.vrsn=_hvVo; //_hvVo is the current version constant
//t_lcv.keys=#; //Automatically determined"Test";

//Fill in temporary LVS's header
struct LVS mate;
mate.encod=enc(b16|fixpos|sgn); //Needed before load
mate.rate=44100; //Needed before load

std::string clade("tlcv"); //The prefix - load all files like "tlcv_4"
	//TRUE indicates error, so garbage collect and also indicate error
	return 1;

//Prepare output string
char t_data[_hsVS+t_lcv.namelen+t_lcv.sdata]; //Init
cLCV(t_lcv,t_data); //Copy
takeOutBack(t_lcv); //Garbage

//Write file
std::ofstream ao (pathO.curd+"test.lcv",std::ios::binary);
	return 0;
return 1;

~LCK, 6/13/2010

← 5: Output

All content © Casady Roy Kemper (a.k.a. Loki Clock) and protected by the Digital Millenium Copyright Act and the Berne Convention, unless otherwise stated or unless alternative authorship is indicated without explicit accompanying copyright claims on the part of Loki Clock.