Log
---
- dynamic height and width
- stopping and starting via space
- seeking
- background
- edit different units
- update last measure is recognized by moo
 - configurable quantization
   - toggle on / off
   - drop down for speccing it
- play / stop buttons
- Saving file
- middle click drag
- have it look decent on scroll limits
5/31
- hear note on play (HARD) - had to factor out the logic independent of the current unit play position
- fix the offset
- zoom according to where cursor is right now
- tried the linear smoothing thing. it was way out of wack. not convergent.
- undo

6/04
- Implement the undo system drawpile uses
- Fix a few things like broken redo (no more chnaging of length 0)

6/6
1. Hook up the network. didn't get working b/c I was distracted but things are
   sending and I think they're generally connected!
2. Status bar, saving with network, reconnecting / starting new server etc.
3. Send view changes / edit state changes.
4. Redo in the right order
5. Demo it in a video, test with friends

6/7
1. Fix issue where other ppl's cursors show up in the wrong position
2. Hook up show-all checkbox properly
3. Users can specify names, show up next to cursor
4. Cursor disappears if user leaves / disconnect from server
5. Show list of connected users on left
6. fixed random bug where startup would loop forever if the file was too big

6/8
1. fix crash when you hold down a non-looping sample for too long
2. realize it's hard to fix the blip
3. I think fixed crash on server restart

6/9
1. alt scroll to change quant
2. ... read a bit about wav formats, turns out there's 8&16 bit linear PCM,
   then 32-bit float and 8-bit mu/a-law. pxtone only supports linear pcm but
   apparently that's usually enough?

   pxtnPulses are the wav / ogg / pt{voice,noise} loaders. pxtnwoice is like a
   variant over them that is the actual voice. then unit is unit.
   use pxtnService::Woice_read pxtnWoice::read to create a new instrument

   the io mate fns are for reading from an existing project.
   what's an assist woice / unit? they're names.

   pxtnUnit is largely - moo state (current woice, pan buffers), names, porta
   state. We could probably just make an extra pxtnUnit for note previews??

   Or still, just make pxtnWoice get stuff for you. Prob better b/c you can
   just directly set the woice. The only thing the unit sampl provides is vel,
   vol, and vol panning. Increment sample doesn't depend on the unit at all
   outside of woice.

6/11
1. Read about qlistview

6/12
1. ability to add units

6/13
1. this std::variant thing worked?!?
2. removing units
  - confirm box for delete
  - autofill name, double click to add
  - switch to unit directly

6/14 
1. more generic binary serialization
2. hopefully unicode?
3. fix crash when you rejoin. it was a deserial transaction mistake!
4. Add instruments! - lots of fumbling around with descriptor
5. remove instruments
6. sticky vel
7. host empty

6/15
1. Build windows version

6/16
1. Fix double voice issue with release rclick
2. Don't use shared ptr array, hopefully better fix now?
3. Exit menu item

6/17
1. fix Save As in windows (save to original file is still broken)
2. fix save to original file in windows. I think?
3. tested 'cross platform' by running in wine simultaneously with linux lol

6/19
1. Discovered that there's a problem with soft disconnects.

6/20
1. headless server sort of

6/21
1. Added logging, I think the thing causing the disconnects was the fact that
   transactions were being added up. So a rollback must've caused like a
   cascade of events written and made the write state weird. (Thanks to tests
   with steedfarmer)
2. Tested with steedfarmer again with the soft disconnect fix. Indeed, no more
   soft disconnects. But still the program sometimes hangs + memory explodes.

   Discoveries:
     - Sometimes a message is not sent if an instrument is simultaneously being added.
     - Hanging seems to be during repeated application of event undos/redos.
     - Hanging happens (in one case at least) after an edit message is dropped
       in roundtrip, prob. because that leads to a ton of local undo/redos.
       - I did see in my debugger like, 200k actions trying to be applied. I
         have no idea how it got to that number.
     - Turns out a message is dropped because QDataStream is not writable if we
       are simultaneously reading from it and hit ReadPastEnd. Dammit. Need
       separate read / write stream
     - But still, why does the action list grow to be so large? that's crazy.
       why does that cause things to hang? And was it really large? Or just
       that things sort of piled up with every additional message?

6/22
1. Figure out bug that causes hanging when an edit action is dropped. When
   having to undo and redo a lot, empty commands get added exponentially.
2. Find and fix a separate bug regarding using the wrong pxtone state to
   compute an undo. Didn't cause any problems this time but could bite in the
   future (e.g., two identical delete would be 'undone' as 2 identical adds
   instead of the second doing nothing)
3. Address QTBUG-63113 by having separate read / write streams. Now messages
   aren't dropped. Or they shouldn't be.

As a general note it's increasingly scary to touch the networking code...
worried about making further breaking changes. Don't have tests, also testing
localhost is just not the right environment.

