# Post-generation data editing

- Some post-generation editing may be occasionally desired.
- Third-party software to tweak the eps/pdf output
    - Adobe Illustrator
    - Inkscape (open source)
- Importing MIDI output into notation software
    - Finale
    - Sibelius
    - MuseScore (open source)
- Edit LilyPond files directly.
- Manipulate data within slippery-chicken object after generating
    - Before creating output.

----

## Events vs. notes

- Event: individual rhythm object, either a note or a rest.
    - Plus all related data, e.g. duration, pitch, marks, clefs etc.
- Note: non-rest event object.
- Some methods count events, some count notes.
    - Most are 1-based.

----

### Example of getting the first event object in a bar

    (let* ((mini
            (make-slippery-chicken
             '+mini+
             :ensemble '(((vn (violin :midi-channel 1))))
             :set-palette '((1 ((c4 d4 e4 f4 g4 a4 b4 c5))))
             :set-map '((1 (1)))
             :rthm-seq-palette '((1 ((((2 4) (s) (s) e e e))
                                     :pitch-seq-palette ((1 2 3)))))
             :rthm-seq-map '((1 ((vn (1))))))))
       (data (get-event mini 1 1 'vn)))

    => S

----

### Example of getting the first note from same bar

    (let* ((mini
            (make-slippery-chicken
             '+mini+
             :ensemble '(((vn (violin :midi-channel 1))))
             :set-palette '((1 ((c4 d4 e4 f4 g4 a4 b4 c5))))
             :set-map '((1 (1)))
             :rthm-seq-palette '((1 ((((2 4) (s) (s) e e e))
                                     :pitch-seq-palette ((1 2 3)))))
             :rthm-seq-map '((1 ((vn (1))))))))
       (data (get-note mini 1 1 'vn)))

    => E

----

## Basic usage 

- All post-generation methods take an sc object as the first argument.
    - Can also be the global variable created for the sc object.
    - Or a variable to which that object has been assigned.
- Remaining arguments generally:
    - bar-number 
    - player
    - event- or note-number 
    - new value.
- Specific arguments required can be found in the source code documentation.

----

### Basic usage example: Adding a dynamic mark

    (let* ((mini
            (make-slippery-chicken
             '+mini+
             :ensemble '(((vn (violin :midi-channel 1))
                          (va (viola :midi-channel 2))
                          (vc (cello :midi-channel 3))))
             :set-palette '((1 ((c3 d3 e3 f3 g3 a3 b3 c4 d4 e4 f4 g4 a4 b4 c5))))
             :set-map '((1 (1 1 1)))
             :rthm-seq-palette '((1 ((((4 4) - e (e) e e - (e) - e e e -))
                                     :pitch-seq-palette ((1 2 3 4 5 6)))))
             :rthm-seq-map '((1 ((vn (1 1 1))
                                 (va (1 1 1))
                                 (vc (1 1 1))))))))
       (add-mark-to-note mini 2 4 'va 'ppp)
       (cmn-display mini))

----

## A few specific methods for post-generation data editing

- `change-pitch`. Change the pitch of a note. 
    - Arguments: sc-object, bar-num, note-num, player, new-pitch. 

    `(change-pitch +sc-object+ 3 2 'va 'c4)`

- `add-mark-to-note`. Add articulation, dynamic, or other mark to a note.

    - Arguments: sc-object, bar-num, note-num, player, mark. 

    `(add-mark-to-note +sc-object+ 3 2 'va 'ppp)`

- `rm-marks-from-note`. Remove one or more specified marks from a note. 
    - Arguments: sc-object, bar-num, note-num, player, mark.

    `(rm-marks-from-note +sc-object+ 3 2 'va 'ppp)`

- `trill`. (LilyPond only.) Add a trill, with trill note.  
    - Arguments: sc-object, player, start-bar, start-event, trill-note;
     &optional end-event, end-bar.

    `(trill +sc-object+ 'va 3 2 'd4)`

----

- `tie-over-rests`. Extend duration of note over all directly subsequent rests.
    - Arguments: sc-object, bar-num, note-num, player; &key end-bar, auto-beam,
      consolidate-notes.

    `(tie-over-rests +sc-object+ 1 1 'va)`

- `tie-over-all-rests`. Extend duration of all notes that immediately precede
  rests over all directly subsequent rests.
    - Arguments: sc-object, player, start-bar, end-bar; &key arguments
      :start-note, :auto-beam, :consolidate-notes

    `(tie-over-all-rests +sc-object+ 'va 1 3 :consolidate-notes t)`

- `re-bar`. Reorganize the data of an sc object into new bars of specified
   length. 
    - Only combines short bars into longer ones.
    - Best when used with the :min-time-sig argument.
    - Arguments: sc-object; &key start-bar, end-bar, min-time-sig, verbose,
      update-slots, check-ties, auto-beam

    `(re-bar +sc-object+ :min-time-sig '(4 4))`

----

- `move-events`. Copy all events from one player to another and delete
 original.
    - Arguments: sc-object, from-player, to-player, start-bar, start-event,
      end-bar, end-event. 

    `(move-events +sc-object+ 'vn 'vc 1 1 3 1)`

- `double-events`. Copy all events from one player to one or more other
  players, without deleting the original. 

    - Arguments: sc-object+, master-player, doubling-players, start-bar,
      start-event, end-bar, end-event &key transposition, consolidate-rests,
      update 

    `(double-events +sc-object+ 'vn '(va vc) 1 1 3 1)`

----

## All post-generation editing methods

\footnotesize

-------------------           --------------                ---------------
add-arrow-to-events           add-tuplet-brackets-to-beats  delete-clefs
add-clef                      auto-accidentals              delete-events
add-event-to-bar              auto-beam                     delete-rehearsal-letter
add-mark-all-players          auto-clefs                    delete-slur
add-mark-before-note          auto-slur                     double-events
add-mark-to-event             change-bar-line-type          enharmonic-spellings
add-mark-to-note              change-pitch                  enharmonics
add-mark-to-notes-from-to     change-pitches                force-artificial-harmonics
add-marks-sh                  change-time-sig               force-rest-bars
add-marks-to-note             consolidate-all-notes         map-over-bars
add-marks-to-notes            consolidate-all-rests         move-clef
add-tuplet-bracket-to-bar     delete-bars                   move-events
-------------------           ----------------              ------------------


----

\footnotesize

-------------------           --------------              ---------------
note-add-bracket-offset       rm-marks-from-notes         rm-slurs
process-events-by-time        rm-slurs                    set-rehearsal-letter
re-bar                        sc-delete-beams             tie
remove-extraneous-dynamics    sc-delete-marks             tie-all-last-notes-over-rests
replace-events                sc-delete-marks-before      tie-over-all-rests
replace-multi-bar-events      sc-delete-marks-from-event  tie-over-rest-bars
replace-tempo-map             sc-force-rest               tie-over-rests
respell-bars                  sc-move-dynamic             trill
respell-notes                 sc-remove-dynamic           unset-cautionary-accidental
rest-to-note                  sc-remove-dynamics          respell-notes-for-player
rm-marks-from-note            set-cautionary-accidental
-----------------             -------------               -------------

----

### Exercise: POST-GENERATION DATA EDITING

See http://michael-edwards.org/sc/workshop-exercises.lsp

