Quick Guide on Setting Up a Custom JSON File for pd2dsy & Oopsy!

Hello everyone!

We’re planning on making a video about audio I/O and custom JSON file in the near future (I actually have both scripts nearly complete!). In the meantime, I wanted to put together a quick guide on how to set up a custom JSON file for the Daisy Seed so that you can control your synth with a sensor!

The goal of this tutorial is to change the pitch of an oscillator by twisting a potentiometer that you connected to the Seed!

Let’s get started!

Here, we have [r knob @hv_param] for pd2dsy and [param knob] for Oopsy, in which “knob” is the argument. The idea is that we want these objects to output 0.0 to 1.0 when we twist a potentiometer that’s connected to the Daisy Seed in the physical world.

knob_pd2dsy

But, flashing this patch without any custom JSON won’t do anything. So, let’s have a custom JSON that will get this working!

Here’s customseed.json

{
    "name": "customseed",
    "som": "seed",
    "components": {
        "knob": {
            "component": "AnalogControl",
            "pin": 15
        }
    }
}

You can copy and paste this into a .txt file (plain text and not rich text) using TextEdit for example. And you can simply change the extension from .txt to .json.

You may have noticed that there’s “knob” in this JSON file. As you guessed it, that corresponds to "knob" in the [r knob @hv_param] object and [param knob] operator!

But how does it know which pin the potentiometer’s analog out is connected to? That’s where that "pin": 15 comes in.

pin 15 corresponds to ADC 0 on the Daisy (please see the attach diagram. A0 = D15). I’m assuming you have a bit of electronics experience (like using an Arduino), so that’s where the potentiometer’s analog out pin should be connected to. If you are not sure about this part, no worries! I’m going over electronics basics in the upcoming video. And you may find this video helpful in the meantime.

So! After connecting the potentiometer to ADC 0, 3.3 volt, and ground (also don’t forget to bridge the DGND and AGND together in order for the analog value to be read effectively), you can now flash to the Daisy!

For pd2dsy, select the .pd and .json files in pd2dsyGUI (or plugdata) similar to how you did with the blink tutorial.

For Oopsy, flash the gen~ patch with the customseed.json (using the Browse button) selected.

I’m gonna assume that you have the audio jack(s) connected to the Daisy (I show this briefly towards the end of this video, but I’ll go over this in more detail in the upcoming audio IO video).

After the program is flashed, you can twist the knob and the pitch of the oscillator should change!

What about adding more sensors?
Here’s an example of what that would look like!

{
    "name": "customseed",
    "som": "seed",
    "components": {
        "knob": {
            "component": "AnalogControl",
            "pin": 15
        },
        "ribbon1": {
            "component": "AnalogControl",
            "pin": 16
        },
        "ribbon2": {
            "component": "AnalogControl",
            "pin": 17
        },
        "fsr1": {
            "component": "AnalogControl",
            "pin": 18
        },
        "fsr2": {
            "component": "AnalogControl",
            "pin": 19
        }
    }
}

Referencing the JSON files for other Daisy products, like Daisy Pod, is helpful by the way! Here’s where you can find them.

Let me know if you have any questions!

2 Likes

@Takumi_Ogata Thanks for this guide! I’ve been able to use custom JSON files like this to work with a simple setup of multiple knobs.

Right now, I’m trying to read sensor data from a Bno055 which is connected to daisy via I2C though, which is part of the definitions in https://github.com/electro-smith/json2daisy/blob/main/src/json2daisy/resources/component_defs.json - so I assume it shouldn’t be too hard. But I have no clue what a functioning JSON definition for this should look like. Would be great to have examples for this and maybe some of the other sensors, too!

I tried to copy a bit from the I2C definitions used in https://github.com/electro-smith/json2daisy/blob/main/src/json2daisy/resources/petal.json … but so far, I only achieve different error messages.

Hey ben-wes!

Getting the bno055 should be similar process to how you got the mpr121 to work. But either way, yes, we would love to have a solid tutorial for getting i2c components working with pd2dsy and Oopsy for sure.
Thank you for the suggestion!

In the meantime, if you would like us to troubleshoot getting the bno055 to work, please feel free to start a separate thread and also share the json file plus the error that you’ve been getting. Thanks!

Thanks for your response and suggestion! It actually helped me to see what I did a few months ago when trying (and failing) to get the MPR121 to properly work. :slight_smile: … the BNO055 support is not yet part of the master branch of libdaisy. There is a separate branch from ~2 years ago though that I could merge:

After building the updated libdaisy, I ran into the same problem with the sdl and sda pins that I didn’t know how to correctly set in the custom JSON (the obvious way with just pin numbers as integers doesn’t work). I then removed those as well from the component_defs.json to force using the (correct) defaults set in bno055.h.

Eventually my test patch compiled and uploaded successfully and I was about to celebrate! … until I realized that there was no sensor data affecting the sound at all. I might follow up on this in a separate thread. But I’m afraid that I’m not on the technical level to proceed with it and also currently don’t have debug tools/hardware for the Daisy.

Are there any plans concerning support for more (I2C) sensors including tutorials/documentation? This would be really great and I’d be happy to contribute if possible! Until then, imho it’s giving a false impression if unsupported sensors are mentioned in https://github.com/electro-smith/pd2dsy/blob/master/README.md

Did you put pull-up resistors?
And yes, we would be happy to have a closer look when you start a new thread.

Of course, we definitely want to provide tutorials and resources for I2C components :slight_smile:

Thank you once more for your quick reply here!

I’m opening another thread now …

1 Like