This kind of thing where msgs get dropped is interesting - seems like a gap
fill architecture could work well.

4. Robust if you see an unexpected message (postel) from yourself.
   - if see later remote id, than what expected, just drop things presumably missed.
   - if earlier, just slot it in b/c everyone sees it in that order.

5. Ability to make server delay / drop msgs artificially

6/23 & 6/26
1. Some playtesting!

6/27
1. Add some slack in vertical momement before adjusting velocity
2. Cleaner note params on new note
3. See existing note velocity
4. Render just the window, less expensive note velocity (no more sqrt / exps)
5. Factor out moo state.
  - Accurate note preview: proper state at time of note w/ params of note.
  - Can still factor out more depending on what kind of preview to isolate.
    Current setup just makes it easy to configure a unit and then just play.
6. A tricky thing to get smooth playhead. Also renders better when there's a
   bigger buffer I think.

6/28
1. Note previews 
2. Small editor QoLs:
   - append .ptcop to save.
   - update add unit dialog to just use the selected voice.
   - fix small bug in smooth playhead
   - escape focuses the keyboard editor (is this really an improvement?)
3. Replace woice. (Was pretty painless, thanks to the variant setup earlier!)
4. Package for windows, add icon
5. Fix overlapping note previews if you had a trackpad and mouse.
6. Click+scroll can also adjust velocity

6/30
1. Selection

7/1
1. Transpose with selection. But at what cost? Undos are a bit jank with the
   mechanism for existing undos. (Perhaps undoing a tranpose should always
   cause the transpose op to go at the end? Though I don't think it'd play well
   with the sync setup. Another option: vertical shifts are tracked in separate
   d/s (interval tree of offsets representing offset over time) and modify set
   values as postprocessing. This might be a good solution for hshifts too.)
2. Shift+u/d to transpose, else shift vel. Ctrl for wide shift.

7/2
1. Select all

7/3
1. Copy and paste for one unit
2. Clear / cut for one unit
3. Not doing hshifting -- too hard with collab, if you undo others' notes will
   be displaced. If it is done, will prob. have to be separate prim action from
   paste to avoid desync.
4. Unit list table - current unit depends on selection; mute / visible depend
   on checked

7/4
1. Make it easier to check / uncheck
2. Don't highlight / grey muted things out
3. Transpose, copy / paste multiple units
4. Reinstate the add unit dialog.
5. Tempo, time signature controls. Hopefully not too jank.

7/9
1. Fix an undo bug hopefully (undone were not invalidated by a new write)

7/10
1. Fix selection rendering weird if zooms differ
2. Forbid selecting below time 0
3. Change a thing that could've caused crash on server connect.
4. Changed 'muted' column to 'played' since the checked = muted was a bit unintuitive
5. Outline selected notes on chosen units and show their vel.
6. Ctrl+D to deselect
7. Preview at different pitches / velocities based off last note input
8. Smaller audio blip after a seek. 

7/11
1. Factor out moo state... but at what cost?

7/14
1. Undo this smaller blip thing because it causes windows to be incredibly slow.

7/16
1. Refactor a ton of stuff to get signals and state centralized.

7/17
1. Display vel, vol, pan params
2. fix scrolling not lining up with mouse

7/18
1. Param edit
2. Fix side menu dropdown not affecting quantization

7/22
1. Playhead, repeat meas in param bar too
2. Mouse / wheel shortcuts in param bar
3. Set loop points from selection
4. follow playhead

7/23
1. Fine tune param - like a volume param
2. portamento param - drag like in ptcollage
3. show effect but no edit

7/25
1. Hopefully fix bug where setting beat up after repeat causes weird jump
2. Set group using same param view as others but w/ 6 notches.
3. Shortcuts for cycling param
4. Edit unit names
5. Modify effects
6. Draw params for other units in lower alpha
7. Ongoing edits for other units in lower alpha
8. experimental thing to draw adjacent portas 
9. Seek in param bar

7/26
1. Change woices of unit
2. Copy option for params, display selection in param view
3. Transpose param
4. Note previews on param input
5. Sane velocity setting (you can only modify existing velocity events)

8/8
1. Clear last meas / repeat meas if selection is not there

8/10
1. Fix scroll wheel jumping if at end and zooming in
2. Some jank stuff so that adding / changing instr doesn't reset selection or
   cause spurious note preview
3. Add and change voice dialogs use the same starting dirs now

8/11
1. Velocity is set based off what the existing velocity is
2. Adjust jump when too far left or right

8/17
1. Woice properties

8/18
1. Rearrange units
2. Slider for volume, buffer size

8/22
1. Previewing a bad file does not crash the editor
2. Moving units up and down doesn't cause transpose to break any more

8/23
1. Moving units up and down doesn't cause velocity setting to affect the wrong
   unit

