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

Test Github Actions (Step 2) #2

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 17 additions & 7 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,24 @@ defaults:

jobs:
build_plugin:
name: PR - ${{ matrix.os }}
name: PR - ${{ matrix.name }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
- os: macos-latest
- os: ubuntu-latest
- name: windows x64
os: windows-latest

- name: windows arm64ec
os: windows-latest
cmakeConfig: -G"Visual Studio 17 2022" -A arm64ec -DCMAKE_SYSTEM_VERSION=10

- name: macOS
os: macos-latest
cmakeConfig: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"

- name: Linux
os: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -29,7 +39,7 @@ jobs:

- name: Build pull request version
run: |
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Debug
cmake -S . -B ./build ${{ matrix.cmakeConfig }} -DCMAKE_BUILD_TYPE=Debug -DJI_LATTICE_COPY_AFTER_BUILD=FALSE
cmake --build ./build --config Debug --target ji-lattice-plugin-installer --parallel 3

build_plugin_lindoc:
Expand All @@ -47,9 +57,9 @@ jobs:
image: ghcr.io/surge-synthesizer/sst-dockerimages/ubuntu20_gcc11:main
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
cmakeArgs: -DCMAKE_BUILD_TYPE=Debug -GNinja
cmakeArgs: -DCMAKE_BUILD_TYPE=Debug -GNinja -DJI_LATTICE_COPY_AFTER_BUILD=FALSE
target: ji-lattice-plugin-installer

- name: Confirm Build
run: |
ls -l build/monique_products
ls -l build/
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.15)

message(STATUS "Building ji-lattice-plugin")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14 CACHE STRING "Build for 10.14")

project(ji-lattice-plugin VERSION 0.3.0)
Expand All @@ -8,6 +9,8 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

option(JI_LATTICE_COPY_AFTER_BUILD "Copy the plugin after build" TRUE)

include (cmake/CPM.cmake)

CPMAddPackage("gh:juce-framework/JUCE#8.0.4")
Expand All @@ -26,7 +29,7 @@ juce_add_plugin(${PROJECT_NAME}

FORMATS AU VST3 Standalone

COPY_PLUGIN_AFTER_BUILD TRUE
COPY_PLUGIN_AFTER_BUILD ${JI_LATTICE_COPY_AFTER_BUILD}
)

juce_add_binary_data(lattices-binary
Expand Down
146 changes: 71 additions & 75 deletions src/JIMath.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
Lattices - A Just-Intonation graphical MTS-ESP Source

Copyright 2023-2024 Andreya Ek Frisk and Paul Walker.

This code is released under the MIT licence, but do note that it depends
on the JUCE library, see licence for more details.

Source available at https://github.com/Andreya-Autumn/lattices
*/

Expand All @@ -24,24 +24,23 @@ struct JIMath
: horizNum(horizN), horizDen(horizD), diagNum(diagN), diagDen(horizD)
{
}

static constexpr int limit = 9;
typedef int monzo[limit];

static constexpr int primes[limit] = {2, 3, 5, 7, 11, 13, 17, 19, 23};
static constexpr std::pair<uint64_t, uint64_t> Commas[limit] =
{
{531441, 524288}, // 3
{80, 81}, // 5
{125, 128}, // 5
{64, 63}, // 7
{32, 33}, // 11
{1024, 1053}, // 13
{2176, 2187}, // 17
{512, 513}, // 19
{736, 729}, // 23
}; // same size as limit because there are two 5-limit commas

static constexpr std::pair<uint64_t, uint64_t> Commas[limit] = {
{531441, 524288}, // 3
{80, 81}, // 5
{125, 128}, // 5
{64, 63}, // 7
{32, 33}, // 11
{1024, 1053}, // 13
{2176, 2187}, // 17
{512, 513}, // 19
{736, 729}, // 23
}; // same size as limit because there are two 5-limit commas

enum Comma_t
{
pyth,
Expand All @@ -54,60 +53,60 @@ struct JIMath
nineteen,
twentythree
};

double comma(Comma_t c, bool major = true)
{
uint64_t A = 1;
uint64_t B = 1;

switch (c)
{
case pyth:
A = Commas[0].first;
B = Commas[0].second;
break;
case syntonic:
A = Commas[1].first;
B = Commas[1].second;
break;
case diesis:
A = Commas[2].first;
B = Commas[2].second;
break;
case seven:
A = Commas[3].first;
B = Commas[3].second;
break;
case eleven:
A = Commas[4].first;
B = Commas[4].second;
break;
case thirteen:
A = Commas[5].first;
B = Commas[5].second;
break;
case seventeen:
A = Commas[6].first;
B = Commas[6].second;
break;
case nineteen:
A = Commas[7].first;
B = Commas[7].second;
break;
case twentythree:
A = Commas[8].first;
B = Commas[8].second;
break;
case pyth:
A = Commas[0].first;
B = Commas[0].second;
break;
case syntonic:
A = Commas[1].first;
B = Commas[1].second;
break;
case diesis:
A = Commas[2].first;
B = Commas[2].second;
break;
case seven:
A = Commas[3].first;
B = Commas[3].second;
break;
case eleven:
A = Commas[4].first;
B = Commas[4].second;
break;
case thirteen:
A = Commas[5].first;
B = Commas[5].second;
break;
case seventeen:
A = Commas[6].first;
B = Commas[6].second;
break;
case nineteen:
A = Commas[7].first;
B = Commas[7].second;
break;
case twentythree:
A = Commas[8].first;
B = Commas[8].second;
break;
}
return (major) ? (double)A/B : (double)B/A;

return (major) ? (double)A / B : (double)B / A;
}

// Maybe move these to the tuning library on Tones one day?
// 3/2 up by 3/2 is 9/4
std::pair<uint64_t, uint64_t> multiplyRatio(uint64_t N1, uint64_t D1, uint64_t N2, uint64_t D2)
{

auto nR = N1 * N2;
auto dR = D1 * D2;

Expand All @@ -131,7 +130,7 @@ struct JIMath
}
return {nR, dR};
}

void monzoToRatio(monzo m, uint64_t &num, uint64_t &denom)
{
for (int i = 0; i < limit; ++i)
Expand All @@ -146,19 +145,18 @@ struct JIMath
}
}
}

inline void ratioToMonzo(const uint64_t num, const uint64_t denom, monzo &m)
{
auto n = num;
auto d = denom;

for (int i = 0; i < limit; ++i)
{
while (n % primes[i] == 0)
{
m[i]++;
n /= primes[i];

}
while (d % primes[i] == 0)
{
Expand All @@ -167,7 +165,7 @@ struct JIMath
}
}
}

inline void octaveReduceRatio(uint64_t &num, uint64_t &denom)
{
while (num < denom)
Expand All @@ -179,25 +177,25 @@ struct JIMath
denom *= 2;
}
}

inline void octaveReduceMonzo(monzo &m)
{
uint64_t n{1}, d{1};

monzoToRatio(m, n, d);
octaveReduceRatio(n, d);
ratioToMonzo(n, d, m);
}

// ============ Note Name Support

std::string nameNoteOnLattice(int x, int y)
{
auto location = x + y * 4 + 3;

auto ml = ((location % 7) + 7) % 7;
std::string name = noteNames[ml];

while (location >= 7)
{
name += "#";
Expand All @@ -219,14 +217,12 @@ struct JIMath
name += "+";
++pom;
}

return name;
}

private:


private:
std::string noteNames[7] = {"F", "C", "G", "D", "A", "E", "B"};

};

#endif // JI_MTS_SOURCE_JIMATH_H
Loading
Loading