Ejemplo n.º 1
0
autoTableOfReal FFNet_extractWeights (FFNet me, long layer) {
	try {
		FFNet_checkLayerNumber (me, layer);

		long numberOfUnitsFrom = my nUnitsInLayer[layer - 1] + 1;
		long numberOfUnitsTo = my nUnitsInLayer[layer];
		autoTableOfReal thee = TableOfReal_create (numberOfUnitsFrom, numberOfUnitsTo);

		char32 label[40];
		for (long i = 1; i <= numberOfUnitsFrom - 1; i++) {
			Melder_sprint (label,40, U"L", layer - 1, U"-", i);
			TableOfReal_setRowLabel (thee.peek(), i, label);
		}
		TableOfReal_setRowLabel (thee.peek(), numberOfUnitsFrom, U"Bias");
		for (long i = 1; i <= numberOfUnitsTo; i++) {
			Melder_sprint (label,40, U"L", layer, U"-", i);
			TableOfReal_setColumnLabel (thee.peek(), i, label);
		}

		long node = 1;
		for (long i = 0; i < layer; i++) {
			node += my nUnitsInLayer[i] + 1;
		}
		for (long i = 1; i <= numberOfUnitsTo; i++, node++) {
			long k = 1;
			for (long j = my wFirst[node]; j <= my wLast[node]; j++) {
				thy data[k++][i] = my w[j];
			}
		}
		return thee;
	} catch (MelderError) {
		Melder_throw (me, U": no TableOfReal created.");
	}
}
Ejemplo n.º 2
0
autoTableOfReal FormantTier_downto_TableOfReal (FormantTier me, int includeFormants, int includeBandwidths) {
	try {
		int maximumNumberOfFormants = FormantTier_getMaxNumFormants (me);
		autoTableOfReal thee = TableOfReal_create (my points -> size, 1 +
			( includeFormants ? maximumNumberOfFormants : 0 ) +
			( includeBandwidths ? maximumNumberOfFormants : 0 ));
		TableOfReal_setColumnLabel (thee.peek(), 1, U"Time");
		for (long icol = 1, iformant = 1; iformant <= maximumNumberOfFormants; iformant ++) {
			char32 label [4];
			if (includeFormants) {
				Melder_sprint (label,4, U"F", iformant);
				TableOfReal_setColumnLabel (thee.peek(), ++ icol, label);
			}
			if (includeBandwidths) {
				Melder_sprint (label,4, U"B", iformant);
				TableOfReal_setColumnLabel (thee.peek(), ++ icol, label);
			}
		}
		for (long ipoint = 1; ipoint <= my points -> size; ipoint ++) {
			FormantPoint point = (FormantPoint) my points -> item [ipoint];
			thy data [ipoint] [1] = point -> time;
			for (long icol = 1, iformant = 1; iformant <= maximumNumberOfFormants; iformant ++) {
				if (includeFormants) thy data [ipoint] [++ icol] = point -> formant [iformant-1];
				if (includeBandwidths) thy data [ipoint] [++ icol] = point -> bandwidth [iformant-1];
			}
		}
		return thee;
	} catch (MelderError) {
		Melder_throw (me, U": not converted to TableOfReal.");
	}
}
Ejemplo n.º 3
0
double PairDistribution_Distributions_getFractionCorrect (PairDistribution me, Distributions dist, long column) {
	try {
		double correct = 0.0;
		long pairmin = 1;
		char32 string [1000];
		Distributions_checkSpecifiedColumnNumberWithinRange (dist, column);
		autoPairDistribution thee = Data_copy (me);
		Collection_sort (thy pairs.get(), PairProbability_compare);
		double total = PairDistributions_getTotalWeight_checkPositive (thee.peek());
		do {
			long pairmax = pairmin, length, ipair;
			double sum = 0.0, sumDist = 0.0;
			char32 *firstInput = ((PairProbability) thy pairs -> item [pairmin]) -> string1;
			for (ipair = pairmin + 1; ipair <= thy pairs -> size; ipair ++) {
				PairProbability prob = static_cast <PairProbability> (thy pairs -> item [ipair]);
				if (! str32equ (prob -> string1, firstInput)) {
					pairmax = ipair - 1;
					break;
				}
			}
			if (ipair > thy pairs -> size) pairmax = thy pairs -> size;
			for (ipair = pairmin; ipair <= pairmax; ipair ++) {
				PairProbability prob = static_cast <PairProbability> (thy pairs -> item [ipair]);
				double p = prob -> weight / total, pout = 0.0;
				Melder_sprint (string, 1000, prob -> string1, U" \\-> ", prob -> string2);
				for (long idist = 1; idist <= dist -> numberOfRows; idist ++) {
					if (str32equ (string, dist -> rowLabels [idist])) {
						pout = dist -> data [idist] [column];
						break;
					}
				}
				sum += p * pout;
			}
			Melder_sprint (string, 1000, firstInput, U" \\-> ");
			length = str32len (string);
			for (long idist = 1; idist <= dist -> numberOfRows; idist ++) {
				if (str32nequ (string, dist -> rowLabels [idist], length)) {
					sumDist += dist -> data [idist] [column];
				}
			}
			if (sumDist != 0.0) correct += sum / sumDist;
			pairmin = pairmax + 1;
		} while (pairmin <= thy pairs -> size);
		return correct;
	} catch (MelderError) {
		Melder_throw (me, U" & ", dist, U": could not compute our fraction correct.");
	}
}
Ejemplo n.º 4
0
char32 * NUMstring_timeNoDot (double time) {
	static char32 string[100];
	long seconds = (long) floor (time);
	long ms = lround ((time - seconds) * 1000.0);
	Melder_sprint (string,100, U"_", seconds, U"_", ms);
	return string;
}
Ejemplo n.º 5
0
static void menu_cb_WriteFlac (TimeSoundEditor me, EDITOR_ARGS_FORM) {
	EDITOR_FORM_WRITE (U"Save selected sound as FLAC file", nullptr)
		Melder_sprint (defaultName,300, my d_longSound.data ? my d_longSound.data -> name : my d_sound.data -> name, U".flac");
	EDITOR_DO_WRITE
		do_write (me, file, Melder_FLAC, 16);
	EDITOR_END
}
Ejemplo n.º 6
0
static void menu_cb_WriteNextSun (TimeSoundEditor me, EDITOR_ARGS_FORM) {
	EDITOR_FORM_WRITE (U"Save selected sound as NeXT/Sun file", nullptr)
		Melder_sprint (defaultName,300, my d_longSound.data ? my d_longSound.data -> name : my d_sound.data -> name, U".au");
	EDITOR_DO_WRITE
		do_write (me, file, Melder_NEXT_SUN, 16);
	EDITOR_END
}
Ejemplo n.º 7
0
static void menu_cb_saveAs (TextEditor me, EDITOR_ARGS_DIRECT) {
	if (! my saveDialog)
		my saveDialog = UiOutfile_create (my d_windowForm, U"Save", cb_saveAs_ok, me, nullptr, nullptr);
	char32 defaultName [300];
	Melder_sprint (defaultName,300, ! my v_fileBased () ? U"info.txt" : my name [0] ? MelderFile_name (& my file) : U"");
	UiOutfile_do (my saveDialog.get(), defaultName);
}
Ejemplo n.º 8
0
void structOTGrammarEditor :: v_draw () {
	OTGrammar ot = (OTGrammar) data;
	static char32 text [1000];
	Graphics_clearWs (g);
	if (ot -> decisionStrategy == kOTGrammar_decisionStrategy_EXPONENTIAL_HG ||
		ot -> decisionStrategy == kOTGrammar_decisionStrategy_EXPONENTIAL_MAXIMUM_ENTROPY)
	{
		HyperPage_listItem (this, U"\t\t      %%ranking value\t      %disharmony\t      %plasticity\t   %%e^^disharmony");
	} else {
		HyperPage_listItem (this, U"\t\t      %%ranking value\t      %disharmony\t      %plasticity");
	}
	for (long icons = 1; icons <= ot -> numberOfConstraints; icons ++) {
		OTGrammarConstraint constraint = & ot -> constraints [ot -> index [icons]];
		if (ot -> decisionStrategy == kOTGrammar_decisionStrategy_EXPONENTIAL_HG ||
			ot -> decisionStrategy == kOTGrammar_decisionStrategy_EXPONENTIAL_MAXIMUM_ENTROPY)
		{
			Melder_sprint (text,1000,
				U"\t", icons == selected ? U"♠︎ " : U"   ",
				U"@@", icons,
				U"|", constraint -> name,
				U"@\t      ", Melder_fixed (constraint -> ranking, 3),
				U"\t      ", Melder_fixed (constraint -> disharmony, 3),
				U"\t      ", Melder_fixed (constraint -> plasticity, 6),
				U"\t ", Melder_float (Melder_half (exp (constraint -> disharmony))));
		} else {
			Melder_sprint (text,1000,
				U"\t", icons == selected ? U"♠︎ " : U"   ",
				U"@@", icons,
				U"|", constraint -> name,
				U"@\t      ", Melder_fixed (constraint -> ranking, 3),
				U"\t      ", Melder_fixed (constraint -> disharmony, 3),
				U"\t      ", Melder_fixed (constraint -> plasticity, 6));
		}
		HyperPage_listItem (this, text);
	}
	Graphics_setAtSignIsLink (g, FALSE);
	for (long itab = 1; itab <= ot -> numberOfTableaus; itab ++) {
		OTGrammarTableau tableau = & ot -> tableaus [itab];
		double rowHeight = 0.25;
		double tableauHeight = rowHeight * (tableau -> numberOfCandidates + 2);
		drawTableau_ot = ot;
		drawTableau_input = tableau -> input;
		drawTableau_constraintsAreDrawnVertically = d_constraintsAreDrawnVertically;
		HyperPage_picture (this, 20, tableauHeight, drawTableau);
	}
	Graphics_setAtSignIsLink (g, TRUE);
}
Ejemplo n.º 9
0
Configuration Configuration_createLetterRExample (int choice) {
	double x1[33] = { 0,
	                  -5, -5, -5, -5, -5, -5, -5,   -5, -5, -5,
	                  -5, -4, -3, -2, -1,  0,  1, 2.25,  3,  3,
	                  2.25,  1,  0, -1, -2, -3, -4,   -1,  0,  1, 2, 3
	                };
	double y1[33] = { 0,
	                  -6, -5, -4, -3, -2, -1, 0,   1,  2,  3,
	                  4,  4,  4,  4,  4,  4, 4, 3.5,  2,  1,
	                  -0.5, -1, -1, -1, -1, -1, -1, -2, -3, -4, -5, -6
	                };
	double x2[33] = {0, 0.94756043346272423, 0.73504466902509913,
	                 0.4528453515175927,    0.46311499024105723,   0.30345454816993439,
	                 0.075184942115601547, -0.090010071904764719, -0.19630977381424003,
	                 -0.36341509807865086,  -0.54216996409132612,  -0.68704678013309872,
	                 -0.67370169194623086,  -0.69336494336440502,  -0.67809065144478664,
	                 -0.61382610572366281,  -0.68656530656078996,  -0.57704879646736551,
	                 -0.63417502349009069,  -0.37153350651419026,  -0.091809666009009777,
	                 0.054833807442559397,  0.1445593164362155,    0.055587230806920782,
	                 0.18201798315035453,   0.048445620192953162,  0.081595930742961439,
	                 0.20063623749033621,   0.28546520751183313,   0.39384438699721991,
	                 0.62832258520372286,   0.78548335015622228,   1.0610707888793069
	                };
	double y2[33] = {0, 0.49630791172076621, 0.53320347382055022,
	                 0.62384637225470441,  0.47592708487655661,  0.50364353255684202,
	                 0.55311720162084443,  0.55118713773007066,  0.50007736370068601,
	                 0.40432332354648709,  0.49817059660482677,  0.49803436631629411,
	                 0.33213829258059019,  0.14585700576425648, -0.022110500334692869,
	                 -0.1752555003289698,  -0.29448744336706828, -0.45639468287493545,
	                 -0.59177815505008013, -0.74980550818568981, -0.78095916436791279,
	                 -0.64447562732895125, -0.49526830813007033, -0.22443396573313243,
	                 -0.066378148077667398, -0.03498490725857361,  0.16196028200653381,
	                 0.30633527000982519, -0.14894460651161745, -0.30808798640907431,
	                 -0.35920781945385832, -0.62766325578928184, -0.60389363590825562
	                };
	try {
		double *x, *y;
		autoConfiguration me = Configuration_create (32, 2);

		if (choice == 2) {
			x = x2; y = y2;
			Thing_setName (me.peek(), U"R_fit");
		} else {
			x = x1; y = y1;
			Thing_setName (me.peek(), U"R");
		}

		for (long i = 1; i <= 32; i++) {
			char32 s[20];
			Melder_sprint (s,20, i);
			TableOfReal_setRowLabel (me.peek(), i, s);
			my data [i][1] = x[i];
			my data [i][2] = y[i];
		}
		return me.transfer();
	} catch (MelderError) {
		Melder_throw (U"Letter R Configuration not created.");
	}
}
Ejemplo n.º 10
0
static void menu_cb_SaveAs32BitWav (TimeSoundEditor me, EDITOR_ARGS_FORM) {
	EDITOR_FORM_WRITE (U"Save selected sound as 32-bit WAV file", nullptr)
		Melder_assert (! my d_longSound.data && my d_sound.data);
		Melder_sprint (defaultName,300, my d_sound.data -> name, U".wav");
	EDITOR_DO_WRITE
		do_write (me, file, Melder_WAV, 32);
	EDITOR_END
}
Ejemplo n.º 11
0
void OrderedOfString_sequentialNumbers (OrderedOfString me, long n) {
	Collection_removeAllItems (me);
	for (long i = 1; i <= n; i++) {
		char32 s[40];
		Melder_sprint (s,40, i);
		autoSimpleString str = SimpleString_create (s);
		Collection_addItem (me, str.transfer());
	}
}
Ejemplo n.º 12
0
void Discriminant_drawConcentrationEllipses (Discriminant me, Graphics g, double scale, bool confidence, char32 *label,
        int discriminantDirections, long d1, long d2, double xmin, double xmax, double ymin, double ymax, int fontSize, int garnish)
{
    long numberOfFunctions = Discriminant_getNumberOfFunctions (me);

    if (! discriminantDirections) {
        SSCPList_drawConcentrationEllipses (my groups.get(), g, scale, confidence, label, d1, d2, xmin, xmax, ymin, ymax, fontSize, garnish);
        return;
    }

    if (numberOfFunctions <= 1) {
        Melder_warning (U"Discriminant_drawConcentrationEllipses: Nothing drawn "
                        U"because there is only one dimension in the discriminant space.");
        return;
    }

    // Project SSCPs on eigenvectors.

    if (d1 == 0 && d2 == 0) {
        d1 = 1;
        d2 = MIN (numberOfFunctions, d1 + 1);
    } else if (d1 < 0 || d2 > numberOfFunctions) {
        return;
    }

    double *v1 = my eigen -> eigenvectors [d1];
    double *v2 = my eigen -> eigenvectors [d2];


    autoSSCPList thee = SSCPList_toTwoDimensions (my groups.get(), v1, v2);

    SSCPList_drawConcentrationEllipses (thee.get(), g, scale, confidence, label, 1, 2, xmin, xmax, ymin, ymax, fontSize, 0);

    if (garnish) {
        char32 llabel[40];
        Graphics_drawInnerBox (g);
        Graphics_marksLeft (g, 2, true, true, false);
        Melder_sprint (llabel,40, U"function ", d2);
        Graphics_textLeft (g, true, llabel);
        Graphics_marksBottom (g, 2, true, true, false);
        Melder_sprint (llabel,40, U"function ", d1);
        Graphics_textBottom (g, true, llabel);
    }
}
Ejemplo n.º 13
0
static void menu_cb_writeOneToHtmlFile (Manual me, EDITOR_ARGS_FORM) {
	EDITOR_FORM_WRITE (U"Save as HTML file", nullptr)
		ManPages manPages = (ManPages) my data;
		autoMelderString buffer;
		MelderString_copy (& buffer, manPages -> pages.at [my path] -> title);
		char32 *p = buffer.string;
		while (*p) { if (! isalnum ((int) *p) && *p != U'_') *p = U'_'; p ++; }
		MelderString_append (& buffer, U".html");
		Melder_sprint (defaultName,300, buffer.string);
	EDITOR_DO_WRITE
		ManPages_writeOneToHtmlFile ((ManPages) my data, my path, file);
	EDITOR_END
}
Ejemplo n.º 14
0
void structManual :: v_defaultHeaders (EditorCommand cmd) {
	Manual me = (Manual) cmd -> d_editor;
	ManPages manPages = (ManPages) my data;
	if (my path) {
		char32 string [400];
		static const char32 *shortMonth [] =
			{ U"Jan", U"Feb", U"Mar", U"Apr", U"May", U"Jun", U"Jul", U"Aug", U"Sep", U"Oct", U"Nov", U"Dec" };
		ManPage page = manPages -> pages.at [my path];
		long date = page -> date;
		SET_STRING (U"Right or outside header", page -> title)
		SET_STRING (U"Left or inside footer", page -> author)
		if (date) {
			Melder_sprint (string,400, shortMonth [date % 10000 / 100 - 1], U" ", date % 100, U", ", date / 10000);
			SET_STRING (U"Left or inside header", string)
		}
	}
Ejemplo n.º 15
0
static autoStrings Strings_createAsFileOrDirectoryList (const char32 *path /* cattable */, int type) {
	#if USE_STAT
		/*
		 * Initialize.
		 */
		DIR *d = nullptr;
		try {
			autoMelderString filePath, searchDirectory, left, right;
			/*
			 * Parse the path.
			 * Example: in /Users/paul/sounds/h*.wav",
			 * the search directory is "/Users/paul/sounds",
			 * the left environment is "h", and the right environment is ".wav".
			 */
			MelderString_copy (& searchDirectory, path);
			char32 *asterisk = str32rchr (searchDirectory. string, '*');
			if (asterisk) {
				*asterisk = '\0';
				searchDirectory. length = asterisk - searchDirectory. string;   // probably superfluous, but correct
				char32 *lastSlash = str32rchr (searchDirectory. string, Melder_DIRECTORY_SEPARATOR);
				if (lastSlash) {
					*lastSlash = '\0';   // This fixes searchDirectory.
					searchDirectory. length = lastSlash - searchDirectory. string;   // probably superfluous, but correct
					MelderString_copy (& left, lastSlash + 1);
				} else {
					MelderString_copy (& left, searchDirectory. string);   // quickly save...
					MelderString_empty (& searchDirectory);   // ...before destruction
				}
				MelderString_copy (& right, asterisk + 1);
			}
			char buffer8 [kMelder_MAXPATH+1];
			Melder_str32To8bitFileRepresentation_inline (searchDirectory. string, buffer8);
			d = opendir (buffer8 [0] ? buffer8 : ".");
			if (! d)
				Melder_throw (U"Cannot open directory ", searchDirectory. string, U".");
			//Melder_casual (U"opened");
			autoStrings me = Thing_new (Strings);
			my strings = NUMvector <char32 *> (1, 1000000);
			struct dirent *entry;
			while (!! (entry = readdir (d))) {
				MelderString_copy (& filePath, searchDirectory. string [0] ? searchDirectory. string : U".");
				MelderString_appendCharacter (& filePath, Melder_DIRECTORY_SEPARATOR);
				char32 buffer32 [kMelder_MAXPATH+1];
				Melder_8bitFileRepresentationToStr32_inline (entry -> d_name, buffer32);
				MelderString_append (& filePath, buffer32);
				//Melder_casual (U"read ", filePath. string);
				Melder_str32To8bitFileRepresentation_inline (filePath. string, buffer8);
				struct stat stats;
				if (stat (buffer8, & stats) != 0) {
					//Melder_throw (U"Cannot look at file ", filePath. string, U".");
					//stats. st_mode = -1L;
				}
				//Melder_casual (U"statted ", filePath. string);
				//Melder_casual (U"file ", filePath. string, U" mode ", stats. st_mode / 4096);
				if ((type == Strings_createAsFileOrDirectoryList_TYPE_FILE && S_ISREG (stats. st_mode)) ||
					(type == Strings_createAsFileOrDirectoryList_TYPE_DIRECTORY && S_ISDIR (stats. st_mode)))
				{
					Melder_8bitFileRepresentationToStr32_inline (entry -> d_name, buffer32);
					int64 length = str32len (buffer32);
					if (buffer32 [0] != U'.' &&
						(left. length == 0 || str32nequ (buffer32, left. string, left. length)) &&
						(right. length == 0 || (length >= right. length && str32equ (buffer32 + (length - right. length), right. string))))
					{
						my strings [++ my numberOfStrings] = Melder_dup (buffer32);
					}
				}
			}
			closedir (d);
			Strings_sort (me.get());
			return me;
		} catch (MelderError) {
			if (d) closedir (d);   // "finally"
			throw;
		}
	#elif defined (_WIN32)
		try {
			char32 searchPath [kMelder_MAXPATH+1];
			int len = str32len (path);
			bool hasAsterisk = !! str32chr (path, U'*');
			bool endsInSeparator = ( len != 0 && path [len - 1] == U'\\' );
			autoStrings me = Thing_new (Strings);
			my strings = NUMvector <char32 *> (1, 1000000);
			Melder_sprint (searchPath, kMelder_MAXPATH+1, path, hasAsterisk || endsInSeparator ? U"" : U"\\", hasAsterisk ? U"" : U"*");
			WIN32_FIND_DATAW findData;
			HANDLE searchHandle = FindFirstFileW (Melder_peek32toW (searchPath), & findData);
			if (searchHandle != INVALID_HANDLE_VALUE) {
				do {
					if ((type == Strings_createAsFileOrDirectoryList_TYPE_FILE &&
							(findData. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
					 || (type == Strings_createAsFileOrDirectoryList_TYPE_DIRECTORY && 
							(findData. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
					{
						if (findData. cFileName [0] != L'.') {
							my strings [++ my numberOfStrings] = Melder_dup (Melder_peekWto32 (findData. cFileName));
						}
					}
				} while (FindNextFileW (searchHandle, & findData));
				FindClose (searchHandle);
			}
			Strings_sort (me.get());
			return me;
		} catch (MelderError) {
			throw;
		}
	#endif
}
Ejemplo n.º 16
0
static void readSound (ExperimentMFC me, const char32 *fileNameHead, const char32 *fileNameTail,
	double medialSilenceDuration, char32 **name, autoSound *sound)
{
	char32 fileNameBuffer [256], *fileNames = & fileNameBuffer [0];
	Melder_sprint (fileNameBuffer,256, *name);
	structMelderFile file = { 0 };
	/*
	 * The following conversion is needed when fileNameHead is an absolute path,
	 * and the stimulus names contain slashes for relative paths.
	 * An ugly case, but allowed.
	 */
	#if defined (_WIN32)
		for (;;) { char32 *slash = str32chr (fileNames, U'/'); if (! slash) break; *slash = U'\\'; }
	#endif
	sound->reset();
	char32 pathName [kMelder_MAXPATH+1];
	/*
	 * 'fileNames' can contain commas, which separate partial file names.
	 * The separate files should be concatenated.
	 */
	for (;;) {
		/*
		 * Determine partial file name.
		 */
		char32 *comma = str32chr (fileNames, U',');
		if (comma) *comma = '\0';
		/*
		 * Determine complete (relative) file name.
		 */
		Melder_sprint (pathName,kMelder_MAXPATH+1, fileNameHead, fileNames, fileNameTail);
		/*
		 * Make sure we are in the correct directory.
		 */
		if (MelderDir_isNull (& my rootDirectory)) {
			/*
			 * Absolute file name.
			 */
			Melder_pathToFile (pathName, & file);
		} else {
			/*
			 * Relative or absolute file name.
			 */
			MelderDir_relativePathToFile (& my rootDirectory, pathName, & file);
			if (Melder_debug == 32) {
				MelderInfo_open ();
				MelderInfo_writeLine (U"Path name <", pathName, U">");
				MelderInfo_writeLine (U"Root directory <", my rootDirectory.path, U">");
				MelderInfo_writeLine (U"Full path name <", file.path, U">");
				MelderInfo_close ();
			}
		}
		/*
		 * Read the substimulus.
		 */
		autoSound substimulus = Data_readFromFile (& file). static_cast_move<structSound>();
		if (substimulus -> classInfo != classSound)
			Melder_throw (U"File ", & file, U" contains a ", Thing_className (substimulus.get()), U" instead of a sound.");
		/*
		 * Check whether all sounds have the same number of channels.
		 */
		if (my numberOfChannels == 0) {
			my numberOfChannels = substimulus -> ny;
		} else if (substimulus -> ny != my numberOfChannels) {
			Melder_throw (U"The sound in file ", & file, U" has a different number of channels than some other sound.");
		}
		/*
		 * Check whether all sounds have the same sampling frequency.
		 */
		if (my samplePeriod == 0.0) {
			my samplePeriod = substimulus -> dx;   /* This must be the first sound read. */
		} else if (substimulus -> dx != my samplePeriod) {
			Melder_throw (U"The sound in file ", & file, U" has a different sampling frequency than some other sound.");
		}
		/*
		 * Append the substimuli, perhaps with silent intervals.
		 */
		if (*sound) {
			*sound = Sounds_append (sound->get(), medialSilenceDuration, substimulus.get());
		} else {
			*sound = substimulus.move();
		}
		/*
		 * Cycle.
		 */
		if (! comma) break;
		fileNames = & comma [1];
	}
}
Ejemplo n.º 17
0
void structManual :: v_draw () {
	ManPages manPages = (ManPages) our data;
	ManPage page;
	ManPage_Paragraph paragraph;
	#if motif
	Graphics_clearWs (our graphics.get());
	#endif
	if (our path == SEARCH_PAGE) {
		HyperPage_pageTitle (this, U"Best matches");
		HyperPage_intro (this, U"The best matches to your query seem to be:");
		for (int i = 1; i <= our numberOfMatches; i ++) {
			char32 link [300];
			page = manPages -> pages.at [matches [i]];
			Melder_sprint (link,300, U"• @@", page -> title);
			HyperPage_listItem (this, link);
		}
		return;
	}
	page = manPages -> pages.at [path];
	if (! our paragraphs) return;
	HyperPage_pageTitle (this, page -> title);
	for (paragraph = & page -> paragraphs [0]; paragraph -> type != 0; paragraph ++) {
		switch (paragraph -> type) {
			case  kManPage_type_INTRO: HyperPage_intro (this, paragraph -> text); break;
			case  kManPage_type_ENTRY: HyperPage_entry (this, paragraph -> text); break;
			case  kManPage_type_NORMAL: HyperPage_paragraph (this, paragraph -> text); break;
			case  kManPage_type_LIST_ITEM: HyperPage_listItem (this, paragraph -> text); break;
			case  kManPage_type_TAG: HyperPage_listTag (this, paragraph -> text); break;
			case  kManPage_type_DEFINITION: HyperPage_definition (this, paragraph -> text); break;
			case  kManPage_type_CODE: HyperPage_code (this, paragraph -> text); break;
			case  kManPage_type_PROTOTYPE: HyperPage_prototype (this, paragraph -> text); break;
			case  kManPage_type_FORMULA: HyperPage_formula (this, paragraph -> text); break;
			case  kManPage_type_PICTURE: HyperPage_picture (this, paragraph -> width,
				paragraph -> height, paragraph -> draw); break;
			case  kManPage_type_SCRIPT: HyperPage_script (this, paragraph -> width,
				paragraph -> height, paragraph -> text); break;
			case  kManPage_type_LIST_ITEM1: HyperPage_listItem1 (this, paragraph -> text); break;
			case  kManPage_type_LIST_ITEM2: HyperPage_listItem2 (this, paragraph -> text); break;
			case  kManPage_type_LIST_ITEM3: HyperPage_listItem3 (this, paragraph -> text); break;
			case  kManPage_type_TAG1: HyperPage_listTag1 (this, paragraph -> text); break;
			case  kManPage_type_TAG2: HyperPage_listTag2 (this, paragraph -> text); break;
			case  kManPage_type_TAG3: HyperPage_listTag3 (this, paragraph -> text); break;
			case  kManPage_type_DEFINITION1: HyperPage_definition1 (this, paragraph -> text); break;
			case  kManPage_type_DEFINITION2: HyperPage_definition2 (this, paragraph -> text); break;
			case  kManPage_type_DEFINITION3: HyperPage_definition3 (this, paragraph -> text); break;
			case  kManPage_type_CODE1: HyperPage_code1 (this, paragraph -> text); break;
			case  kManPage_type_CODE2: HyperPage_code2 (this, paragraph -> text); break;
			case  kManPage_type_CODE3: HyperPage_code3 (this, paragraph -> text); break;
			case  kManPage_type_CODE4: HyperPage_code4 (this, paragraph -> text); break;
			case  kManPage_type_CODE5: HyperPage_code5 (this, paragraph -> text); break;
			default: break;
		}
	}
	if (ManPages_uniqueLinksHither (manPages, our path)) {
		long ilink, jlink, lastParagraph = 0;
		bool goAhead = true;
		while (page -> paragraphs [lastParagraph]. type != 0) lastParagraph ++;
		if (lastParagraph > 0) {
			const char32 *text = page -> paragraphs [lastParagraph - 1]. text;
			if (! text || text [0] == U'\0' || text [str32len (text) - 1] != U':') {
				if (our printing && our suppressLinksHither)
					goAhead = false;
				else
					HyperPage_entry (this, U"Links to this page");
			}
		}
		if (goAhead) for (ilink = 1; ilink <= page -> nlinksHither; ilink ++) {
			long link = page -> linksHither [ilink];
			bool alreadyShown = false;
			for (jlink = 1; jlink <= page -> nlinksThither; jlink ++)
				if (page -> linksThither [jlink] == link)
					alreadyShown = true;
			if (! alreadyShown) {
				const char32 *title = manPages -> pages.at [page -> linksHither [ilink]] -> title;
				char32 linkText [304];
				Melder_sprint (linkText, 304, U"@@", title, U"@");
				HyperPage_listItem (this, linkText);
			}
		}
	}
	if (! our printing && page -> date) {
		char32 signature [100];
		long date = page -> date;
		int imonth = date % 10000 / 100;
		if (imonth < 0 || imonth > 12) imonth = 0;
		Melder_sprint (signature,100,
			U"© ", str32equ (page -> author, U"ppgb") ? U"Paul Boersma" :
			       str32equ (page -> author, U"djmw") ? U"David Weenink" : page -> author,
			U", ", date % 100,
			U" ", month [imonth],
			U" ", date / 10000);
		HyperPage_any (this, U"", our p_font, our p_fontSize, 0, 0.0,
			0.0, 0.0, 0.1, 0.1, HyperPage_ADD_BORDER);
		HyperPage_any (this, signature, our p_font, our p_fontSize, Graphics_ITALIC, 0.0,
			0.03, 0.0, 0.1, 0.0, 0);
	}
}