<s> class Segment ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , track , comp_location , start , duration , effects = None ) : <EOL> """<STR_LIT>""" <EOL> self . samplerate = track . samplerate <EOL> self . track = track <EOL> self . comp_location_in_seconds = comp_location <EOL> self . start_in_seconds = start <EOL> self . duration_in_seconds = duration <EOL> if effects is None : <EOL> self . effects = [ ] <EOL> else : <EOL> self . effects = effects <EOL> @ property <EOL> def duration_in_seconds ( self ) : <EOL> return self . duration / float ( self . samplerate ) <EOL> @ duration_in_seconds . setter <EOL> def duration_in_seconds ( self , duration_in_seconds ) : <EOL> self . duration = int ( duration_in_seconds * self . samplerate ) <EOL> @ property <EOL> def start_in_seconds ( self ) : <EOL> return self . start / float ( self . samplerate ) <EOL> @ start_in_seconds . setter <EOL> def start_in_seconds ( self , start_in_seconds ) : <EOL> self . start = int ( start_in_seconds * self . samplerate ) <EOL> @ property <EOL> def comp_location_in_seconds ( self ) : <EOL> return self . comp_location / float ( self . samplerate ) <EOL> @ comp_location_in_seconds . setter <EOL> def comp_location_in_seconds ( self , comp_location_in_seconds ) : <EOL> self . comp_location = int ( comp_location_in_seconds * self . samplerate ) <EOL> def add_effect ( self , effect ) : <EOL> self . effects . append ( effect ) <EOL> def add_effects ( self , effects ) : <EOL> self . effects . extend ( effects ) <EOL> def get_frames ( self , channels = <NUM_LIT:2> ) : <EOL> """<STR_LIT>""" <EOL> tmp_frame = self . track . current_frame <EOL> self . track . current_frame = self . start <EOL> frames = self . track . read_frames ( self . duration , channels = channels ) <EOL> self . track . current_frame = tmp_frame <EOL> for effect in self . effects : <EOL> frames = effect . apply_to ( frames , self . samplerate ) <EOL> return frames . copy ( ) </s>
