Skip to content

Commit

Permalink
Add pline, textdur and meter tools.
Browse files Browse the repository at this point in the history
  • Loading branch information
craigsapp committed Sep 17, 2023
1 parent 9e633fb commit 24db155
Show file tree
Hide file tree
Showing 14 changed files with 3,793 additions and 12 deletions.
7 changes: 4 additions & 3 deletions bin/makeMinDistribution
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ sub createIncludeFile {
# HumdrumFileSet depends on Options and HumdrumFileStream classes:
$contents .= getMergeContents("$sourceDir/HumdrumFileSet.h");

my @tools = glob "$sourceDir/tool-*.h";
my @tools = sort glob "$sourceDir/tool-*.h";

foreach my $tool (@tools) {
$tool =~ s/^$sourceDir\///;
Expand Down Expand Up @@ -346,7 +346,7 @@ sub getMergeContents {

##############################
##
## getFiles -- Get a list of a files in a directory.
## getFiles -- Get a list of a files in a directory. Only allowing .cpp, .h, and .hpp files.
##

sub getFiles {
Expand All @@ -356,6 +356,7 @@ sub getFiles {
my @output2;
while (my $file = readdir(DIR)) {
next if $file =~ /^\./;
next if $file !~ /\.(h|hpp|cpp)$/;
next if -d "$dir/$file";
next if !-r "$dir/$file";
if ($file =~ /Convert/) {
Expand All @@ -367,7 +368,7 @@ sub getFiles {
}
@output = sort @output;
push(@output, @output2);
return sort @output;
return sort @output;
}


Expand Down
18 changes: 18 additions & 0 deletions cli/meter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Tue Sep 12 20:14:20 PDT 2023
// Last Modified: Tue Sep 12 20:14:22 PDT 2023
// Filename: meter.cpp
// URL: https://github.com/craigsapp/humlib/blob/master/cli/meter.cpp
// Syntax: C++11
// vim: ts=3 noexpandtab nowrap
//
// Description: Meter/beat extraction tool.
//

#include "humlib.h"

STREAM_INTERFACE(Tool_meter)



18 changes: 18 additions & 0 deletions cli/pline.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Sep 2 16:14:22 CEST 2023
// Last Modified: Mon Sep 4 11:39:35 CEST 2023
// Filename: pline.cpp
// URL: https://github.com/craigsapp/humlib/blob/master/cli/pline.cpp
// Syntax: C++11
// vim: ts=3 noexpandtab nowrap
//
// Description: Processing tool for poetic lines.
//

#include "humlib.h"

STREAM_INTERFACE(Tool_pline)



18 changes: 18 additions & 0 deletions cli/textdur.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Sep 2 16:14:22 CEST 2023
// Last Modified: Sat Sep 2 16:14:24 CEST 2023
// Filename: textdur.cpp
// URL: https://github.com/craigsapp/humlib/blob/master/cli/textdur.cpp
// Syntax: C++11
// vim: ts=3 noexpandtab nowrap
//
// Description: Calculate durations of **text/**sylbe syllables (including melismas).
//

#include "humlib.h"

STREAM_INTERFACE(Tool_textdur)



73 changes: 73 additions & 0 deletions include/tool-meter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sun Sep 10 00:29:24 PDT 2023
// Last Modified: Thu Sep 14 03:33:20 PDT 2023
// Filename: tool-meter.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/tool-meter.h
// Syntax: C++11; humlib
// vim: ts=3 noexpandtab
//
// Description: Meter/beat data extraction tool.
//

#ifndef _TOOL_METER_H
#define _TOOL_METER_H

#include "HumTool.h"
#include "HumdrumFile.h"

namespace hum {

// START_MERGE

class Tool_meter : public HumTool {

public:
Tool_meter (void);
~Tool_meter () {};

bool run (HumdrumFileSet& infiles);
bool run (HumdrumFile& infile);
bool run (const string& indata, std::ostream& out);
bool run (HumdrumFile& infile, std::ostream& out);


protected:
void initialize (void);
void processFile (HumdrumFile& infile);
void getMeterData (HumdrumFile& infile);
void processLine (HumdrumLine& line,
std::vector<HumNum>& curNum,
std::vector<HumNum>& curDen,
std::vector<HumNum>& curBeat,
std::vector<HumNum>& curBarTime);
void printMeterData (HumdrumFile& infile);
void printHumdrumLine (HumdrumLine& line, bool printLabels);
int printKernAndAnalysisSpine(HumdrumLine& line, int index, bool printLabels, bool forceInterpretation = false);
HumNum getHumNum (HTp token, const std::string& parameter);
std::string getHumNumString(HumNum input);
bool searchForLabels (HumdrumLine& line);
void printLabelLine (HumdrumLine& line);

private:
bool m_commaQ = false;
bool m_denominatorQ = false;
bool m_floatQ = false;
bool m_joinQ = false;
bool m_tsigQ = false;
bool m_nobeatQ = false;
bool m_nolabelQ = false;
bool m_numeratorQ = false;
bool m_restQ = false;
bool m_zeroQ = false;

};

// END_MERGE

} // end namespace hum

#endif /* _TOOL_METER_H */



61 changes: 61 additions & 0 deletions include/tool-pline.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Sep 2 11:58:11 CEST 2023
// Last Modified: Mon Sep 4 10:23:13 CEST 2023
// Filename: tool-pline.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/tool-pline.h
// Syntax: C++11; humlib
// vim: ts=3 noexpandtab
//
// Description: Poetic line processing tool.
//

#ifndef _TOOL_PLINE_H
#define _TOOL_PLINE_H

#include "HumTool.h"
#include "HumdrumFile.h"

namespace hum {

// START_MERGE

class Tool_pline : public HumTool {
public:
Tool_pline (void);
~Tool_pline () {};

bool run (HumdrumFileSet& infiles);
bool run (HumdrumFile& infile);
bool run (const string& indata, ostream& out);
bool run (HumdrumFile& infile, ostream& out);


protected:
void initialize (void);
void processFile (HumdrumFile& infile);
void getPlineInterpretations(HumdrumFile& infile, vector<HTp>& tokens);
void plineToColor (HumdrumFile& infile, vector<HTp>& tokens);
void markRests (HumdrumFile& infile);
void markSpineRests (HTp spineStop);
void fillLineInfo (HumdrumFile& infile, std::vector<std::vector<int>>& lineInfo);

private:
bool m_colorQ = false; // used with -c option
// bool m_overlapQ = false; // used with -o option

std::vector<std::string> m_colors;
std::vector<HTp> m_ptokens;
std::vector<std::vector<int>> m_lineInfo;


};

// END_MERGE

} // end namespace hum

#endif /* _TOOL_PLINE_H */



81 changes: 81 additions & 0 deletions include/tool-textdur.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Sep 2 11:58:11 CEST 2023
// Last Modified: Sat Sep 2 11:58:15 CEST 2023
// Filename: tool-textdur.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/tool-textdur.h
// Syntax: C++11; humlib
// vim: ts=3 noexpandtab
//
// Description: Calculate duration of text (lyrics). Either as **text or **sylba
//

#ifndef _TOOL_TEXTDUR_H
#define _TOOL_TEXTDUR_H

#include "HumTool.h"
#include "HumdrumFile.h"

namespace hum {

// START_MERGE

class Tool_textdur : public HumTool {
public:
Tool_textdur (void);
~Tool_textdur () {};

bool run (HumdrumFileSet& infiles);
bool run (HumdrumFile& infile);
bool run (const string& indata, ostream& out);
bool run (HumdrumFile& infile, ostream& out);


protected:
void initialize (void);
void processFile (HumdrumFile& infile);
void printMelismas (HumdrumFile& infile);
void printDurations (HumdrumFile& infile);
void getTextSpineStarts(HumdrumFile& infile, vector<HTp>& starts);
void processTextSpine (vector<HTp>& starts, int index);
int getMelisma (HTp tok1, HTp tok2);
HumNum getDuration (HTp tok1, HTp tok2);
HTp getTandemKernToken(HTp token);
void printInterleaved (HumdrumFile& infile);
void printInterleavedLine(HumdrumLine& line, vector<bool>& textTrack);
void printTokenAnalysis(HTp token);
void printAnalysis (void);
void printDurationAverage(void);
void printMelismaAverage(void);
void printHtmlContent (void);
void printMelismaHtmlHistogram(void);
void printMelismaHtmlHistogram(int index, int maxVal);
void printDurationHtmlHistogram(void);
void fillInstrumentNameInfo(void);
std::string getColumnName (HTp token);

private:
std::vector<HTp> m_textStarts;
std::vector<int> m_track2column;
std::vector<string> m_columnName;

std::vector<std::vector<HTp>> m_syllables; // List of syllables in **text/**sylba
std::vector<std::vector<HumNum>> m_durations; // List of durations excluding trailing rests
std::vector<std::vector<int>> m_melismas; // List of note counts for syllable

bool m_analysisQ = false; // used with -a option
bool m_melismaQ = false; // used with -m option
bool m_durationQ = true; // used with -m, -d option
bool m_interleaveQ = false; // used with -i option
HumNum m_RhythmFactor = 1; // uwed with -1, -2, -8, and later -f #

};

// END_MERGE

} // end namespace hum

#endif /* _TOOL_TEXTDUR_H */



Loading

0 comments on commit 24db155

Please sign in to comment.