Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[myank] Add -l flag to select line range and improve cutting null tokens #55

Merged
merged 23 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
09f499f
Basic implementation to enable line yank
WolfgangDrescher Dec 15, 2022
b9256e1
Fix indentation
WolfgangDrescher Dec 15, 2022
693ed16
Merge branch 'master' into myank
WolfgangDrescher Jan 24, 2023
8a35e6b
Add space between keyword and brackets
WolfgangDrescher Jan 24, 2023
0ed6ca9
Add `m_` prefix for member variables
WolfgangDrescher Jan 24, 2023
ebb5377
Use HumRegex
WolfgangDrescher Jan 24, 2023
eae2be6
Indentation
WolfgangDrescher Jan 24, 2023
de92b3c
Add line-range as long name for -l
WolfgangDrescher Jan 24, 2023
d792927
Add comments and improve method names
WolfgangDrescher Jan 24, 2023
f09a979
Add helper function to get duration from start and remaining duration…
WolfgangDrescher Jan 24, 2023
d024d03
Improve cutting sustained notes
WolfgangDrescher Jan 24, 2023
1fd549e
Update humlib.h and humlib.cpp
WolfgangDrescher Jan 24, 2023
47ff6c5
Disallow unreasonable line numbers
WolfgangDrescher Jan 25, 2023
12fc4b3
Remove bar line at end if in the middle of a bar
WolfgangDrescher Jan 25, 2023
ab079a0
Use isData
WolfgangDrescher Jan 25, 2023
ebec910
Add bar numbers when section starts at beginning of a bar
WolfgangDrescher Jan 25, 2023
a3a80f4
Update humlib.h and humlib.cpp
WolfgangDrescher Jan 25, 2023
3fc4f16
Fix adjustGlobalInterpretations when line is a global comment
WolfgangDrescher Jan 25, 2023
d5f8258
Add --hide-starting and --hide-ending options
WolfgangDrescher Jan 26, 2023
7bd1c08
Alway include !!!RDF reference records in starting and ending section
WolfgangDrescher Feb 7, 2023
c843e92
Limit createLineFromTokens for current line
WolfgangDrescher Feb 7, 2023
207f63d
Merge branch 'master' into myank
WolfgangDrescher Feb 7, 2023
a1eda08
Format long lines
WolfgangDrescher Feb 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/HumdrumToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ class HumdrumToken : public std::string, public HumHash {
HumNum getDurationToEnd (void);
HumNum getDurationToEnd (HumNum scale);

HumNum getDurationFromNoteStart (void);
HumNum getDurationFromNoteStart (HumNum scale);

HumNum getDurationToNoteEnd (void);
HumNum getDurationToNoteEnd (HumNum scale);

HumNum getDurationFromBarline (void);
HumNum getDurationFromBarline (HumNum scale);

Expand Down
55 changes: 36 additions & 19 deletions include/humlib.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Sat Aug 8 12:24:49 PDT 2015
// Last Modified: Thu Jan 26 22:41:11 PST 2023
// Last Modified: Di 7 Feb 2023 18:58:16 CET
// Filename: humlib.h
// URL: https://github.com/craigsapp/humlib/blob/master/include/humlib.h
// Syntax: C++11
Expand Down Expand Up @@ -1619,6 +1619,12 @@ class HumdrumToken : public std::string, public HumHash {
HumNum getDurationToEnd (void);
HumNum getDurationToEnd (HumNum scale);

HumNum getDurationFromNoteStart (void);
HumNum getDurationFromNoteStart (HumNum scale);

HumNum getDurationToNoteEnd (void);
HumNum getDurationToNoteEnd (HumNum scale);

HumNum getDurationFromBarline (void);
HumNum getDurationFromBarline (HumNum scale);

Expand Down Expand Up @@ -9173,25 +9179,36 @@ class Tool_myank : public HumTool {
void printMeasureStart (HumdrumFile& infile, int line, const string& style);
std::string expandMultipliers (const string& inputstring);

vector<int> analyzeBarNumbers (HumdrumFile& infile);
int getBarNumberForLineNumber(int lineNumber);
int getStartLineNumber (void);
int getEndLineNumber (void);
void printDataLine (HLp line, bool& startLineHandled, const vector<int>& lastLineResolvedTokenLineIndex, const vector<HumNum>& lastLineDurationsFromNoteStart);

private:
int debugQ = 0; // used with --debug option
// int inputlist = 0; // used with --inlist option
int inlistQ = 0; // used with --inlist option
int outlistQ = 0; // used with --outlist option
int verboseQ = 0; // used with -v option
int invisibleQ = 1; // used with --visible option
int maxQ = 0; // used with --max option
int minQ = 0; // used with --min option
int instrumentQ = 0; // used with -I option
int nolastbarQ = 0; // used with -B option
int markQ = 0; // used with --mark option
int doubleQ = 0; // used with --mdsep option
int barnumtextQ = 0; // used with -T option
int Section = 0; // used with --section option
int sectionCountQ = 0; // used with --section-count option
vector<MeasureInfo> MeasureOutList; // used with -m option
vector<MeasureInfo> MeasureInList; // used with -m option
vector<vector<MyCoord> > metstates;
int m_debugQ = 0; // used with --debug option
// int inputlist = 0; // used with --inlist option
int m_inlistQ = 0; // used with --inlist option
int m_outlistQ = 0; // used with --outlist option
int m_verboseQ = 0; // used with -v option
int m_invisibleQ = 1; // used with --visible option
int m_maxQ = 0; // used with --max option
int m_minQ = 0; // used with --min option
int m_instrumentQ = 0; // used with -I option
int m_nolastbarQ = 0; // used with -B option
int m_markQ = 0; // used with --mark option
int m_doubleQ = 0; // used with --mdsep option
int m_barnumtextQ = 0; // used with -T option
int m_section = 0; // used with --section option
int m_sectionCountQ = 0; // used with --section-count option
vector<MeasureInfo> m_measureOutList; // used with -m option
vector<MeasureInfo> m_measureInList; // used with -m option
vector<vector<MyCoord> > m_metstates;

string m_lineRange; // used with -l option
vector<int> m_barNumbersPerLine; // used with -l option
bool m_hideStarting; // used with --hide-starting option
bool m_hideEnding; // used with --hide-ending option

};

Expand Down
47 changes: 29 additions & 18 deletions include/tool-myank.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,25 +155,36 @@ class Tool_myank : public HumTool {
void printMeasureStart (HumdrumFile& infile, int line, const string& style);
std::string expandMultipliers (const string& inputstring);

vector<int> analyzeBarNumbers (HumdrumFile& infile);
int getBarNumberForLineNumber(int lineNumber);
int getStartLineNumber (void);
int getEndLineNumber (void);
void printDataLine (HLp line, bool& startLineHandled, const vector<int>& lastLineResolvedTokenLineIndex, const vector<HumNum>& lastLineDurationsFromNoteStart);

private:
int debugQ = 0; // used with --debug option
// int inputlist = 0; // used with --inlist option
int inlistQ = 0; // used with --inlist option
int outlistQ = 0; // used with --outlist option
int verboseQ = 0; // used with -v option
int invisibleQ = 1; // used with --visible option
int maxQ = 0; // used with --max option
int minQ = 0; // used with --min option
int instrumentQ = 0; // used with -I option
int nolastbarQ = 0; // used with -B option
int markQ = 0; // used with --mark option
int doubleQ = 0; // used with --mdsep option
int barnumtextQ = 0; // used with -T option
int Section = 0; // used with --section option
int sectionCountQ = 0; // used with --section-count option
vector<MeasureInfo> MeasureOutList; // used with -m option
vector<MeasureInfo> MeasureInList; // used with -m option
vector<vector<MyCoord> > metstates;
int m_debugQ = 0; // used with --debug option
// int inputlist = 0; // used with --inlist option
int m_inlistQ = 0; // used with --inlist option
int m_outlistQ = 0; // used with --outlist option
int m_verboseQ = 0; // used with -v option
int m_invisibleQ = 1; // used with --visible option
int m_maxQ = 0; // used with --max option
int m_minQ = 0; // used with --min option
int m_instrumentQ = 0; // used with -I option
int m_nolastbarQ = 0; // used with -B option
int m_markQ = 0; // used with --mark option
int m_doubleQ = 0; // used with --mdsep option
int m_barnumtextQ = 0; // used with -T option
int m_section = 0; // used with --section option
int m_sectionCountQ = 0; // used with --section-count option
vector<MeasureInfo> m_measureOutList; // used with -m option
vector<MeasureInfo> m_measureInList; // used with -m option
vector<vector<MyCoord> > m_metstates;

string m_lineRange; // used with -l option
vector<int> m_barNumbersPerLine; // used with -l option
bool m_hideStarting; // used with --hide-starting option
bool m_hideEnding; // used with --hide-ending option

};

Expand Down
46 changes: 46 additions & 0 deletions src/HumdrumToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,52 @@ HumNum HumdrumToken::getDurationToEnd(HumNum scale) {



//////////////////////////////
//
// HumdrumToken::getDurationFromNoteStart -- Returns the duration from the start
// of the resolved HumdrumToken to the starting time of this token. This is
// useful to get the pased duration of a null token.
//

HumNum HumdrumToken::getDurationFromNoteStart(void) {
HumNum dur = HumNum();
HTp resolvedToken = this->resolveNull();
HumdrumFile* infile = getLine()->getOwner();
int startLineIndex = resolvedToken->getLineIndex();
int thisLineIndex = getLineIndex();
for (int i = startLineIndex; i < thisLineIndex; i++) {
dur += infile->getLine(i)->getDuration();
}
// TODO handle tied notes
return dur;
}


HumNum HumdrumToken::getDurationFromNoteStart(HumNum scale) {
return this->getDurationFromNoteStart() * scale;
}



//////////////////////////////
//
// HumdrumToken::getDurationToNoteEnd -- Returns the duration from this token to
// the end of the resolved HumdrumToken duration. This is useful to get the
// remaining duration of a null token.
//

HumNum HumdrumToken::getDurationToNoteEnd(void) {
// TODO handle tied notes
return this->resolveNull()->getDuration() - getDurationFromNoteStart();
}


HumNum HumdrumToken::getDurationToNoteEnd(HumNum scale) {
return this->getDurationToNoteEnd() * scale;
}



//////////////////////////////
//
// HumdrumToken::getBarlineDuration -- Returns the duration between
Expand Down
Loading