9/14
1. Add icons
2. Slightly better buffer settings. Still bad on windows though

9/19
1. Split help menu, tooltips for icons
2. Save confirmation
3. Save username, connection destination, port
4. Note preview is affected by volume now
5. Easier voice selection via menu
6. Subtle highlight on root note

9/20
1. A few more keyboard shortcuts (pgup/dn, fn keys, 1..9)
2. Preview with changing voice is now at the right pitch
3. Fix tiny bug that let you delete velocity events
4. Set repeat and last flags
5. I think note previews are fast on windows now

9/25
1. Highlight row on play or on input
2. Remove blip after play
3. Dark mode icons

10/4
1. ptcollage-like palette by default. thanks gkpotter for extensive ui feedback!

10/5
1. Watching other users
2. Recording sessions that you can jump into live (bit janky)

10/7
1. Prepare video (thanks gkpotter, arcofdream for feedback!)

10/8
1. new session dialog
2. scroll to start on song load, reset some other state
3. connect dialog
4. Show ping
5. Watch other users includes getting updates for their play states.
6. Don't show 'hosting on' and 'connected to' simultaneously

10/9
1. cleaner fps
2. save session recording to 1 file
3. test + make watch a bit more robust

10/10
1. appimage, standardize enum sizes
2. cleaner user list
3. Some fixes with watching another user randomly stopping
4. If the playhead passes over the last event, new events added to the song
   will still be played.

10/11
1. Build on mac
2. Better help
3. Update pages
4. mac icons
5. Record again

10/17
1. Use shift-JIS
2. escape once brings you back to previous position, escape twice to beginning
3. Draw playhead / last seek more consistently among 3 views

11/07
1. mute/solo shortcuts
2. when inputting a note, preview everything else with it
3. drag near the sides of the keyboard window to have it scroll for you

11/08
1. better command line arg, hopefully can dbl click
2. drag and drop projects and instruments
3. tiny bug where new project doesn't reset the project workspace
4. Don't show server restart confirm if you're the only one connected
5. Copy / paste across multiple projects

11/09
1. wav export
2. verify files can be opened in windows via file association.
  - make sure old file doesn't exist, or else association is cached

11/10
1. change note length (unit edit under ribbon)
2. quantize note preview time in param / measure view
3. fix being able to set parameter above max

11/11
1. update guide

1/15/21
1. ui options:
 - spacebar is stop instead of pause
 - no velocity adjustment with vertical
 - invert scrolling / zoom options

1/16/21
1. ui remember menu / bottom bar size
2. rename a few menu options
3. chord preview respects mute

1/18/21
1. PLayhead jitter in real time
2. note preview in top bar too

2/24/21
1. multi select in add woice
2. some debug checkboxes for ptcollab

2/28/21
1. don't save dialog dir except at start

3/2
1. auto add unit with each woice
2. woice preview in add unit window
3. Woice preview in unit tab for current time
4. ijkl for midi input
5. alt Q to quantize

3/3
1. finickiness with input at boundary
2. bug with auto adding unit when woice name is too long
3. fix seek not catching upf or a long time if you seek past end
4. don't show other people's ongoing midi inputs, it was too hard to sync
playback
5. auto step forward on note input
6. copy options and default

3/4
1. fix preview with all units brekaing with unit click preview
2. polyphonic midi note preview

3/7
1. hopefully fix the 'hosting but not connected' error by using local session

3/21
1. don't crash if selecting port that is already in use (thanks ewan for the report!)

5/12
1. Draw the current instrument above everything else
2. Don't preview notes when clicking in the sidebar if the song is playing

5/28
1. fix clicking on certain projects with echo

5/30
1. (internal) make remove/changevoice take id instead of no + name
2. menu item to 'remove unused units' and 'remove unused voices'
3. render volume option
4. dialog for copy options

5/31
1. fix silent cxn fail if you connect after a connection failure

Todo by priority
----------------
 - show other's midi inputs if you're either following the or they're not playing
 - midi input: mute the unit regularly if you're recording, also record silence? Maybe idk
 - Unit view, at least for drums
   - how many views do you want? the fewer, the easier it is to be 'present'
     with others.
   - something like ptweb
     - can pin instruments to be drums. (list of pinned is global)
- when following and someone does midi it can mess you up
- save dialog state instead of just last dir <- not that easy since you gotta save the state at diff places and the ptrec key is useful for the host dialog prefill

Misc todo by categories
-----------------------
Aesthetics:
  - The units view is not pretty right now. Unit should have mute icon, visible
    icon, copyable icon. One unit should be selected at a time.
  - customizable piano roll colours
  - qwerty midi input
  - tab system to edit multiple files at once / switch between sessions
  - arcofdream's icon designs for the connect / disconnect menus
  - write / read shiftJIS in unit, woice names.
 - coarse tune
 - piano roll on the left

