Commit Graph

45 Commits

Author SHA1 Message Date
kris
38280e7d93 Add more audio file types 2020-12-28 13:23:18 +00:00
kris
d4bc2d45e5 Parametrize options by command-line flags 2020-12-28 12:54:44 +00:00
kris
4090c502a8 Add back preprocess_audio for converting audio sample rate. It's
faster to do this once when converting an audio file many times.
2020-12-28 12:54:39 +00:00
kris
4666171aaa Count and report on the number of speaker toggles/sec during encoding. 2020-12-28 12:30:29 +00:00
kris
a1a1f33c21 Add partial support for 4-cycle NOP; NOP opcode pairs
Count and report on the number of speaker toggles/sec during encoding
2020-12-28 12:29:05 +00:00
kris
089591737f Regen 2020-12-24 14:44:19 +00:00
kris
cef38dae59 Comment nit 2020-12-24 14:44:09 +00:00
kris
4701dc14f1 Regen 2020-12-24 14:43:51 +00:00
kris
93b63db558 Use the correct effective clock rate for a PAL Apple II, taking into account the long cycle. 2020-12-24 14:43:00 +00:00
kris
0bb7871355 Allow padding out the full $300 page with opcodes, sorted by the
number of non-NOP opcodes to give the most opportunities for speaker
actuation.

Use float32 in opcode code.
2020-12-24 14:40:26 +00:00
kris
c776b3cbe2 Refactor to allow passing in other opcode sequences 2020-12-07 21:06:00 +00:00
kris
baca499d3b Checkpoint 2020-12-07 20:58:34 +00:00
kris
f1b6983dda Last minute tweaks 2020-12-07 20:58:18 +00:00
kris
706ba54f5b Further significant optimizations:
- Switch some matrices to column-major order, since they usually have
  more rows than columns.  This turns out to be slightly faster.
- Precompute more of the speaker trajectory formula, since most of it
  only depends on the matrix of applied voltages (which only depends
  on frame_offset).

Bug fixes:
- make sure to leave enough 0-padding at the end of input data in case
  we schedule a SLOWPATH towards the end, since we'll skip into this
  buffer.
- Pad the last TCP frame with EXIT opcodes instead of TICK_00.
- Improve the eta counter behaviour by not setting a minimum tick
  interval, and being more careful about when we update.  This fixes
  issues with short files
2020-12-07 20:48:15 +00:00
kris
54369a620f Wrap line 2020-12-07 20:48:05 +00:00
kris
194da9a509 Check in generated player using NOP, NOP3 and STA opcodes, to max
cycle length 19.  This seems to give the best quality so far.
2020-12-07 20:40:00 +00:00
kris
1cf1ed25bb Don't start opcode sequences with NOPs, the encoder mostly avoids
these so they just waste space without improving quality.
2020-12-07 20:38:58 +00:00
kris
b8de1d4f7b Fix a serious bug in cycle_lookahead, it was not flipping the opcode
voltage schedule based on the last value of the previous opcode.

In candidate_opcodes, return the hash of pruned_opcodes as well (since
this is relatively expensive to recompute), so this can be used to
precompute and cache partial results of applying the opcodes.
2020-12-07 20:34:57 +00:00
kris
ccc8594c45 Clean up more.
Switch back to longest opcodes first, it is both smaller and slightly
better quality (~3%).
2020-10-15 20:28:26 +01:00
kris
76d6bc8426 Integrate generated player code 2020-10-15 14:27:37 +01:00
kris
22babbaa73 Parametrize normalization percentage 2020-10-15 13:08:33 +01:00
kris
3ef80ec6cf Overhaul README to describe current status. Still some work needed. 2020-10-15 11:31:25 +01:00
kris
f17db175a5 Simplify 2020-08-25 21:57:42 +01:00
kris
659d9906bd Generates player audio code and encoder representation, by enumerating
all combinations of 6502 opcodes and deduplicating.
2020-08-25 21:54:46 +01:00
kris
8122f65dc6 Optimize memory and speed. 2020-08-25 20:46:00 +01:00
kris
938fbae488 Optimize evolve() by expanding recurrence relation 2020-08-24 22:28:28 +01:00
kris
7a4a36af6b Checkpoint WIP
- use exotic opcodes in player
- optimize encoder
2020-08-24 21:27:24 +01:00
kris
5fb995c435 Credit Scott in README 2020-08-16 23:19:48 +01:00
kris
4767ee51fd Fixup player timings and opcode variants for 65c02 timings since JMP
(indirect) takes 5 cycles not 6!  It should be possible to also
accommodate 6502 timings in a followup.

h/t to Scott Duensing who noticed that my sample audio sounded "a tad
slow", which turned out to be due to this 1-cycle difference (which
added up to almost an extra minute playback to an 8-minute song).

Add comments and tidy up the code a bit.

Flesh out README some more.
2020-08-16 23:15:30 +01:00
kris
9e0e1fcbcb One more fix 2020-08-15 23:24:25 +01:00
kris
790c2bc1ec Revise and update 2020-08-15 23:22:27 +01:00
kris
86cd1e1114 1MHz encoder and player
- we simulate the speaker at full 1-cycle resolution, and
  evaluate all possible opcodes that can be scheduled for the
  given position in the TCP stream
- this lets us tick the speaker at any cycle interval >=9 (except 10
  cycles)
2020-08-13 22:08:50 +01:00
kris
eeeb457b23 Add an example file. This was encoded with lookahead 11. 2020-08-12 22:10:38 +01:00
kris
08f3a58a7f Add missing makefile and tidy up a bit. 2020-08-12 22:08:27 +01:00
kris
9c08e31cb0 Remove dead code and assemble at $2000 instead. 2020-08-12 21:48:54 +01:00
KrisKennaway
ebe9cd688e
Happy 70th birthday Woz! 2020-08-12 00:14:20 +01:00
kris
b35e4f86fb Add shebang and tidy some more 2020-08-11 23:26:55 +01:00
kris
1bbbd8c154 Merge preprocess_audio back in. We didn't end up getting a speed
boost from pypy, perhaps because the critical path is in numpy code.

Add some comments and clean up a bit.
2020-08-11 23:23:33 +01:00
kris
7ff129346e Merge branch 'master' of https://github.com/KrisKennaway/ii-sound 2020-08-11 23:18:28 +01:00
kris
61cdda6cd1 Rename 2020-08-11 23:18:20 +01:00
KrisKennaway
1b2eede9fb
Create README.md 2020-08-11 23:17:46 +01:00
kris
1d8ed9e8aa Clean up, add comments and include disk image 2020-08-11 22:36:33 +01:00
kris
2f341bda99 Support files for btc build 2020-08-11 21:53:48 +01:00
kris
0f8ad1bf17 Checkpoint working code that implements delta modulation with look-ahead.
I split out preprocess_audio because scipy/librosa don't run under
pypy and I was hoping that would speed up the encoding, but it does
not for some reason (maybe numpy interactions?)

Anyway, I should be able to vectorize the slow path which will likely
help a lot.
2020-08-10 21:03:12 +01:00
kris
d283789199 Initial commit of working delta modulation playback over ethernet
(moved over from rewolf repository).

Using a 13-cycle period neatly divides the 65-cycle 'long cycle'
period of the Apple II which avoids audio transients when playing
'silence'.  This also aligns with the horizontal refresh period which
should make it possible to do some interesting visual effects.

TODO
- implement predictive encoding that looks ahead to next N samples and
  minimizes average error.  This should improve quality

- get page-flipping effects looking nice
2020-08-07 12:50:32 +01:00