Skip to content

Commit

Permalink
Merge pull request #18 from DBraun/fix-null-code-crash
Browse files Browse the repository at this point in the history
Fix null code crash
  • Loading branch information
DBraun authored Feb 18, 2024
2 parents 5e337de + ec5ebfd commit 91947e4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
submodules: true

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1
uses: microsoft/setup-msbuild@v2

- name: Get CMake
uses: lukka/get-cmake@latest
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
submodules: true

- name: Setup Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.8'

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Part 2 (Python API):

### ChucK

ChucKDesigner is currently being built for ChucK 1.5.1.9 for TouchDesigner with Python 3.9 (2022 builds) or 3.11 (2023 builds). If you need to support something else, please check out earlier [releases](https://github.com/DBraun/ChucKDesigner/releases) or commits of this repository.
ChucKDesigner is currently being built for ChucK 1.5.2 for TouchDesigner with 3.11 (2023 builds) and Python 3.9 (2022 builds). If you need to support something else, please check out earlier [releases](https://github.com/DBraun/ChucKDesigner/releases) or commits of this repository.

[Downloading ChucK](https://chuck.stanford.edu/release/) is optional but highly encouraged! Use miniAudicle and the examples that come with the installation to learn ChucK. More educational resources are available from the [ChucK homepage](https://chuck.stanford.edu/). ChucKDesigner is very similar to [Chunity](https://chuck.stanford.edu/chunity/) (the integration of ChucK with Unity), so you are also encouraged to learn about [Chunity](https://github.com/ccrma/chunity/)!

Expand All @@ -39,14 +39,14 @@ Download and unzip the latest Windows [release](https://github.com/DBraun/ChucKD
<br>
Clone this repository with git. Then update all submodules in the root of the repository with <code>git submodule update --init --recursive</code>.
<br>
Install <a href="https://www.python.org/downloads/release/python-3910/">Python 3.9</a> to <code>C:/Python39/</code> and confirm it's in your system PATH.
Install <a href="https://www.python.org/downloads/release/python-3117/">Python 3.11</a> to <code>C:/Python311/</code> and confirm it's in your system PATH.
<br>
Install CMake and confirm that it's installed by running <code>cmake --version</code> in a command prompt.
<br>
Then in this repository,
<br>
<code>
cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -DPYTHONVER="3.9"
cmake . -DCMAKE_BUILD_TYPE=Release -Bbuild -DPYTHONVER="3.11"
</code>
<br>
Finally, open <code>build/ChucKDesignerCHOP.sln</code> and compile.
Expand All @@ -59,8 +59,8 @@ Finally, open <code>build/ChucKDesignerCHOP.sln</code> and compile.
1. Clone this repository with git. Then update all submodules in the root of the repository with `git submodule update --init --recursive`
2. Install Xcode.
3. [Install CMake](https://cmake.org/download/) and confirm that it's installed by running `cmake --version` in Terminal. You may need to run `export PATH="/Applications/CMake.app/Contents/bin":"$PATH"`
4. In a Terminal Window, export a variable to the TouchDesigner.app to which you'd like to support. For example: `export TOUCHDESIGNER_APP=/Applications/TouchDesigner.app`, assuming this version is a 2022.22650 build or higher.
5. Optional: depending on the Python version associated with the TouchDesigner you intend to use, run `export PYTHONVER=3.9` or `export PYTHONVER=3.11`.
4. In a Terminal Window, export a variable to the TouchDesigner.app to which you'd like to support. For example: `export TOUCHDESIGNER_APP=/Applications/TouchDesigner.app`, assuming this version is a 2023 build or higher.
5. Optional: depending on the Python version associated with the TouchDesigner you intend to use, run `export PYTHONVER=3.11` or `export PYTHONVER=3.9`.
6. In the same Terminal window, navigate to the root of this repository and run `sh build_macos.sh`
7. Open `ChucKDesigner.toe` and play around!

Expand Down
2 changes: 1 addition & 1 deletion build_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi

if [ "$PYTHONVER" == "" ]; then
# Guess which Python version TD uses.
export PYTHONVER=3.9
export PYTHONVER=3.11
fi
echo Building for Python $PYTHONVER

Expand Down
2 changes: 1 addition & 1 deletion build_windows.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if "%PYTHONVER%"=="" (
set PYTHONVER=3.9
set PYTHONVER=3.11
)
echo "Using Python version: %PYTHONVER%"

Expand Down
30 changes: 16 additions & 14 deletions src/ChucKDesignerCHOP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ extern "C"
info->customOPInfo.authorName->setString("David Braun");
info->customOPInfo.authorEmail->setString("github.com/DBraun");

info->customOPInfo.majorVersion = 0;
info->customOPInfo.minorVersion = 3;

info->customOPInfo.minInputs = 0;
info->customOPInfo.maxInputs = 1;

Expand Down Expand Up @@ -556,6 +559,7 @@ ChucKDesignerCHOP::getChannelName(int32_t index, OP_String *name, const OP_Input

void
ChucKDesignerCHOP::reset() {
myError.str("");
ChucK_For_TouchDesigner::clearGlobals(m_chuckID);
ChucK_For_TouchDesigner::clearChuckInstance(m_chuckID);
ChucK_For_TouchDesigner::cleanupChuckInstance(m_chuckID, myNodeInfo->opId);
Expand All @@ -578,11 +582,7 @@ ChucKDesignerCHOP::execute(CHOP_Output* output,
if (needCompile) {
needCompile = false;

// Until ChucK on windows parses the working directory better,
// we have to pass it as a relative path rather than an absolute path.
// https://github.com/ccrma/chuck/blob/de0530b4d0d85c9fe4abca17019730fe8e8e0454/src/core/chuck.cpp#L524
string globalDir = inputs->getParString("Workingdirectory");
//string globalDir = inputs->getParFilePath("Workingdirectory");
string globalDir = inputs->getParFilePath("Workingdirectory");

double sample_rate = inputs->getParDouble("Samplerate");

Expand All @@ -602,16 +602,18 @@ ChucKDesignerCHOP::execute(CHOP_Output* output,

ChucK_For_TouchDesigner::initChuckInstance(m_chuckID, sample_rate, m_inChannels, m_outChannels, globalDir);

const OP_DATInput* input = inputs->getParDAT("Code");
const char* code = *(input->cellData);
const OP_DATInput* codeInput = inputs->getParDAT("Code");

bool result = ChucK_For_TouchDesigner::runChuckCode(m_chuckID, code);
if (result) {
// clear any existing error
myError.str("");
}
else {
myError.str("ChucK code did not compile correctly.");
myError.str("");

if (codeInput) {
const char* code = *(codeInput->cellData);
bool result = ChucK_For_TouchDesigner::runChuckCode(m_chuckID, code);
if (!result) {
myError.str("ChucK code did not compile correctly.");
}
} else {
myError.str("You must specify ChucK Code.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/chuck
Submodule chuck updated 2 files
+5 −0 VERSIONS
+3 −1 src/core/ugen_osc.cpp

0 comments on commit 91947e4

Please sign in to comment.