Skip to content

Commit

Permalink
Merge github.com:praat/praat
Browse files Browse the repository at this point in the history
  • Loading branch information
davidweenink committed Nov 19, 2024
2 parents 1b78935 + 563bd68 commit fb39be0
Show file tree
Hide file tree
Showing 70 changed files with 1,157 additions and 634 deletions.
10 changes: 5 additions & 5 deletions dwsys/FileInMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ autoFileInMemory FileInMemory_create (MelderFile file) {
const integer length = MelderFile_length (file);

autoFileInMemory me = Thing_new (FileInMemory);
my string = Melder_dup (file -> path);
my string = Melder_dup (MelderFile_peekPath (file));
my d_numberOfBytes = length;
my _dontOwnData = false;
my d_data = newvectorzero <byte> (my d_numberOfBytes + 1); // includes room for a final null byte in case the file happens to contain only text
Expand All @@ -68,7 +68,7 @@ autoFileInMemory FileInMemory_create (MelderFile file) {
MelderFile_close (file);
return me;
} catch (MelderError) {
Melder_throw (U"FileInMemory not created from \"", Melder_fileToPath (file), U"\".");
Melder_throw (U"FileInMemory not created from file ", file, U".");
}
}

Expand Down Expand Up @@ -828,15 +828,15 @@ static void testOneFile (
Full paths should not work:
*/
MelderInfo_writeLine (U"Testing fopen...");
MelderInfo_writeLine (U"\tTrying to open file-in-memory via full path:\n\t\t\"", theTestFile. path, U"\"...");
theTestFim = FileInMemorySet_fopen (theTestFileInMemorySet.get(), Melder_peek32to8_fileSystem (theTestFile. path), "rb");
MelderInfo_writeLine (U"\tTrying to open file-in-memory via full path:\n\t\t\"", MelderFile_peekPath (& theTestFile), U"\"...");
theTestFim = FileInMemorySet_fopen (theTestFileInMemorySet.get(), MelderFile_peekPath8 (& theTestFile), "rb");
Melder_require (theTestFim == nullptr,
U"FileInMemory should have been null.");
/*
If the returned file is NULL, errno should contain a relevant message.
*/
Melder_require (errno == ENOENT,
U"It should have been reported that the file ", theTestFile. path, U" does not exist.");
U"It should have been reported that the file ", & theTestFile, U" does not exist.");
MelderInfo_writeLine (U"\t\t\t... not opened");
/*
Raw file names should not work:
Expand Down
4 changes: 2 additions & 2 deletions dwtools/LongSound_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ static void MelderFile_truncate (MelderFile me, integer size) {
CloseHandle (hFile);
#elif defined (linux) || defined (macintosh)
MelderFile_close (me);
const int succes = truncate (Melder_peek32to8_fileSystem (my path), size);
Melder_require (succes == 0,
const int success = truncate (Melder_peek32to8_fileSystem (my path), size);
Melder_require (success == 0,
U"Truncating failed for file ", me, U" (", Melder_peek8to32 (strerror (errno)), U").");
#else
Melder_throw (U"Don't know what to do.");
Expand Down
3 changes: 1 addition & 2 deletions dwtools/Sound_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,8 @@ autoSound Sound_readFromOggVorbisFile (MelderFile file) {

autoSound Sound_readFromOggOpusFile (MelderFile file) {
try {
conststring32 path = Melder_fileToPath (file);
int error;
OggOpusFile *opusFile = op_open_file (Melder_peek32to8_fileSystem (path), & error);
OggOpusFile *opusFile = op_open_file (MelderFile_peekPath8 (file), & error);
if (error != 0) {
if (error == OP_EREAD)
Melder_throw (U"Reading error.");
Expand Down
10 changes: 5 additions & 5 deletions dwtools/VowelEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static bool isValidVowelMarksTableFile (MelderFile file, autoTable *out_marks) {
autoDaata data = Data_readFromFile (file);
if (! Thing_isa (data.get(), classTable))
return false;
autoTable marks = data.static_cast_move <structTable> ();
autoTable marks = data.static_cast_move <structTable>();
/*
Require columns Vowel F1 and F2 to be present in the Table
*/
Expand Down Expand Up @@ -535,7 +535,7 @@ static void Table_addColumnIfNotExists_colour (Table me, conststring32 colour) {

static void VowelEditor_getVowelMarksFromFile (VowelEditor me) {
autoTable marks;
structMelderFile file = {};
structMelderFile file { };
Melder_pathToFile (my instancePref_marks_fileName(), & file);
if (! isValidVowelMarksTableFile (& file, & marks))
return;
Expand Down Expand Up @@ -920,8 +920,8 @@ static void menu_cb_vowelMarksFromTableFile (VowelEditor me, EDITOR_ARGS) {
EDITOR_FORM_READ (U"VowelEditor: Show vowel marks from Table file", U"VowelEditor: Show vowel marks from Table file...");
EDITOR_DO_READ
Melder_require (isValidVowelMarksTableFile (file, nullptr),
U"File '", Melder_fileToPath (file), U"' does not contain valid Table data.");
my setInstancePref_marks_fileName (Melder_fileToPath (file));
U"File ", file, U" does not contain valid Table data.");
my setInstancePref_marks_fileName (MelderFile_peekPath (file));
my setInstancePref_marks_speakerType (kVowelEditor_speakerType::UNKNOWN);
my setInstancePref_marks_dataSet (kVowelEditor_marksDataSet::OTHER);
VowelEditor_getVowelMarksFromFile (me);
Expand Down Expand Up @@ -1345,7 +1345,7 @@ void structVowelEditor :: v9_repairPreferences () {
our setInstancePref_marks_dataSet (our default_marks_dataSet());
our setInstancePref_marks_speakerType (our default_marks_speakerType());
} else {
structMelderFile file = {};
structMelderFile file { };
Melder_pathToFile (our instancePref_marks_fileName(), & file);
if (! isValidVowelMarksTableFile (& file, nullptr)) {
Melder_warning (U"The file '", our instancePref_marks_fileName(), U"' which was specified in your preferences "
Expand Down
4 changes: 2 additions & 2 deletions fon/AmplitudeTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* AmplitudeTier.cpp
*
* Copyright (C) 2003-2012,2014-2022 Paul Boersma
* Copyright (C) 2003-2012,2014-2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,7 +38,7 @@ void AmplitudeTier_draw (AmplitudeTier me, Graphics g, double tmin, double tmax,

autoAmplitudeTier PointProcess_upto_AmplitudeTier (PointProcess me, double soundPressure) {
try {
autoAmplitudeTier thee = PointProcess_upto_RealTier (me, soundPressure, classAmplitudeTier).static_cast_move<structAmplitudeTier>();
autoAmplitudeTier thee = PointProcess_upto_RealTier (me, soundPressure, classAmplitudeTier).static_cast_move <structAmplitudeTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to AmplitudeTier.");
Expand Down
6 changes: 3 additions & 3 deletions fon/ExperimentMFC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ static void readSound (ExperimentMFC me, conststring32 fileNameHead, conststring
if (Melder_debug == 32) {
MelderInfo_open ();
MelderInfo_writeLine (U"Path name <", pathName, U">");
MelderInfo_writeLine (U"Root folder <", my rootDirectory.path, U">");
MelderInfo_writeLine (U"Full path name <", file.path, U">");
MelderInfo_writeLine (U"Root folder <", MelderFolder_peekPath (& my rootDirectory), U">");
MelderInfo_writeLine (U"Full path name <", MelderFile_peekPath (& file), U">");
MelderInfo_close ();
}
}
/*
Read the substimulus.
*/
autoSound substimulus = Data_readFromFile (& file). static_cast_move<structSound>();
autoSound substimulus = Data_readFromFile (& file).static_cast_move <structSound>();
Melder_require (substimulus -> classInfo == classSound,
U"File ", & file, U" contains a ", Thing_className (substimulus.get()), U" instead of a sound.");
/*
Expand Down
10 changes: 5 additions & 5 deletions fon/IntensityTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* IntensityTier.cpp
*
* Copyright (C) 1992-2005,2007,2008,2010-2012,2015-2018,2020-2022 Paul Boersma
* Copyright (C) 1992-2005,2007,2008,2010-2012,2015-2018,2020-2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -38,7 +38,7 @@ void IntensityTier_draw (IntensityTier me, Graphics g, double tmin, double tmax,

autoIntensityTier PointProcess_upto_IntensityTier (PointProcess me, double intensity) {
try {
autoIntensityTier thee = PointProcess_upto_RealTier (me, intensity, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = PointProcess_upto_RealTier (me, intensity, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to IntensityTier.");
Expand All @@ -47,7 +47,7 @@ autoIntensityTier PointProcess_upto_IntensityTier (PointProcess me, double inten

autoIntensityTier Intensity_downto_IntensityTier (Intensity me) {
try {
autoIntensityTier thee = Vector_to_RealTier (me, 1, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = Vector_to_RealTier (me, 1, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to IntensityTier.");
Expand All @@ -56,7 +56,7 @@ autoIntensityTier Intensity_downto_IntensityTier (Intensity me) {

autoIntensityTier Intensity_to_IntensityTier_peaks (Intensity me) {
try {
autoIntensityTier thee = Vector_to_RealTier_peaks (me, 1, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = Vector_to_RealTier_peaks (me, 1, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": peaks not converted to IntensityTier.");
Expand All @@ -65,7 +65,7 @@ autoIntensityTier Intensity_to_IntensityTier_peaks (Intensity me) {

autoIntensityTier Intensity_to_IntensityTier_valleys (Intensity me) {
try {
autoIntensityTier thee = Vector_to_RealTier_valleys (me, 1, classIntensityTier).static_cast_move<structIntensityTier>();
autoIntensityTier thee = Vector_to_RealTier_valleys (me, 1, classIntensityTier).static_cast_move <structIntensityTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": valleys not converted to IntensityTier.");
Expand Down
2 changes: 1 addition & 1 deletion fon/LongSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void structLongSound :: v1_info () {
U"IEEE float 64 bit big-endian", U"IEEE float 64 bit little-endian",
U"FLAC", U"FLAC", U"FLAC", U"MP3", U"MP3", U"MP3" };
MelderInfo_writeLine (U"Duration: ", xmax - xmin, U" seconds");
MelderInfo_writeLine (U"File name: ", Melder_fileToPath (& file));
MelderInfo_writeLine (U"File name: ", MelderFile_peekPath (& file));
MelderInfo_writeLine (U"File type: ", audioFileType > Melder_NUMBER_OF_AUDIO_FILE_TYPES ? U"unknown" : Melder_audioFileTypeString (audioFileType));
MelderInfo_writeLine (U"Number of channels: ", numberOfChannels);
MelderInfo_writeLine (U"Encoding: ", encoding > 20 ? U"unknown" : encodingStrings [encoding]);
Expand Down
4 changes: 2 additions & 2 deletions fon/Ltas_to_SpectrumTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Ltas_to_SpectrumTier.cpp
*
* Copyright (C) 2007-2011,2015 Paul Boersma
* Copyright (C) 2007-2011,2015,2026,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -20,7 +20,7 @@

autoSpectrumTier Ltas_to_SpectrumTier_peaks (Ltas me) {
try {
autoSpectrumTier thee = Vector_to_RealTier_peaks (me, 1, classSpectrumTier).static_cast_move<structSpectrumTier>();
autoSpectrumTier thee = Vector_to_RealTier_peaks (me, 1, classSpectrumTier).static_cast_move <structSpectrumTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": peaks not analyzed as SpectrumTier.");
Expand Down
2 changes: 1 addition & 1 deletion fon/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ autoMatrix Matrix_readAP (MelderFile file) {

autoMatrix Matrix_appendRows (const constMatrix me, const constMatrix thee, ClassInfo klas) {
try {
autoMatrix him = Thing_newFromClass (klas).static_cast_move<structMatrix>();
autoMatrix him = Thing_newFromClass (klas).static_cast_move <structMatrix>();
Matrix_init (him.get(),
std::min (my xmin, thy xmin),
std::max (my xmax, thy xmax),
Expand Down
6 changes: 3 additions & 3 deletions fon/Movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ autoMovie Movie_openFromSoundFile (MelderFile file)
autoMovie me = Thing_new (Movie);
autoSound sound = Sound_readFromSoundFile (file);
autoMelderString fileNameHead;
MelderString_copy (& fileNameHead, Melder_fileToPath (file));
MelderString_copy (& fileNameHead, MelderFile_peekPath (file));
char32 *extensionLocation = str32rchr (fileNameHead.string, U'.');
if (! extensionLocation)
extensionLocation = & fileNameHead.string [fileNameHead.length];
Expand All @@ -74,7 +74,7 @@ autoMovie Movie_openFromSoundFile (MelderFile file)
autoStrings strings = Strings_createAsFileList (Melder_cat (fileNameHead.string, U"*.png"));
structMelderFolder folder { };
MelderFile_getParentFolder (file, & folder);
Movie_init (me.get(), sound.move(), Melder_folderToPath (& folder), strings.move());
Movie_init (me.get(), sound.move(), MelderFolder_peekPath (& folder), strings.move());
return me;
} catch (MelderError) {
Melder_throw (U"Movie object not read from file ", file, U".");
Expand All @@ -94,7 +94,7 @@ void Movie_paintOneImageInside (Movie me, Graphics graphics, integer frameNumber
Melder_pathToFolder (my d_folderName.get(), & folder);
structMelderFile file { };
MelderFolder_getFile (& folder, my d_fileNames -> strings [frameNumber].get(), & file);
Graphics_imageFromFile (graphics, Melder_fileToPath (& file), xmin, xmax, ymin, ymax);
Graphics_imageFromFile (graphics, MelderFile_peekPath (& file), xmin, xmax, ymin, ymax);
} catch (MelderError) {
Melder_throw (me, U": image ", frameNumber, U" not painted.");
}
Expand Down
16 changes: 7 additions & 9 deletions fon/Photo.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Photo.cpp
*
* Copyright (C) 2013-2023 Paul Boersma
* Copyright (C) 2013-2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -102,7 +102,7 @@ autoPhoto Photo_createSimple (integer numberOfRows, integer numberOfColumns) {
autoPhoto Photo_readFromImageFile (MelderFile file) {
try {
#if defined (linux) && ! defined (NO_GRAPHICS)
cairo_surface_t *surface = cairo_image_surface_create_from_png (Melder_peek32to8_fileSystem (file -> path));
cairo_surface_t *surface = cairo_image_surface_create_from_png (MelderFile_peekPath8 (file));
//if (cairo_surface_status)
// Melder_throw (U"Error opening PNG file.");
integer width = cairo_image_surface_get_width (surface);
Expand Down Expand Up @@ -142,7 +142,7 @@ autoPhoto Photo_readFromImageFile (MelderFile file) {
cairo_surface_destroy (surface);
return me;
#elif defined (_WIN32)
Gdiplus::Bitmap gdiplusBitmap (Melder_peek32toW_fileSystem (file -> path));
Gdiplus::Bitmap gdiplusBitmap (MelderFile_peekPathW (file));
integer width = gdiplusBitmap. GetWidth ();
integer height = gdiplusBitmap. GetHeight ();
if (width == 0 || height == 0)
Expand All @@ -161,9 +161,7 @@ autoPhoto Photo_readFromImageFile (MelderFile file) {
return me;
#elif defined (macintosh)
autoPhoto me;
CFStringRef path = CFStringCreateWithCString (nullptr, Melder_peek32to8_fileSystem (file -> path), kCFStringEncodingUTF8);
CFURLRef url = CFURLCreateWithFileSystemPath (nullptr, path, kCFURLPOSIXPathStyle, false);
CFRelease (path);
CFURLRef url = CFURLCreateWithFileSystemPath (nullptr, (CFStringRef) MelderFile_peekPathCfstring (file), kCFURLPOSIXPathStyle, false);
CGImageSourceRef imageSource = CGImageSourceCreateWithURL (url, nullptr);
CFRelease (url);
if (! imageSource)
Expand Down Expand Up @@ -236,7 +234,7 @@ autoPhoto Photo_readFromImageFile (MelderFile file) {
}
cairo_surface_t *surface = cairo_image_surface_create_for_data (imageData,
format, my nx, my ny, bytesPerRow);
cairo_surface_write_to_png (surface, Melder_peek32to8_fileSystem (file -> path));
cairo_surface_write_to_png (surface, MelderFile_peekPath8 (file));
cairo_surface_destroy (surface);
}
#endif
Expand Down Expand Up @@ -278,7 +276,7 @@ autoPhoto Photo_readFromImageFile (MelderFile file) {
encoderParameters. Parameter [0]. Value = & quality;
p = & encoderParameters;
}
gdiplusBitmap. Save (Melder_peek32toW_fileSystem (file -> path),
gdiplusBitmap. Save (MelderFile_peekPathW (file),
& imageEncoderInfos [iencoder]. Clsid, p);
Melder_free (imageEncoderInfos);
return;
Expand Down Expand Up @@ -317,7 +315,7 @@ autoPhoto Photo_readFromImageFile (MelderFile file) {
8, 32, integer_to_uinteger (bytesPerRow), colourSpace, kCGImageAlphaNone, dataProvider, nullptr, false, kCGRenderingIntentDefault);
CGDataProviderRelease (dataProvider);
Melder_assert (image);
NSString *path = (NSString *) Melder_peek32toCfstring (Melder_fileToPath (file));
NSString *path = (NSString *) MelderFile_peekPathCfstring (file);
CFURLRef url = (CFURLRef) [NSURL fileURLWithPath: path isDirectory: NO];
CGImageDestinationRef destination = CGImageDestinationCreateWithURL (url, (CFStringRef) which, 1, nullptr);
CGImageDestinationAddImage (destination, image, nil);
Expand Down
4 changes: 2 additions & 2 deletions fon/PitchTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* PitchTier.cpp
*
* Copyright (C) 1992-2008,2010-2013,2015-2018,2021,2022 Paul Boersma
* Copyright (C) 1992-2008,2010-2013,2015-2018,2021,2022,2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -49,7 +49,7 @@ void PitchTier_draw (PitchTier me, Graphics g, double tmin, double tmax,

autoPitchTier PointProcess_upto_PitchTier (PointProcess me, double frequency) {
try {
autoPitchTier thee = PointProcess_upto_RealTier (me, frequency, classPitchTier).static_cast_move<structPitchTier>();
autoPitchTier thee = PointProcess_upto_RealTier (me, frequency, classPitchTier).static_cast_move <structPitchTier>();
return thee;
} catch (MelderError) {
Melder_throw (me, U": not converted to PitchTier.");
Expand Down
6 changes: 3 additions & 3 deletions fon/RealTier.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* RealTier.cpp
*
* Copyright (C) 1992-2012,2014-2023 Paul Boersma
* Copyright (C) 1992-2012,2014-2024 Paul Boersma
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -85,7 +85,7 @@ autoRealTier RealTier_create (double tmin, double tmax) {

autoRealTier RealTier_createWithClass (double tmin, double tmax, ClassInfo klas) {
try {
autoRealTier me = Thing_newFromClass (klas).static_cast_move <structRealTier> ();
autoRealTier me = Thing_newFromClass (klas).static_cast_move <structRealTier>();
RealTier_init (me.get(), tmin, tmax);
return me;
} catch (MelderError) {
Expand All @@ -99,7 +99,7 @@ template <typename T> autoSomeThing <T> Thing_create () {

template <>
autoSomeThing <structRealTier> Thing_create <structRealTier> () {
return Thing_newFromClass (classRealTier). static_cast_move<structRealTier>();
return Thing_newFromClass (classRealTier).static_cast_move <structRealTier>();
}

template <typename structSomeRealTier>
Expand Down
Loading

0 comments on commit fb39be0

Please sign in to comment.