Did you #include <memory>?
Type: Posts; User: PieterP
Did you #include <memory>?
Arduino/Teensy code is compiled using a GCC C++ compiler, so you can just consult the C++ documentation: https://en.cppreference.com/w/cpp/header/cmath#Functions
Indeed, if you need to handle out-of-memory conditions on a microcontroller with exceptions disabled, use new(std::nothrow).
I think that's a good idea. Returning null is not allowed and does...
It's just the optimizer doing its job. The standard requires that `new` always returns a non-null pointer, so the optimizer can just throw away the entire `else` branch.
See it for yourself on...
Some general comments:
Don't use goto, use human-readable control structures like if, while, do-while, for, function calls, etc. instead:
do {
currentState = digitalRead(BUTTON_PIN);
...
But that doesn't solve the issue, you can shift it to the left as much as you like, in the end you have to represent everything in a finite number of bits, and no amount of filtering or shifting is...
I think this is an inherent problem with quantization, not necessarily because of the implementation of the filter (although different rounding/quantization methods might reveal it more easily than...
This might be useful: https://github.com/tttapa/Control-Surface/issues/241#issuecomment-660960589
It does roughly the same as the code you're using now (except the 3-way and 4-way switches), but...
There is a wrapper, but you don't need it, Control Surface supports MIDI over hardware serial out of the box. For example:
HardwareSerialMIDI_Interface serialmidi = Serial1;
This line replaces...
I don't think you're supposed to make copies of the serial ports. Not sure why the HardwareSerial copy constructor isn't deleted.
If you want to declare the serial ports separately, use references...
You might be interested in the Control Surface library for Arduino and Teensy that I maintain. It comes with many building blocks for creating MIDI controllers and control surfaces and has support...
Changing the Interrupt Threshold Control value seems to alter the timing and might expose some data races.
Occasionally, packets seem to be dropped when sending very long SysEx messages using my...
What exactly is the problem with the USBDriverTimer class? Is there anything you could use help with?
You would inherit from the MIDI_Callback class and implement its onChannelMessage method. Then attach the callback to the MIDI interface using setCallbacks.
For example:
#include...
Sure, the code for the T4.0 simply discards any incoming MIDI USB data (compiled with USB type “MIDI”, of course):
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN,...
I've been working on a more efficient implementation of the USB host MIDI driver. It uses alternating transmit buffers and disables interrupts only for a minimal amount of time, which allows for high...
On a related note: Raspberry Pi also boasts about the SWD debugging support on the Pico. A $4 SWD debugger sounds pretty nice.
I've tried their “Picoprobe” firmware and their fork of OpenOCD to...
Maybe it was because I already had some of the necessary dependencies and tools installed, but for me it was as simple as installing the PlatformIO extension in VSCode and clicking the “new project”...
IIRC, the Arduino Pro IDE is based on Eclipse Theia, which is an open-source VSCode alternative. The problem with VSCode is that it's not really open-source. It's built on open-source and large parts...
The Teensy 4.0 is a 3.3V device, connecting analog pins to 5V will destroy it. Your potentiometers should be wired to 3.3V, not 5V.
Pieter
You could use a lambda function:
OLEDIntervalTimer.begin(+[]{ enableCyclePointer(¤tGlobals); }, 6);
Pieter
I've been using Teensy on Ubuntu 20.04 since it came out in April (and on 19.10, 18.04 and 16.04 before that), and I've never had any problems with the serial monitor.
When selecting the 'Serial'...
MIDI uses a current loop, not voltage. It's normal that you don't measure any voltage at the output of your circuit, it only needs to source current. By adding some kind of pull-up network (e.g. by...
I posted a working example for a MIDI controller with buttons and an encoder. Did it not work for you?
If you want to write your own code from scratch, you'll have to learn some basics about the...
The MCU::PLAY constant is for the Mackie Control Universal protocol specifically. If you don't use that protocol, the controller numbers don't really have any meaning apart for the MIDI mapping you...
You have to write code, there's no way around that. You have to tell the Teensy what MIDI messages to send and when, and how it should react to the incoming MIDI messages it receives.
I'm the...
There are very few circumstances where you should be using “new” in modern C++.
The code you linked to uses “new” and owning raw pointers, and leaks memory as a result.
For example here:
...
A quick glance at the source seems to reveal that the default constructor copies the contents of a pre-allocated “zero” constant BigNumber. This constant is created when calling BigNumber::begin(),...
Something like this, perhaps?
class Foo {
public:
static BigNumber* getBarPtr() {
static BigNumber bar; // Costructed when this function is first called
return &bar;
...
You cannot create a BigNumber before calling BigNumber::begin(), otherwise the BigNumber constructor will dereference a null pointer and crash your program.
Pieter
You can use the “usb_string_midi_port1” through “usb_string_midi_port16” constants. By default, the names used are “Port *”, see usb_desc.c#L1686.
You can define these names as shown here, for...
I don't have too much time to look into it right now, but here are a couple of things you could try:
- Try using doubles instead of floats. If it's a numerical issue, there should be a difference....
I'm not familiar with “denormalisation” in digital filters. In analog filter design, there seems to be a technique called denormalisation, but I'm not familiar with it.
In all floating point...
I maintain this Arduino-Filters library.
It supports Butterworth filters out of the box, as you can see in this example: Butterworth.ino
Ideally, this example is all you need to filter some sensor...
I don't use Ableton myself, but in my experience, DAWs will usually send all relevant MIDI data when you start the application, when you open a new project, or when you configure the control surface....
Basically it just reads the states of all the pins, and for each pair of pins, it compares them to the previous states. This is done by combining the two new states and the two old states as a 4-bit...
Here's what I use: https://github.com/tttapa/Arduino-Helpers/blob/master/src/AH/Hardware/MCP23017Encoders.hpp
See this example:...
I see you've edited your reply, glad you got it working.
If you have multiple chips, you could tie all of their interrupt pins together (use open-drain output on the MCPs and input pull-up enabled...
When a pin of the MCP changes state, the interrupt output goes low. This should trigger an interrupt on the Teensy. In the ISR, you read the MCP input register, and this read request causes the MPC...
The MCP will keep the interrupt pin low until you read the input register of the port that caused the interrupt, so you have to read the data in your ISR.
This also implies that the correct...
A latency of 27ms doesn't seem right at all. I'm not familiar with the Adafruit libraries you mention, but I did write a MIDI BLE library for ESP32. The way I handle it there is by buffering the...
What exactly do you need a queue for? Usually, you want to keep the latency as low as possible, so you'd avoid queuing up any MIDI data. The serial port or USB MIDI code you're using already has its...
For my purposes, and as a beginner-friendly Arduino/Teensy sketch, using the same size for the state as for the input is a perfectly sensible default.
You can still supply your own types as a...
Agreed, I added a check and more comments on the page:...
For truly random inputs, it probably doesn't matter, but the problem with truncation is that it makes it impossible to reach zero again (assuming non-negative inputs).
Using a rectangular input...
Ah, I see what you mean.
The difference is of course that both 'Decay' and 'Exponential' use floating point states and operations, whereas the C++ implementation uses only integer arithmetic, so...
Indeed, @xenington where did you get that code from? The pages you linked to seem to list the correct code...
You're right, I didn't double-check my version, I meant 1.52, 1.53 does indeed seem to include the change.
The .ARM.exidx section was added just 25 days ago, it's not yet included in the latest official release of Teensyduino.
I ran into the same problem a couple of weeks ago, trying to copy the...
I've used CMake extensively for cross-compiling on Linux, but never tried it on Windows, so I might be wrong but here are at least some things I could think of:
The default CMake generator for...