1
0
mirror of https://github.com/sjlongland/atinysynth.git synced 2025-09-13 10:03:15 +10:00
Commit Graph

37 Commits

Author SHA1 Message Date
b46f9864e7
attiny861: Port to new API 2021-05-23 10:22:16 +10:00
137dba352c
attiny85: Port to new API 2021-05-23 10:19:48 +10:00
Luciano Martorella
c19c6dddcb - Added sequencer from binary 'waveform' and ADSR data.
- Added waveform generic API to create waveforms, and use period instead of frequency in waveform (avoid division on MCUs)
- Introduced 'def' struct in ADSR API for reuse
- Multi-track MML parser and compilation
- Added some samples from https://electronicmusic.fandom.com/wiki/Music_Macro_Language
- Added scale.mml for testing
2021-05-18 20:18:29 +02:00
c4a67b9d81
pc main: Code clean-up following merge of PR #1
- Adjust the styling of identifiers (camelCase to snake_case)
- Fix mixed indentation on line 38.
- Fold some long lines to within 80 characters
2021-04-29 08:33:28 +10:00
Luciano Martorella
b9f796c7e7 - Added check for read-error of script file 2021-04-28 22:08:24 +02:00
Luciano Martorella
6e5978d7a3 - Wav output instead of raw via libao
- Support missing live ao support
- Added support for script file
2021-04-28 21:59:14 +02:00
a83da25fa1
attiny861: Increase detection delay.
Increase the delay for detecting the buttons to account for power
supplies that may have a slower rise time.  Otherwise the MCU thinks
there's no buttons present and ignores all inputs.
2018-09-22 17:09:13 +10:00
64731b8a0d
attiny861: Reduce voices to 8.
16 voices is a bit ambitious in 512 bytes of RAM when each voice
occupies 30 bytes.
2017-07-26 07:44:25 +10:00
26af316c2c
attiny861 port: Tweak BOD settings.
Setting the BOD level to 2.7V helps prevent a condition where the MCU
partially fires up during connection of power.
2017-07-25 18:40:52 +10:00
3a63ab2951
attiny861 main: Simplify button logic.
Rather than having "hit" and "release" events, we just monitor the
debounced button state.  This is less likely to "stick" and is
sufficient for the job.
2017-07-15 17:24:57 +10:00
b0aeaab41e
attiny861 main: Add button auto-detection 2017-07-15 16:30:25 +10:00
98df61229d
attiny861 main: Use switch instead of if.
Years ago, and on MSP430 not AVR, I found that gcc produced tighter code
using `if` instead of `switch`.  Thus, I found myself always using `if`
and never `switch` if I needed branching, since smaller code is faster
code, and we needed all the speed we could get.

Turns out, AVR does not have this problem, and we get better performance
using `switch`.
2017-07-15 15:59:49 +10:00
b6e678f045
attiny861 poly_cfg: Drop sample rate to 8kHz
With the extra processing needed to get bleed-free LED control, we can't
quite make 16kHz sample rates.
2017-07-15 15:55:06 +10:00
0ef982d463
attiny861 main: Fix adjacent light channel bleed.
Move to a 3-state machine for PWMing lights so that we don't get bleed
from one channel into the next due to propagation delay in the 74HC574.
2017-07-15 15:41:20 +10:00
7bb914755c
attiny861 main: Hard-code buttons to channels.
Rather than hunting for a free channel, just hard-code the button to the
channel.  This gets polyphonics sort-of working: both notes are
out-of-tune which suggests the CPU isn't keeping up.
2017-07-15 15:22:21 +10:00
aeefd70fe3
attiny861 port: Fix annoying pop on each note.
It seems when the NJM2113 is first powered up, it emits a pop noise.
Not much I can do about that.  The thought was I should power down the
amplifier when it is not in use to save power.

The outcome is on each note, it would power the amp up, and it would
pop.

