Chunreal is a plugin for Unreal Engine 5 that allows users to compile ChucK code at runtime. Multiple ChuckMain nodes can be chained in a MetaSound graph using stereo input & output to perform modular synthesis style digital signal processing.
Developed by Eito Murakami and Ge Wang at CCRMA | Stanford University.
The Wiki page contains a step-by-step tutorial that demonstrates how to set up the Chunreal plugin in your Unreal Engine project.
https://github.com/ccrma/chunreal/wiki
This git repository hosts a template Unreal Engine 5.3 project that includes example scenes, Blueprints, MetaSound sources, and materials. Clone or fork the repository and generate Visual Studio project files. If this is your first time compiling a Unreal Engine project, set up your IDE by following these tutorials:
https://docs.unrealengine.com/5.3/en-US/how-to-generate-unreal-engine-project-files-for-your-ide/
Try opening the following example levels and playing in the editor viewport!
- Chunreal_SetGlobals_ExampleLevel
- Chunreal_ChainedDSP_ExampleLevel
- Chunreal_1Source_ExampleLevel
- Chunreal_ManySources_ExampleLevel
- Chunreal_Physics_ExampleLevel
- Chunreal_Mic_ExampleLevel
- Chunreal_GlobalEvent_ExampleLevel
- Chunreal_PitchChange_ExampleLevel
Chunreal_Simple_MetaSound asset contains an example of ChuckMain node implementation in a MetaSound source.
Input
- Run Code: A trigger input for compiling ChucK code.
- Code: A string input for ChucK code to be compiled.
- ID: A string input for assigning a unique ID to a ChuckMain node. This is used to get and set global variables for a specific ChucK instance.
- Audio Input Left: Audio input left channel. Can be accessed by adc.left inside a ChucK code.
- Audio Input Right: Audio input right channel. Can be accessed by adc.right inside a ChucK code.
- Volume Multiplier: A float input for applying a volume multiplier to both output channels.
Output
- Audio Output Left: Audio output left channel. Can be accessed by dac.left inside a ChucK code.
- Audio Output Right: Audio output right channel. Can be accessed by dac.right inside a ChucK code.
![image](https://private-user-images.githubusercontent.com/75334216/250631690-ca0cd851-843a-4435-8557-efe61fa23a55.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTM1MTMsIm5iZiI6MTcyNDU5MzIxMywicGF0aCI6Ii83NTMzNDIxNi8yNTA2MzE2OTAtY2EwY2Q4NTEtODQzYS00NDM1LTg1NTctZWZlNjFmYTIzYTU1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDEzNDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdkMzg5MjMyZjE5ZDBhMmUyYjc1OTgwNzk1ODAyMjJlNWQxNTkwMzAyMDNjZGYzYmVmYzk2ZDM2NmE4ZWZmMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gLBbsK1t8C7591-NFExK0g5-Ea3uH78XJ_wyKKX54WU)
Create a Blueprint actor, attach an audio component, and assign your MetaSound source that contains a ChuckMain node(s) as the sound parameter. Optionally, enable Allow Spatialization and apply Attenuation Settings. We prepared an example Binaural_SA sound attenuation asset.
Chunreal_Simple_BP asset provides a template.
![image](https://private-user-images.githubusercontent.com/75334216/250635252-1afd5fe6-a1a5-436a-88a9-baf57edc03ee.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTM1MTMsIm5iZiI6MTcyNDU5MzIxMywicGF0aCI6Ii83NTMzNDIxNi8yNTA2MzUyNTItMWFmZDVmZTYtYTFhNS00MzZhLTg4YTktYmFmNTdlZGMwM2VlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDEzNDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWFiZTllMWZiN2VmYWZlOWRiYjY1NmEyYjYzZWY5YzdmZTU3OGViNTkyMWVhNzg3MmExNzgxOTAzZDliMjQ2ZjEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.dD-m5lhPNMCoYbiYItzmLRxiXY-0gPMKRa21ysYzrjc)
A ChucK code can be written as a string and can be passed to the Audio Component that uses the MetaSound source as follows:
![image](https://private-user-images.githubusercontent.com/75334216/250633575-5df1d56b-2b3a-4b3c-ae17-2868ba5b839a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTM1MTMsIm5iZiI6MTcyNDU5MzIxMywicGF0aCI6Ii83NTMzNDIxNi8yNTA2MzM1NzUtNWRmMWQ1NmItMmIzYS00YjNjLWFlMTctMjg2OGJhNWI4MzlhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDEzNDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBhYjUyNDMxOGY1NTgxM2NmNzVlYTcxY2RiOWQ3ZGQ2MDRkZWZkY2ZjZTczNDM1N2YwZGEzYTcwOWE0MzhlMmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.7X_N8Ck9SY0FFzuPgjKfUvmeQuBoKftly26YD80dlVw)
Alternatively, we prepared a ReadFile Blueprint function for loading a .ck file using an absolute path.
![image](https://private-user-images.githubusercontent.com/75334216/250633904-5bd443ba-c303-4b9b-9bee-174fe22a52f0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTM1MTMsIm5iZiI6MTcyNDU5MzIxMywicGF0aCI6Ii83NTMzNDIxNi8yNTA2MzM5MDQtNWJkNDQzYmEtYzMwMy00YjliLTliZWUtMTc0ZmUyMmE1MmYwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDEzNDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZhOWExM2IyZTQxOWMxMDQ3NDA3YTUxMDJjMGE1ZGQ5YzNjN2NhNzc1ZjIwZGY3Zjg5NzNiZTQ2NGM5MzIwYzYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.N32lfZ7ZbBDY_kfXdHZL5fqhEBw4fUlu9nmM7v4QFR4)
A specific ChucK instance can be accessed using its assigned unique ID. Global event, int, float, and string variables can be accessed using the following Blueprint functions. To learn how to use each function, open each Blueprint Actor in ExampleBlueprints folder.
![image](https://private-user-images.githubusercontent.com/75334216/250636659-8f3ea549-a607-4592-b129-b96db6421ede.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTM1MTMsIm5iZiI6MTcyNDU5MzIxMywicGF0aCI6Ii83NTMzNDIxNi8yNTA2MzY2NTktOGYzZWE1NDktYTYwNy00NTkyLWIxMjktYjk2ZGI2NDIxZWRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDEzNDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWE3OTFjMGU0YzZlODUzMDkzYWI0NzQ3Njc3OTU3YzQ5ZjEwYmM2MmVlNTkyNGU5ZGUzNzkzN2YyNzI2MDEzZmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.GqoUm-RxoTfDzuHUeDxGlrVPf4ef47Rl9FtizssGKn0)
Multiple ChuckMain nodes can be chained in a MetaSound source and can interact with other existing MetaSound nodes!
Chunreal_ChainedDSPExample_MetaSound and Chunreal_ChainedDSPExample_BP provide a template.
![image](https://private-user-images.githubusercontent.com/75334216/250637681-34271b38-185e-4d43-91b8-65a8b8da8c63.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ1OTM1MTMsIm5iZiI6MTcyNDU5MzIxMywicGF0aCI6Ii83NTMzNDIxNi8yNTA2Mzc2ODEtMzQyNzFiMzgtMTg1ZS00ZDQzLTkxYjgtNjVhOGI4ZGE4YzYzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODI1VDEzNDAxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlmYmE3OTdhNWE5OGM3OWRmNTNhN2M4ZDMzN2RlODY5NTdlMjI3ZWE5OWEzYmYwMDllYTE3YjI1NTlmNWQ3YzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.JFhNtNhJUlvhsIFa0CU0xBHpLLemBiai7sjcQoMCAg0)
Join us!! ChucK Community Discord | ChucK-users Mailing list