Skip to content

Commit

Permalink
create basic and basic-osc templates. Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
edumeneses committed Nov 15, 2024
1 parent 7656092 commit 2cc23f6
Show file tree
Hide file tree
Showing 87 changed files with 7,003 additions and 13 deletions.
32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Puara Module template (module manager)

This repository can be used as a base to create musical controllers compatible with the Puara Framework.

It includes a Wi-Fi manager (set SSID/password for wireless networks), a [OSC](https://en.wikipedia.org/wiki/Open_Sound_Control) manager (set addresses to send OSC messages), setup tools, and [libmapper](http://libmapper.github.io/) compatibility*.

This pseudo-library currently has the following dependencies:

- [libmapper-arduino](https://github.com/puara/libmapper-arduino.git) (cloned from the [original library](https://github.com/mathiasbredholt/libmapper-arduino)).
This repository contains several templates to be used as a base to create devices that can be controlled over the network the Puara Framework.

## How to use

Expand All @@ -18,17 +12,29 @@ This pseudo-library currently has the following dependencies:

## Available Templates

### libmapper-osc-template
Use this as a base if you want to use libmapper or raw OSC messages.
### basic

Use this as a bare-minimum template to just make puara-module available in you microcontroller.

### basic-osc

Use this as a base if you want to send and receive osc messages.

### ble-advertising

### ble-advertising-template
Use this as a base if you want to expose sensor data as BLE advertisements.

## More Info on the related [GuitarAMI](https://github.com/Puara/GuitarAMI) and [Puara](https://github.com/Puara) research
### libmapper-osc

[https://www.edumeneses.com](https://www.edumeneses.com)
Use this as a base if you want to use libmapper or raw OSC messages.

## More Info on the research related with [Puara](https://github.com/Puara)

[http://www-new.idmil.org/project/guitarami/](http://www-new.idmil.org/project/guitarami/)
[http://www.sat.qc.ca](http://www.sat.qc.ca/)

[http://www.idmil.org](http://www.idmil.org/)

[https://www.edumeneses.com](https://www.edumeneses.com)

## Licensing

Expand Down
5 changes: 5 additions & 0 deletions basic-osc/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
78 changes: 78 additions & 0 deletions basic-osc/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
description = Puara module manager

[common]
lib_deps =
https://github.com/Puara/puara-module.git#0.3
https://github.com/cnmat/OSC#3.5.8

[env:Xiao]
platform = espressif32
board = seeed_xiao_esp32c3
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
lib_deps =
${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder

[env:tinypico]
platform = espressif32
board = tinypico
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
lib_deps =
${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder

[env:m5stick-c]
platform = espressif32
board = m5stick-c
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
lib_deps =
${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder

[env:ESP32-S3]
platform = espressif32
board = esp32-c3-devkitc-02
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
lib_deps =
${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder
File renamed without changes.
File renamed without changes.
File renamed without changes.
113 changes: 113 additions & 0 deletions basic-osc/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//****************************************************************************//
// Puara Module Manager //
// Société des Arts Technologiques (SAT) //
// Input Devices and Music Interaction Laboratory (IDMIL), McGill University //
//****************************************************************************//

#include "Arduino.h"

// Include Puara's module manager
// If using Arduino.h, include it before including puara.h
#include "puara.h"

// Initialize Puara's module manager
Puara puara;

/*
* Include CNMAT's OSC library (by Adrian Freed)
* This library was chosen as it is widely used, but it can be replaced by any
* other OSC library of choice
*/
#include <WiFiUdp.h>
#include <OSCMessage.h>

// UDP instances to let us send and receive packets
WiFiUDP Udp;

// Dummy sensor data
float sensor;

void setup() {
#ifdef Arduino_h
Serial.begin(115200);
#endif

/*
* the Puara start function initializes the spiffs, reads config and custom json
* settings, start the wi-fi AP/connects to SSID, starts the webserver, serial
* listening, MDNS service, and scans for WiFi networks.
*/
puara.start();

/*
* Printing custom settings stored. The data/config.json values will print during
* Initialization (puara.start)
*/
std::cout << "\n"
<< "Settings stored in data/settings.json:\n"
<< "Hitchhiker: " << puara.getVarText ("Hitchhiker") << "\n"
<< "answer_to_everything: " << puara.getVarNumber("answer_to_everything") << "\n"
<< "variable3: " << puara.getVarNumber("variable3") << "\n"
<< std::endl;

// Start the UDP instances
Udp.begin(puara.getLocalPORT());
}

void loop() {

// Update the dummy sensor variable with random number
sensor = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/10));

// print the dummy sensor data
std::cout << "\n"
<< "Settings stored in data/settings.json:\n"
<< "Dummy sensor value: " << sensor << "\n"
<< std::endl;

/*
* Sending OSC messages.
* If you're not planning to send messages to both addresses (OSC1 and OSC2),
* it is recommended to set the address to 0.0.0.0 to avoid cluttering the
* network (WiFiUdp will print an warning message in those cases).
*/
if (puara.IP1_ready()) { // set namespace and send OSC message for address 1
OSCMessage msg1(("/" + puara.get_dmi_name()).c_str());
msg1.add(sensor);
Udp.beginPacket(puara.getIP1().c_str(), puara.getPORT1());
msg1.send(Udp);
Udp.endPacket();
msg1.empty();
std::cout << "Message send to " << puara.getIP1() << std::endl;
}
if (puara.IP2_ready()) { // set namespace and send OSC message for address 2
OSCMessage msg2(("/" + puara.get_dmi_name()).c_str());
msg2.add(sensor);
Udp.beginPacket(puara.getIP2().c_str(), puara.getPORT2());
msg2.send(Udp);
Udp.endPacket();
msg2.empty();
std::cout << "Message send to " << puara.getIP2() << std::endl;
}

// run at 1 Hz (1 message per second)
vTaskDelay(1000 / portTICK_PERIOD_MS);
}

/*
* The Arduino header defines app_main and conflicts with having an app_main function
* in code. This ifndef makes the code valid in case we remove the Arduino header in
* the future.
*/
#ifndef Arduino_h
extern "C" {
void app_main(void);
}

void app_main() {
setup();
while(1) {
loop();
}
}
#endif
File renamed without changes.
5 changes: 5 additions & 0 deletions basic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
79 changes: 79 additions & 0 deletions basic/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[platformio]
description = Puara module manager

[common]
lib_deps =
https://github.com/Puara/puara-module.git#0.3
;build_flags =
; -DCONFIG_ARDUINO_LOOP_STACK_SIZE=32768

[env:Xiao]
platform = espressif32
board = seeed_xiao_esp32c3
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
;build_flags = ${common.build_flags}
lib_deps = ${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder

[env:tinypico]
platform = espressif32
board = tinypico
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
;${common.build_flags}
lib_deps = ${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder

[env:m5stick-c]
platform = espressif32
board = m5stick-c
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
;build_flags = ${common.build_flags}
lib_deps = ${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder

[env:ESP32-S3]
platform = espressif32
board = esp32-c3-devkitc-02
framework = arduino
board_build.partitions = min_spiffs_no_OTA.csv
build_flags =
-DBOARD_HAS_PSRAM
-mfix-esp32-psram-cache-issue
;build_flags = ${common.build_flags}
lib_deps = ${common.lib_deps}
monitor_speed = 115200
monitor_echo = yes
monitor_filters =
default
esp32_exception_decoder
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2cc23f6

Please sign in to comment.