Technical stuff:
 - server keeps its own state (e.g., active users) + running history (currently
   it plays back -everything-)
   - probably goes hand-in-hand with undo stack, which drawpile limits to
     globally 30. probably a good idea so we don't keep on growing in memory
   - cheap to have large stack
 - seqnums on the server messages.
   - robust if you see an unexpected message from elsewhere (unexpected server
     seqnum?)
   - note: without seqnums, clients do not have a chance if server drops msgs
     to some clients but not others, without seqnums
 - place to see errors like missed writes or unexpected IDs.
   - log on server side history of actions too (maybe exclude editstate).
   - log if a message hasn't roundtripped in a while (consider if there's
     any expected situation where we don't expect roundtrip. prob. not if like
     drawpile)
   - also if a pxtone action returns false
 - put hello in the protocol.
 - put ping in protocol
 - placing notes is choppy in windows because of note preview lag. how to fix?
   wasapi? miniaudio?
 - static build
 - scroll sometimes desyncs on ptcop load?

Editor functionality:
 - echo & overdrive
 - moving voices up and down
 - edit voice, unit names
 - set voice - will need map from voice id to no
   - can drag a time interval and set with that unit / clear unit
 - low-precision key correct param (24 -> 1 octave)
 - some kind of sine wave param or note setting?

Editor QoL:
 - Time bar at the top
 - Don't scroll if last measure changes from some other user
 - v to solo visible. s to solo playing? - overrides checkboxes.
 - follow playhead (seems low pri since no one suggested)
 - ctrl+shift+click is a bit much to do a selection. but ctrl click is note
   tool. Maybe it shouldn't be a modifier but a mode? tools seem reasonable.
 - Better woice previews
   - idea: the pitch could be determined by the last note pressed in a keyboard
     (that has yet been added). this can avoid complicating the file dialog.
   - Add a 'stop all note previews' button
   - Perhaps you could show a mini keyboard for previews under the woice list.
 - see other user's playhead optionally
   - involves: messages for seeking, starting, stopping with clock at X
   - would be real nice to click on a user and jump to their view
     - client would match the seeks and play controls, slightly delaying
       depending on clock desync.
     - client view would also just centre on the other's cursor. prob. with
       matching zoom; or, (harder, not much gain) match window bboxes
 - Play audio while paused but seeking!
 - Scroll if clicking and on edge of pane
   - Not too big a deal - if you need a big interval, zoom out
 - Speed things up.
   - Separate audio thread with locking.
   - Bounding boxes for the undos/redos
     - At least on remote action rollback. You have to undo a prefix from the tip.
     - Also possibly useful for actual undos.
       - actually probably not useful for actual undos because there are cases
         where you'd have to roll everything back anyway.
   - Indexes for searching through list fast
     - according to botb event limit is 500k in the regular editor; here the
       limit is 1M.  could probably handle 1000 events with little lag (1000
       events * 1000 actions = 1M iterations, not too much)
   - Pastes are slow for big songs b/c have to traverse whole evelist for each
     action. Maybe give a hint?
 - don't blip when seeking and playing again (hard due to QAudioOutput behavior)
 - Edit while playing soundness (low priority, unlikely to hit)
   - Add things between last event and next (before / after now?)
   - Delete things. Don't strand the pointer
   - Adjust the length of ON
 - once you click with shift it should stay in seek mode until release.
 - ctrl+shift+alt+click to select snap to measure? sounds a bit crazy honestly.
 - maybe offer quant option for measure (instead of snap to measure select)
 - note preview vel should not be adjustable if you're editing note instead of on
 - allow zero selection interval, and restrict to selection interval if
   nonzero? prob not bc ptcollage doesn't
 - copy / paste improvements
   - maybe slight desync in case haven't seen others' edit? but sort of inevitable.
   - also copy start vol / pan values / tails of an on event.

Low priority:
 - Editor UI: Piano on the left
 - Misc UI: Recent connections dropdown
 - Custom icon for people's names?
 - scale selections by time (with no quantize), then quantize
 - Undo transpose make less jank
 - A chat

Just general format? improvements:
 - A kind of meta instrument that changes depending on parameter or pitch

Running thank-you list:
- Pixel for making such an awesome music software!
- Everyone involved in ptweb!
- Friends and family for supporting this!
- jaxcheese, neozoid, steedfarmer, ewangreen for testing out with me, making
  tunes together, and giving great feedback!
- steedfarmer for helping me hunt down this nasty networking bug!
- arcofdream for helping conceptualize the UI, giving feedback, and testing it
  out!
- arcofdream, nanoplink, easynam for general programming, UX discussion and
  consulting!
- jade for testing, finding UI bugs, and providing valuable suggestions!
- gkpotter and arcofdream for helping with publicizing this!
- everyone in the pxtone discord servers!
