Skip to content

Commit

Permalink
address #3: change to 'dialog' type & use AccidentalType instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
euwbah committed Feb 20, 2023
1 parent 4b1dc93 commit 45f069b
Show file tree
Hide file tree
Showing 16 changed files with 116 additions and 56 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.4.0

- Attempt MuseScore 4 support.
- Changed 'dock' to 'dialog' type to support MuseScore 4.
- Remove dependency on old `PluginAPI::Ms`, using `Element.name` instead.
- Use `AccidentalType` when on MS4 instead of `Accidental`.
- Fix shortcuts breaking when plugin closed and reopened in plugin creator/MS 4.

## 0.3.2

- Huge performance improvements for tuning & up/down/enharmonic cycle for large scores
Expand Down
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ This is still a work in progress. Free for all to edit, and [in need of communit
- [Enharmonic equivalents aren't showing up / are incorrect](#enharmonic-equivalents-arent-showing-up--are-incorrect)
- [Keyboard shortcuts stop working](#keyboard-shortcuts-stop-working)
- [Reporting an issue](#reporting-an-issue)
- [Accessing plugin debug logs in MuseScore 3](#accessing-plugin-debug-logs-in-musescore-3)
- [Accessing plugin debug logs for MuseScore 4](#accessing-plugin-debug-logs-for-musescore-4)
- [HELP NEEDED!](#help-needed)
- [1. Testing on MS 4](#1-testing-on-ms-4)
- [2. Data entry of accidentals](#2-data-entry-of-accidentals)
Expand Down Expand Up @@ -1340,15 +1342,29 @@ If none of the above remedies work, you will need to [file an issue here](https:
- Operating system
- Example score
- Tuning config you were using
- Debug logs
- Stop running Xen Tuner (close plugin window/quit button).
- Open the **Plugin Creator** (Plugins > Plugin Creator).
- Open the `xen tuner.qml` file
- Run `xen tuner.qml` from the Plugin Creator.
- Repeat the action you did that caused the issue.
- Usually if an error occurs, you should be able to see the error message at the bottom of the log.
- Copy and paste as much of the debug log as you can, **including the error message** at the bottom.
- If you stopped the plugin/modified source code in the Plugin Creator, you will need to restart MuseScore to get the plugin working again.
- **Debug logs**

### Accessing plugin debug logs in MuseScore 3

- Stop running Xen Tuner (close plugin window/quit button).
- Open the **Plugin Creator** (Plugins > Plugin Creator).
- Open the `xen tuner.qml` file
- Run `xen tuner.qml` from the Plugin Creator.
- Repeat the action you did that caused the issue.
- Usually if an error occurs, you should be able to see the error message at the bottom of the log.
- Copy and paste as much of the debug log as you can, **including the error message** at the bottom.

### Accessing plugin debug logs for MuseScore 4

Logs created directly by the plugin aren't accessible anywhere in MuseScore 4 yet.

The best option would be to attach the `.log` files located at:

- **Windows**: `C:\Users\<name>\AppData\Local\MuseScore\MuseScore4\logs\`
- **MacOS**: `~/Library/Application Support/MuseScore/MuseScore4/logs/`
- **Linux**: `~/.local/share/data/MuseScore/MuseScore4/logs/`

if you're not on Windows, you can try running MuseScore from the command line/terminal to see if there's any output.

## HELP NEEDED!

Expand Down
8 changes: 5 additions & 3 deletions clear tuning cache.qml → Xen Tuner/clear tuning cache.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Qt.labs.settings 1.0
import FileIO 3.0

MuseScore {
version: "0.3.2"
version: "0.4.0"
description: "The tuning cache contains cached data about tunings used in the score.\n" +
"If you've experimented with many different tunings within a score, but aren't currently using most of them," +
"it is highly recommended to clear the Tuning Config cache."
Expand All @@ -52,10 +52,12 @@ MuseScore {
}

onRun: {
console.log('Xenharmonic Clear Tuning Cache');
console.log('Xen Tuner - Clear Tuning Cache');
// When you want to find which import has a syntax error, uncomment this line
// console.log(JSON.stringify(Fns));
Fns.init(Accidental, NoteType, SymId, Element, Ms, fileIO, Qt.resolvedUrl("."), curScore);
var isMS4 = mscoreMajorVersion >= 4;
Fns.init(isMS4 ? AccidentalType : Accidental, NoteType, SymId, Element,
fileIO, Qt.resolvedUrl("."), curScore, isMS4);
console.log(Qt.resolvedUrl("."));

if (typeof curScore === 'undefined')
Expand Down
9 changes: 5 additions & 4 deletions debug xen tuner.qml → Xen Tuner/debug xen tuner.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Qt.labs.settings 1.0
import FileIO 3.0

MuseScore {
version: "0.3.2"
version: "0.4.0"
description: "Debug Tune function.\n\n" +
"The docking Xen Tuner plugin is hard to debug as the shortcuts break everytime you re-run " +
"the plugin in the plugin creator. Use this instead to test functions without having to " +
Expand Down Expand Up @@ -61,11 +61,12 @@ MuseScore {
}

onRun: {
console.log('Started Xen Tuner');
console.log('Xen Tuner - Debug');
// When you want to find which import has a syntax error, uncomment this line
// console.log(JSON.stringify(Fns));
Fns.init(Accidental, NoteType, SymId, Element, Ms, fileIO, Qt.resolvedUrl("."), curScore);
console.log('present working dir: ' + Qt.resolvedUrl("."));
var isMS4 = mscoreMajorVersion >= 4;
Fns.init(isMS4 ? AccidentalType : Accidental, NoteType, SymId, Element,
fileIO, Qt.resolvedUrl("."), curScore, isMS4);

// Debug code here.
Fns.operationTune(); // test tune
Expand Down
6 changes: 4 additions & 2 deletions display cents.qml → Xen Tuner/display cents.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Qt.labs.settings 1.0
import FileIO 3.0

MuseScore {
version: "0.3.2"
version: "0.4.0"
description: "Create fingerings to display cent offsets of notes.\n\n" +
"Applies to selection, or entire score if nothing is selected."
menuPath: "Plugins.Xen Tuner.Display Cents"
Expand Down Expand Up @@ -60,7 +60,9 @@ MuseScore {

onRun: {
console.log('Xen Tuner - Display Cents');
Fns.init(Accidental, NoteType, SymId, Element, Ms, fileIO, Qt.resolvedUrl("."), curScore);
var isMS4 = mscoreMajorVersion >= 4;
Fns.init(isMS4 ? AccidentalType : Accidental, NoteType, SymId, Element,
fileIO, Qt.resolvedUrl("."), curScore, isMS4);

Fns.operationTune(1);
}
Expand Down
6 changes: 4 additions & 2 deletions display steps.qml → Xen Tuner/display steps.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Qt.labs.settings 1.0
import FileIO 3.0

MuseScore {
version: "0.3.2"
version: "0.4.0"
description: "Create fingerings to display edo/neji-steps of notes relative to the reference note.\n\n" +
"Applies to selection, or entire score if nothing is selected."
menuPath: "Plugins.Xen Tuner.Display Steps"
Expand Down Expand Up @@ -60,7 +60,9 @@ MuseScore {

onRun: {
console.log('Xen Tuner - Display Steps');
Fns.init(Accidental, NoteType, SymId, Element, Ms, fileIO, Qt.resolvedUrl("."), curScore);
var isMS4 = mscoreMajorVersion >= 4;
Fns.init(isMS4 ? AccidentalType : Accidental, NoteType, SymId, Element,
fileIO, Qt.resolvedUrl("."), curScore, isMS4);

Fns.operationTune(2);
}
Expand Down
8 changes: 5 additions & 3 deletions export midi csv.qml → Xen Tuner/export midi csv.qml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import QtQuick.Dialogs 1.1
import FileIO 3.0

MuseScore {
version: "0.3.2"
version: "0.4.0"
description: "Tunes & export the entire score/selection as a midi.csv file. Feed the generated text file into the text-to-midi.py "
+ "script to generate one MPE midi file per staff."
menuPath: "Plugins.Xen Tuner.Export MIDI CSV"
Expand Down Expand Up @@ -64,7 +64,9 @@ MuseScore {
console.log('Xenharmonic Export MIDI CSV');
// When you want to find which import has a syntax error, uncomment this line
// console.log(JSON.stringify(Fns));
Fns.init(Accidental, NoteType, SymId, Element, Ms, fileIO, Qt.resolvedUrl("."), curScore);
var isMS4 = mscoreMajorVersion >= 4;
Fns.init(isMS4 ? AccidentalType : Accidental, NoteType, SymId, Element,
fileIO, Qt.resolvedUrl("."), curScore, isMS4);
console.log(Qt.resolvedUrl("."));


Expand Down Expand Up @@ -271,7 +273,7 @@ MuseScore {
// Tune the note!

if (cursor.element) {
if (cursor.element.type == Ms.CHORD) {
if (cursor.element.name == "Chord") {
var graceChords = cursor.element.graceNotes;
for (var i = 0; i < graceChords.length; i++) {
// iterate through all grace chords
Expand Down
26 changes: 15 additions & 11 deletions fns.js → Xen Tuner/fns.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

var Lookup = ImportLookup();

var isMS4; // init sets this to true if MuseScore 4 is detected.

/**
* During init, this will be assigned to the MuseScore plugin API `Accidental` enum.
* If {@link isMS4}, this will be assigned to `mu::plugins::api::enums::AccidentalType`,
* otherwise, it will be `MS::PluginAPI::Accidental` for MuseScore 3.
*/
var Accidental = null;
var NoteType = null;
var Element = null;
var Ms = null;
var SymId = null; // WARNING: SymId has a long loading time.
/** @type {FileIO} */
var fileIO;
Expand Down Expand Up @@ -323,17 +325,17 @@ function generateDefaultTuningConfig() {
* @param {*} MSAccidental Accidental enum from MuseScore plugin API.
* @param {*} MSNoteType NoteType enum from MuseScore plugin API.
*/
function init(MSAccidental, MSNoteType, MSSymId, MSElement, MSMs, MSFileIO, homePath, MSCurScore) {
function init(MSAccidental, MSNoteType, MSSymId, MSElement, MSFileIO, homePath, MSCurScore, _isMS4) {
Lookup = ImportLookup();
// console.log(JSON.stringify(Lookup));
Accidental = MSAccidental;
SymId = MSSymId;
NoteType = MSNoteType;
Ms = MSMs;
Element = MSElement;
fileIO = MSFileIO;
pluginHomePath = homePath;
_curScore = MSCurScore;
isMS4 = _isMS4;
console.log("Initialized! Enharmonic eqv: " + ENHARMONIC_EQUIVALENT_THRESHOLD + " cents");
}

Expand Down Expand Up @@ -3625,7 +3627,7 @@ function readBarState(tickOfThisBar, tickOfNextBar, cursor) {
setCursorToPosition(cursor, tickOfThisBar, voice, ogCursorPos.staffIdx);

while (cursor.segment && cursor.tick < tickOfNextBar) {
if (cursor.element && cursor.element.type == Ms.CHORD) {
if (cursor.element && cursor.element.name == "Chord") {
var notes = cursor.element.notes;
var graceChords = cursor.element.graceNotes;
var currTick = cursor.tick;
Expand Down Expand Up @@ -4598,7 +4600,7 @@ function forceExplicitAccidentalsAfterNote(
while (cursor.segment && (cursor.tick < tickOfNextBar || tickOfNextBar == -1)) {
// console.log('cursor.tick: ' + cursor.tick + ', tickOfNextBar: ' + tickOfNextBar);

if (!(cursor.element && cursor.element.type == Ms.CHORD)) {
if (!(cursor.element && cursor.element.name == "Chord")) {
cursor.next();
continue;
}
Expand Down Expand Up @@ -5059,7 +5061,7 @@ function partitionChords(tickOfThisBar, tickOfNextBar, cursor) {
setCursorToPosition(cursor, tickOfThisBar, voice, ogCursorPos.staffIdx);

while (cursor.segment && cursor.tick < tickOfNextBar) {
if (cursor.element && cursor.element.type == Ms.CHORD) {
if (cursor.element && cursor.element.name == "Chord") {
var notes = cursor.element.notes;
var graceChords = cursor.element.graceNotes;
var currTick = cursor.tick;
Expand Down Expand Up @@ -5523,7 +5525,9 @@ function autoPositionAccidentals(startTick, endTick, parms, cursor, firstBarTick
// '\nTicks found: ' + ticks.join(', '));

ticks.forEach(function (tick) {
// the Chords object
/**
* @type {Chords}
*/
var chords = chordsByTick[tick];

// One vert stack = all chords at a tick that should be
Expand Down Expand Up @@ -5574,7 +5578,7 @@ function autoPositionAccidentals(startTick, endTick, parms, cursor, firstBarTick
continue;
}

if (chdElement.parent.type != Ms.CHORD) {
if (chdElement.parent.name != "Chord") {
console.error("ERROR: parent of note object isn't a chord??");
continue;
}
Expand Down Expand Up @@ -5966,7 +5970,7 @@ function operationTune(display) {
// Tune the note!

if (cursor.element) {
if (cursor.element.type == Ms.CHORD) {
if (cursor.element.name == "Chord") {
var graceChords = cursor.element.graceNotes;
for (var i = 0; i < graceChords.length; i++) {
// iterate through all grace chords
Expand Down Expand Up @@ -6293,7 +6297,7 @@ function operationTranspose(stepwiseDirection, stepwiseAux) {
}

if (cursor.element) {
if (cursor.element.type == Ms.CHORD) {
if (cursor.element.name == "Chord") {
var graceChords = cursor.element.graceNotes;
for (var i = 0; i < graceChords.length; i++) {
// iterate through all grace chords
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 45f069b

Please sign in to comment.