Solution: create a 1msec timer for general timing events, and use that
to count down one minute before powering off the amplifier.  The toy
will pop on first power on, then if left alone for a minute, will pop
again on the first note, but will not pop so long as there's only short
gaps between notes.
2017-06-11 16:09:42 +10:00
f982e0c31f
attiny861: Bump amplitude up.
Since the number of notes possible with this device is small… in fact,
it seems to only want to do monophonics, not sure why, we can bump the
amplitude up a bit more without risk of saturation.
2017-05-28 11:08:18 +10:00
cf587e3fd8
attiny861 port: Clear button hit/release events at power-on.
This prevents all the notes being played all at once on power-on.
2017-05-28 11:01:32 +10:00
e75d75d20b
attiny861: Enable pull resistors when reading.
Set PORTA to all ones to enable the pull resistors on all pins.
2017-05-28 10:43:27 +10:00
0bed82802b
attiny861 port: Bump sample rate
Seems we can handle 16kHz sampling… but not 32kHz.
2017-05-28 10:25:21 +10:00
75fe949f27
attiny861 port: Semi-working version.
This implements detection of the pressed buttons, with software
debouncing, and plays a note indefinitely until the button is released.
The corresponding LED's amplitude is modulated by the ADSR envelope.
2017-05-28 10:19:05 +10:00
f2fac87ba3
main: timer: Invert button states
There's a pull-up with the button asserting a logic low, so invert the
inputs.
2017-05-27 15:01:41 +10:00
f8346cdea9
Add ATTiny861 port.
The ATTiny85, as good as it is, has too few pins to really do a lot.
You can buy I²C GPIO expanders, but many cost more than programming an
ATTiny24A (which has more brains).

The nearest equivalent is the ATTiny861, it is basically the same core
as the ATTiny85, features the same PLL for high-speed PWM, but comes in
a 20-pin package.  They cost ~AU$3 in individual quantities.  (An
ATTiny85 costs AU$1.74, an ATTiny24A costs AU$1.57; thus you save about
20c and a lot of interfacing effort in going to the '861.)

Thus it can interface to 8 individual switches with ease.

The circuit here uses a 74374 D-latch to drive up to 8 LEDs with PWM and
two 4066s to isolate the 8 inputs.  Idea being, when the GPIO_EN signal
is high, the 4066s are turned on and port A sees the 8 GPIO lines on the
other side of the 4066s.

4066s were used because I have 4066s up the wazoo… bought a box of
random ICs off eBay many years ago and it came with 5 (!) tubes of
MM74HC4066s with 25 ICs each (amongst other parts, some hard-to-find).
The bonus being these can be ADC inputs too if desired, allowing sensing
of piezo sensors.

When we want to switch which LEDs are turned on, we bring GPIO_EN low,
switch port A's pins to outputs, assert the desired LEDs, then bring
GPIO_EN high again.  The 74374 latches those pins, and we are free to
put port A back to being inputs.

This happens with each sample from the synthesizer, alternating between
input and output.  Thus the effective rate seen on the LEDs and inputs
is half the sample rate.

A spare GPIO is available for turning on and off an amplifier (I use the
NJR NJM2113D) to save power.

The 74374's nOE pin is connected to the PWM output for the lights, thus
using pull resistors, one is able to use the one PWM channel for all 8
lights.  The lights are turned on in round-robin fashion, so effective
duty cycle is ⅛ and the refresh rate is ~500Hz.
2017-05-20 20:48:19 +10:00
6ddaad18f2
attiny85: Add ADC-based keyboard support.
This is a work-in-progress, but we're now able to play some notes by
pressing keys.
2017-05-01 17:38:17 +10:00
3ff3e349f5
attiny85 Makefile: Add main.o and adckbd.o to object list. 2017-05-01 17:37:48 +10:00
8333f32d26
pc Makefile: Add main.o to port object list for PC 2017-05-01 17:37:22 +10:00
aa3771dc78
adckbd: Add first stab at ADC-based keyboard.
This works by relying on a resistor ladder that is part-shorted-out by a
button to Vcc.  The ADC detects the button pressed from the voltage seen
on the ADC.

There's some work to be done on this yet.
2017-05-01 17:35:19 +10:00
17599177cb
ports/attiny85: Looping sound effects.
It sounds like the crappiest doorbell you've ever heard, but we now get
a crude "ding dong" effect with this code, on a loop.
2017-04-09 10:17:49 +10:00
fb59c52b71
ports/pc: Start playback when enable ≠ 0.
After configuring the voices, we start playback until all channels stop.
2017-04-09 10:13:29 +10:00
093b6dd888
ports/attiny85: Set sample rate to 8kHz 2017-04-09 09:17:28 +10:00
3f7c6353c1
ports/attiny85: Remove debugging #if blocks 2017-04-09 09:17:04 +10:00
b1ddd0c099
ports/attiny85: Define program target 2017-04-09 09:16:50 +10:00
9bba7c0c19
ports/attiny85: Work in progress ATTiny85 port 2017-04-09 08:24:14 +10:00
9f3cd37109
ports/pc: Set default target in Makefile 2017-04-09 08:23:33 +10:00
06199b7da8
pc/main: Tweak output 2017-04-08 21:53:12 +10:00
e24cf7376e
ports/pc: Debugging, bugfixes. 2017-04-08 20:56:03 +10:00
35e7d5ed9a
Beginnings of separate ports. 2017-04-08 20:23:26 +10:00