Hi Nigel,
First I have to tell you that you are stepping in dangerous territories here, but you are probably aware of that.
Hacking this part of OM code (the very core of score objects) might get you into complicate issues. But let’s try it 
So, I think your problem comes from the fact that the chord-seq object has a specific way of saving/reloading itself, using the regular “slots” values for storage (lmidics, lvels, …) and building the chords inside at initialization (then resetting to NIL). Additional slots (like your “Ltypes”) are saved and restored as well, but after the chord-seq has already been loaded: therefore, they are not (yet) here to be considered at initializing the instance.
You are redefiniting the initialize-instance
method of your object, copying the one of chord-seq
including call-next-method
and do-initialize
, and adding stuff. This is not very good because now, do-initialize
gets called twice (and LTypes is always NIL anyway).
=> I first suggest you remove this redefinition of initialize-instance
. The slot value will be set anyway (later).
What might be interesting is to redefine the Ltype accessors (reader/setter) on the model of the other chord-seq slots, so that the setter calls do-initialize
with the Ltype list:
(defmethod (setf ltypes) ((ltypes list) (self chord-seq))
(do-initialize self
:LPort (LPort self)
:LMidic (LMidic self)
:LVel (LVel self)
:LOnset (LOnset self)
:LOffset (LOffset self)
:LDur (LDur self)
:LChan (LChan self)
:Legato (legato self)
:Ltypes ltypes))
The reader accessor would simply be:
(defmethod Ltypes ((self system-seq))
(loop for chord in (inside self)
collect (type-of chord)))
do-initialized will now be called at setting the type List. You can rework how you deal with the Ltypes list in there:
[...]
(setf (inside self)
(loop while (or midics vels durs offsets ports)
for midic = (or (pop midics) midic)
;;; for i in Types
FOR I = (OR (POP TYPES) TYPES 'CHORD)
for vel = (or (pop vels) vel)
for dur = (or (pop durs) dur)
for offset = (or (pop offsets) offset)
for chan = (or (pop chans) chan)
for port = (or (pop ports) port) ; (list 0))
;; do (print i)
collect (let ((chord (mki I ;;; (type-of i)
:Lmidic (list! midic)
:Lvel (list! vel)
:Ldur (list! dur )
:Loffset (list! offset)
:LChan (list! chan)
)))
(setf (LPort chord) port)
chord) ))
[...]
Note that in the previous code I consider types being chord types (symbols) not chord instances.
Using instances and type-of
to determine the type seems not necessary.
You should change as well the default value for ltypes in the system-seq definition accordingly.
Hope this help (and is is more or less clear…)
Jean