Jaffe- / NESizer2

A synthesizer based on the 2A03 (NES APU)
99 stars 18 forks source link

Added MIDI CC support #16

Open circuitcreature opened 7 months ago

circuitcreature commented 7 months ago

Fixes #15 I'll need to update the docs, but here are the base CC channels. After listing these out, it might be better to move the loops off of channel 14 and to something else.

SQUARES: 1: DUTY 5: GLIDE 7: VOLMOD 14: DETUNE 15: COARSE 20: ATTACK 21: DECAY 22: SUSTAIN 23: RELEASE
24: ENVMOD 30: LFO1 31: LFO2 32: LFO3 123: ENABLE/DISABLE

TRIANGLE: 5: GLIDE 14: DETUNE 15: COARSE 24: ENVMOD 30: LFO1 31: LFO2 32: LFO3 123: ENABLE/DISABLE

NOISE: 7: VOLMOD 14: LOOP 15: COARSE 20: ATTACK 21: DECAY 22: SUSTAIN 23: RELEASE
24: ENVMOD 30: LFO1 31: LFO2 32: LFO3 123: ENABLE/DISABLE

DMC: 14: LOOP 123: ENABLE/DISABLE

GLOBAL: 50: LFO1 PERIOD 51: LFO1 WAVEFORM 52: LFO2 PERIOD 53: LFO2 WAVEFORM 54: LFO3 PERIOD 55: LFO3 WAVEFORM

circuitcreature commented 7 months ago

I pushed a commit with pushing the constant to flash, and to have functions match the style. i haven't tested that commit yet, I'll be back to update the synth tomorrow night.

circuitcreature commented 7 months ago

@Jaffe- I've updated the constants to use PROGMEM and corrected the crash issue, I think. I also set a true zero value to set the channel to its initial value. A quick test shows things seem to be working. I'll be able to do a more in-depth QA tomorrow.

Jaffe- commented 7 months ago

@Jaffe- I've updated the constants to use PROGMEM and corrected the crash issue, I think. I also set a true zero value to set the channel to its initial value. A quick test shows things seem to be working. I'll be able to do a more in-depth QA tomorrow.

Thanks for the new commit! I will try and get it tested this week also. What is the reason you went from the 2D array to the separate arrays and an array of pointers? Just wondering because it was a bit clearer to read before imo.

circuitcreature commented 7 months ago

From what I was reading when looking up PROGMEM it saves on memory since the original arrays defaulted to a length of 15. This setup allows each array to be its own length.

I pushed another update to address some bugs I found and made the midi CC arrays easier to read.

I've been trying to use leds_7seg_two_digit_set_hex() to debug incoming messages, but the display clears too quickly to read. Is there a way to force these led updates to display longer?

Jaffe- commented 5 months ago

From what I was reading when looking up PROGMEM it saves on memory since the original arrays defaulted to a length of 15. This setup allows each array to be its own length.

I pushed another update to address some bugs I found and made the midi CC arrays easier to read.

I've been trying to use leds_7seg_two_digit_set_hex() to debug incoming messages, but the display clears too quickly to read. Is there a way to force these led updates to display longer?

Actually I started adding some functionality for debugging, including a new UI "mode" for showing info on the display and waiting until OK is pressed to clear it. I think it should be possible to push without too much work. In retrospect it could be nice to have a UART in this thing, but unfortunately it is used by MIDI ...

Sorry for the long delay in answering, I hope to be able to test your changes soon.

circuitcreature commented 5 months ago

My tests from my last commit worked on my end. I have another commit I'm working on to add more CC features matching the functionality of the Famimimidi and other NES cartridges. I should have more time in the coming weeks now the holiday season is over.

beau-seidon commented 5 months ago

@Jaffe- for debugging purposes it may be possible to use the Send-Only SoftwareSerial library by nickgammon.

https://github.com/nickgammon/SendOnlySoftwareSerial

Might be able to map to one of the ISP pins and connect it to a USB serial adapter and monitor debug messages via bit-banged serial. Not sure how well it will work with everything else jammed in the little 328p tho.

Perhaps a topic for the Discussions board.

circuitcreature commented 4 months ago

@Jaffe- pushed an update. The first major update is a better mapping function to convert midi CC values to the internal parameter values. The second update is the midi_command struct now takes a second cc value that will act as a toggle for the main CC command. For example, you change the channel's glide with midi CC 5 and then change midi CC 65 to a value below 63, this will store the current parameter.target value and then set its value to its initial state, basically turning it OFF. In the OFF state, it will still accept updates to the value, but will remain off until CC 65 is set to a value above 63.

I was able to get some testing in tonight and things are working as intended. In a future commit I'll have the CC commands that match Famimimidi's command, to a degree.