Dec-02-2019, 06:55 AM
Hi!
I have a small problem:
I defined a class Tone which inherits from the class Recorder. (i.e. a recorder is an instrument which has many notes). Each Tone has certain attributes like frequency, fingering, etc. Currently, I am doing the following:
This however doesn't satisfy me as I would like to be able to easily create a list of all frequencies from an instance of Recorder. Something along these lines
I have a small problem:
I defined a class Tone which inherits from the class Recorder. (i.e. a recorder is an instrument which has many notes). Each Tone has certain attributes like frequency, fingering, etc. Currently, I am doing the following:
class Recorder(object): def __init__(self): self.alltones=[Tone(ii) for ii in range(10)] class Tone(Recorder): def __init__(self,ii): self.frequency=2**(ii/12)
This however doesn't satisfy me as I would like to be able to easily create a list of all frequencies from an instance of Recorder. Something along these lines
a=Recorder() a.alltones.frequencyIn particular, I am looking for a clean way of creating lists of the following type
[Tone(ii).attribute for ii in range(10)]Thank you in advance for your help :)