diff options
author | Nat <natcl@hotmail.com> | 2007-08-09 06:12:06 (GMT) |
---|---|---|
committer | Nat <natcl@hotmail.com> | 2007-08-09 06:12:06 (GMT) |
commit | 92dd1bba2244c5bf23b519c5801d22bf39c9bebc (patch) | |
tree | c064b29351bd4ee0ad85997834bd1b6f738a9fa9 | |
parent | 1837544663ab6d6b82ae0607b0a1ed503f2fee95 (diff) |
Working Generation Toolbar
-rw-r--r-- | Edit/EditToolbars.py | 101 | ||||
-rwxr-xr-x | SynthLab/SynthLabConstants.py | 108 |
2 files changed, 182 insertions, 27 deletions
diff --git a/Edit/EditToolbars.py b/Edit/EditToolbars.py index b99a387..14f10de 100644 --- a/Edit/EditToolbars.py +++ b/Edit/EditToolbars.py @@ -8,6 +8,8 @@ from sugar.graphics.toggletoolbutton import ToggleToolButton from sugar.graphics.palette import Palette from sugar.graphics.icon import Icon from Util.ThemeWidgets import * +from Generation.Generator import GenerationParameters +from Generation.GenerationConstants import GenerationConstants from gettext import gettext as _ class mainToolbar(gtk.Toolbar): @@ -134,7 +136,7 @@ class volumeTempoPalette(Palette): self.volumeSliderBox = gtk.HBox() self.volumeSliderLabel = gtk.Label(_('Volume')) - self.volumeSliderAdj = gtk .Adjustment(value=0, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0) + self.volumeSliderAdj = gtk.Adjustment(value=0, lower=0, upper=1, step_incr=0.1, page_incr=0, page_size=0) self.volumeSlider = gtk.HScale(adjustment = self.volumeSliderAdj) self.volumeSlider.set_size_request(250,-1) self.volumeSlider.set_inverted(False) @@ -327,14 +329,23 @@ class propsPalette(Palette): self.set_content(self.mainBox) - - class generationPalette(Palette): def __init__(self, label, edit): Palette.__init__(self, label) self.edit = edit + self.rythmDensity = GenerationConstants.DEFAULT_DENSITY + self.rythmRegularity = GenerationConstants.DEFAULT_RYTHM_REGULARITY + self.pitchRegularity = GenerationConstants.DEFAULT_PITCH_REGULARITY + self.pitchStep = GenerationConstants.DEFAULT_STEP + self.duration = GenerationConstants.DEFAULT_DURATION + self.silence = GenerationConstants.DEFAULT_SILENCE + self.rythmMethod = GenerationConstants.DEFAULT_RYTHM_METHOD + self.pitchMethod = GenerationConstants.DEFAULT_PITCH_METHOD + self.pattern = GenerationConstants.DEFAULT_PATTERN + self.scale = GenerationConstants.DEFAULT_SCALE + self.mainBox = gtk.VBox() self.slidersBox = gtk.HBox() self.scaleModeBox = gtk.HBox() @@ -343,22 +354,28 @@ class generationPalette(Palette): self.XYSliderBox1 = RoundFixed(fillcolor = '#CCCCCC', bordercolor = '#000000') self.XYSliderBox1.set_size_request(200,200) self.XYButton1 = ImageToggleButton( Config.TAM_TAM_ROOT + '/icons/XYBut.svg', Config.TAM_TAM_ROOT + '/icons/XYButDown.svg') - self.XAdjustment1 = gtk.Adjustment( 1, 0, 100, 1, 1, 1 ) - self.YAdjustment1 = gtk.Adjustment( 1, 0, 100, 1, 1, 1 ) + self.XAdjustment1 = gtk.Adjustment(self.rythmDensity * 100, 0, 100, 1, 1, 1) + self.XAdjustment1.connect("value-changed", self.handleXAdjustment1) + self.YAdjustment1 = gtk.Adjustment(self.rythmRegularity * 100, 0, 100, 1, 1, 1) + self.YAdjustment1.connect("value-changed", self.handleYAdjustment1) self.XYSlider1 = XYSlider( self.XYSliderBox1, self.XYButton1, self.XAdjustment1, self.YAdjustment1, False, True ) self.XYSliderBox2 = RoundFixed(fillcolor = '#CCCCCC', bordercolor = '#000000') self.XYSliderBox2.set_size_request(200,200) self.XYButton2 = ImageToggleButton( Config.TAM_TAM_ROOT + '/icons/XYBut.svg', Config.TAM_TAM_ROOT + '/icons/XYButDown.svg') - self.XAdjustment2 = gtk.Adjustment( 1, 0, 100, 1, 1, 1 ) - self.YAdjustment2 = gtk.Adjustment( 1, 0, 100, 1, 1, 1 ) + self.XAdjustment2 = gtk.Adjustment(self.pitchRegularity * 100, 0, 100, 1, 1, 1) + self.XAdjustment2.connect("value-changed", self.handleXAdjustment2) + self.YAdjustment2 = gtk.Adjustment(self.pitchStep * 100, 0, 100, 1, 1, 1) + self.YAdjustment2.connect("value-changed", self.handleYAdjustment2) self.XYSlider2 = XYSlider( self.XYSliderBox2, self.XYButton2, self.XAdjustment2, self.YAdjustment2, False, True ) self.XYSliderBox3 = RoundFixed(fillcolor = '#CCCCCC', bordercolor = '#000000') self.XYSliderBox3.set_size_request(200,200) self.XYButton3 = ImageToggleButton( Config.TAM_TAM_ROOT + '/icons/XYBut.svg', Config.TAM_TAM_ROOT + '/icons/XYButDown.svg') - self.XAdjustment3 = gtk.Adjustment( 1, 0, 100, 1, 1, 1 ) - self.YAdjustment3 = gtk.Adjustment( 1, 0, 100, 1, 1, 1 ) + self.XAdjustment3 = gtk.Adjustment(self.duration * 100, 0, 100, 1, 1, 1) + self.XAdjustment3.connect("value-changed", self.handleXAdjustment3) + self.YAdjustment3 = gtk.Adjustment(self.silence * 100, 0, 100, 1, 1, 1) + self.YAdjustment3.connect("value-changed", self.handleYAdjustment3) self.XYSlider3 = XYSlider( self.XYSliderBox3, self.XYButton3, self.XAdjustment3, self.YAdjustment3, False, True ) self.slidersBox.pack_start(self.XYSlider1, False, False, padding = 5) @@ -366,15 +383,19 @@ class generationPalette(Palette): self.slidersBox.pack_start(self.XYSlider3, False, False, padding = 5) self.scaleBoxLabel = gtk.Label(_('Scale: ')) - self.scaleBox = gtk.combo_box_new_text() - for scale in [_('Major scale'), _('Harmonic minor scale'), _('Natural minor scale'), _('Phrygian scale'), _('Dorian scale'), _('Lydian scale'), _('Myxolidian scale')]: - self.scaleBox.append_text(scale) + self.scaleBox = BigComboBox() + scales = [_('Major scale'), _('Harmonic minor scale'), _('Natural minor scale'), _('Phrygian scale'), _('Dorian scale'), _('Lydian scale'), _('Myxolidian scale')] + for scale in scales: + self.scaleBox.append_item(scales.index(scale), scale) + self.scaleBox.connect('changed', self.handleScale) self.scaleBox.set_active(0) self.modeBoxLabel = gtk.Label(_('Mode: ')) - self.modeBox = gtk.combo_box_new_text() - for mode in [_('Drunk'), _('Drone and Jump'), _('Repeater'), _('Loop segments')]: - self.modeBox.append_text(mode) + self.modeBox = BigComboBox() + modes = [_('Drunk'), _('Drone and Jump'), _('Repeater'), _('Loop segments')] + for mode in modes: + self.modeBox.append_item(modes.index(mode), mode) + self.modeBox.connect('changed', self.handleMode) self.modeBox.set_active(0) self.scaleModeBox.pack_start(self.scaleBoxLabel, False, False, padding = 10) @@ -382,8 +403,12 @@ class generationPalette(Palette): self.scaleModeBox.pack_start(self.modeBoxLabel, False, False, padding = 10) self.scaleModeBox.pack_start(self.modeBox, False, False, padding = 10) - self.acceptButton = Icon('stock-accept') - self.cancelButton = Icon('activity-stop') + self.acceptButton = gtk.Button(label = _('Accept')) +# self.acceptButton = IconButton('stock-accept') + self.acceptButton.connect('clicked',self.generate) + self.cancelButton = gtk.Button(label = _('Cancel')) + self.cancelButton.connect('clicked',self.cancel) +# self.cancelButton = IconButton('activity-stop') self.decisionBox.pack_start(self.cancelButton, False, False, padding = 5) self.decisionBox.pack_start(self.acceptButton, False, False, padding = 5) @@ -394,5 +419,47 @@ class generationPalette(Palette): self.set_content(self.mainBox) + + def handleXAdjustment1( self, data ): + self.rythmDensity = self.XAdjustment1.value * .01 + + def handleYAdjustment1( self, data ): + self.rythmRegularity = self.YAdjustment1.value * .01 + def handleXAdjustment2( self, data ): + self.pitchRegularity = self.XAdjustment2.value * .01 + + def handleYAdjustment2( self, data ): + self.pitchStep = self.YAdjustment2.value * .01 + + def handleXAdjustment3( self, data ): + self.duration = self.XAdjustment3.value * .01 + + def handleYAdjustment3( self, data ): + self.silence = self.YAdjustment3.value * .01 + + def getGenerationParameters( self ): + return GenerationParameters( self.rythmDensity, + self.rythmRegularity, + self.pitchStep, + self.pitchRegularity, + self.duration, + self.silence, + self.rythmMethod, + self.pitchMethod, + self.pattern, + self.scale ) + + def handleScale(self, widget, data = None): + self.scale = widget.props.value + + def handleMode( self, widget, data = None ): + self.pattern = widget.props.value + + def cancel(self, widget, data = None): + self.popdown(True) + + def generate(self, widget, data=None): + self.edit.generate(self.getGenerationParameters()) + self.popdown(True) diff --git a/SynthLab/SynthLabConstants.py b/SynthLab/SynthLabConstants.py index 5598ffc..9bf7294 100755 --- a/SynthLab/SynthLabConstants.py +++ b/SynthLab/SynthLabConstants.py @@ -99,21 +99,33 @@ class SynthLabConstants: WAVEFORM = _('Waveform') LFO_WAVEFORMS = [_('Sine'), _('Triangle'), _('Bi-Square'), _('Uni-Square'), _('Sawtooth'), _('Sawtooth-down')] OFFSET = _('Offset') - LFO_INFO = _('A low frequency oscillation (LFO) is a signal usually below 20 Hz which creates a pulsating rythm rather than a audible tone.') - + LFO_INFO = _('A low frequency oscillation (LFO) is a signal usually below 20 Hz which creates a pulsating rythm rather than a audible tone. This signal is commonly used to control sound parameters.') + LFO_PARA1 = _('The amplitude (volume) of the LFO signal. More amplitude means the effect will be more noticeable.') + LFO_PARA2 = _('The speed of the signal beteen 0 Hz and 20 hz.') + LFO_PARA3 = _('The type of waveform that will be used for the LFO.') + LFO_PARA4 = _('Offset: ') + RANDOM = _('Random') MIN = _('Minimum') MAX = _('Maximum') FREQ = FREQ SEED = _('Seed') RANDOM_INFO = _('A random number generator is a computational device designed to generate a sequence of numbers that lack any pattern.') - + RANDOM_PARA1 = _('') + RANDOM_PARA2 = _('The minimum value that can be generated.') + RANDOM_PARA3 = _('The maximum value that can be generated.') + RANDOM_PARA4 = _('') + ADSR = _('Envelope') ATTACK = _('Attack') DECAY = _('Decay') SUSTAIN = _('Sustain') RELEASE = _('Release') - ADSR_INFO = _('') + ADSR_INFO = _("An ADSR envelope is a component of many sythesizers, samplers, and other electronic musical instruments. Its function is to modulate some aspect of the instrument's sound - often its volume - over time.") + ADSR_PARA1 = _('How quickly the sound reaches full volume after the sound is activated.') + ADSR_PARA2 = _('How quickly the sound drops to the sustain level after the initial peak.') + ADSR_PARA3= _('The "constant" volume that the sound takes after decay until the note is released.') + ADSR_PARA4 = _('How quickly the sound fades when a note ends.') TRACKPADX = _('Trackpad X') MIN = MIN @@ -121,7 +133,11 @@ class SynthLabConstants: SCALING = _('Scaling') SCALING_TYPES = [_('Lin'), _('Log')] POLL = _('Poll time') - TRACKPADX_INFO = _('') + TRACKPADX_INFO = _('The XO trackpad can be used to control sound parameters. This is the x axis, from left to right.') + TRACKPADX_PARA1 = _('The minimum value the trackpad will send.') + TRACKPADX_PARA2 = _('The maximum value de trackpad will send.') + TRACKPADX_PARA3 = _('The type of scaling, logarithmic or linear.') + TRACKPADX_PARA4= _('The time interval between each event coming from the trackpad.') TRACKPADY = _('Trackpad Y') MIN = MIN @@ -129,7 +145,11 @@ class SynthLabConstants: SCALING = SCALING SCALING_TYPES = SCALING_TYPES POLL = POLL - TRACKPADY_INFO = _('') + TRACKPADY_INFO = _('The XO trackpad can be used to control sound parameters. This is the y axis, from top to bottom.') + TRACKPADY_PARA1 = _('The minimum value the trackpad will send.') + TRACKPADY_PARA2 = _('The maximum value de trackpad will send.') + TRACKPADY_PARA3 = _('The type of scaling, logarithmic or linear.') + TRACKPADY_PARA4 = _('The time interval between each event coming from the trackpad.') #Source FM = _('FM') @@ -137,7 +157,11 @@ class SynthLabConstants: MOD = _('Modulator Frequency') INDEX = _('Index') GAIN = _('Gain') - FM_INFO = _('') + FM_INFO = _('Frequency modulation synthesis is a form of audio synthesis where the timbre of a simple waveform is changed by frequency modulating it with a modulating frequency that is also in the audio range, resulting in a more complex waveform and a different-sounding tone.') + FM_PARA1 = _('The main waveform frequency.') + FM_PARA2 = _('The frequency of the waveform that will modulate the Carrier waveform.') + FM_PARA3 = _('The variation in frequency of the Carrier waveform.') + FM_PARA4 = _('The overall gain (volume) of the sound source.') BUZZ = _('Buzz') FREQ = FREQ @@ -145,6 +169,10 @@ class SynthLabConstants: FSLOPE = _('Filter Slope') GAIN = GAIN BUZZ_INFO = _('') + BUZZ_PARA1 = _('') + BUZZ_PARA2 = _('') + BUZZ_PARA3 = _('') + BUZZ_PARA4 = _('The overall gain (volume) of the sound source.') VCO = _('VCO') FREQ = FREQ @@ -153,6 +181,10 @@ class SynthLabConstants: FSLOPE = FSLOPE GAIN = GAIN VCO_INFO = _('') + VCO_PARA1 = _('') + VCO_PARA2 = _('') + VCO_PARA3 = _('') + VCO_PARA4 = _('The overall gain (volume) of the sound source.') PLUCK = _('Pluck') FREQ = FREQ @@ -160,6 +192,10 @@ class SynthLabConstants: VIBRATO = _('Vibrato') GAIN = GAIN PLUCK_INFO = _('') + PLUCK_PARA1 = _('') + PLUCK_PARA2 = _('') + PLUCK_PARA3 = _('') + PLUCK_PARA4 = _('The overall gain (volume) of the sound source.') NOISE = _('Noise') NOISETYPE = _('Type') @@ -168,6 +204,10 @@ class SynthLabConstants: BANDWITH = _('Bandwith') GAIN = GAIN NOISE_INFO = _('') + NOISE_PARA1 = _('') + NOISE_PARA2 = _('') + NOISE_PARA3 = _('') + NOISE_PARA4 = _('The overall gain (volume) of the sound source.') SAMPLE = _('Sound Sample') FREQ = FREQ @@ -176,6 +216,10 @@ class SynthLabConstants: LFILTER = LFILTER GAIN = GAIN SAMPLE_INFO = _('') + SAMPLE_PARA1 = _('') + SAMPLE_PARA2 = _('') + SAMPLE_PARA3 = _('') + SAMPLE_PARA4 = _('The overall gain (volume) of the sound source.') VOICE = _('Voice') FREQ = FREQ @@ -184,6 +228,10 @@ class SynthLabConstants: VIBRATO = VIBRATO GAIN = GAIN VOICE_INFO = _('') + VOICE_PARA1 = _('') + VOICE_PARA2 = _('') + VOICE_PARA3 = _('') + VOICE_PARA4 = _('The overall gain (volume) of the sound source.') GRAIN = _('Grain') FREQ = FREQ @@ -191,6 +239,10 @@ class SynthLabConstants: INDEX = _('Index') GAIN = GAIN GRAIN_INFO = _('') + GRAIN_PARA1 = _('') + GRAIN_PARA2 = _('') + GRAIN_PARA3 = _('') + GRAIN_PARA4 = _('The overall gain (volume) of the sound source.') ADDSYNTH = _('Additive Synthesis') FREQ = FREQ @@ -198,6 +250,10 @@ class SynthLabConstants: WAVE = _('Waveform') GAIN = GAIN ADDSYNTH_INFO = _('') + ADDSYNTH_PARA1 = _('') + ADDSYNTH_PARA2 = _('') + ADDSYNTH_PARA3 = _('') + ADDSYNTH_PARA4 = _('The overall gain (volume) of the sound source.') #Effects DELAY = _('Delay') @@ -206,6 +262,10 @@ class SynthLabConstants: FEEDBACK = _('Feedback') GAIN = GAIN DELAY_INFO = _('') + DELAY_PARA1 = _('') + DELAY_PARA2 = _('') + DELAY_PARA3 = _('') + DELAY_PARA4 = _('The overall gain (volume) of the sound source.') DIST = _('Distortion') FREQ = FREQ @@ -213,6 +273,10 @@ class SynthLabConstants: DISTL = _('Distotion Level') GAIN = GAIN DIST_INFO = _('') + DIST_PARA1 = _('') + DIST_PARA2 = _('') + DIST_PARA3 = _('') + DIST_PARA4 = _('The overall gain (volume) of the sound source.') FILTER = _('Filter') FREQ = FREQ @@ -221,6 +285,10 @@ class SynthLabConstants: FILTER_TYPES = [_('Lowpass'), _('Highpass'), _('Bandpass')] GAIN = GAIN FILTER_INFO = _('') + FILTER_PARA1 = _('') + FILTER_PARA2 = _('') + FILTER_PARA3 = _('') + FILTER_PARA4 = _('The overall gain (volume) of the sound source.') RINGMOD = _('Ring Modulator') FREQ = FREQ @@ -229,13 +297,21 @@ class SynthLabConstants: LFO_WAVEFORMS = LFO_WAVEFORMS GAIN = GAIN RINGMOD_INFO = _('') + RINGMOD_PARA1 = _('') + RINGMOD_PARA2 = _('') + RINGMOD_PARA3 = _('') + RINGMOD_PARA4 = _('The overall gain (volume) of the sound source.') REVERB = _('Reverb') REVERBD = _('Length') REVERBF = _('Lowpass Filter') REVERBL = _('Reverb Level') GAIN = GAIN - REVERB_INFO = _('') + REVERB_INFO = _('Reverberation is the persistence od sound in a particular space after the original sound is removed.') + REVERB_PARA1 = _('') + REVERB_PARA2 = _('') + REVERB_PARA3 = _('') + REVERB_PARA4 = _('The overall gain (volume) of the sound source.') HARMON = _('Harmonizer') FREQ = FREQ @@ -243,13 +319,21 @@ class SynthLabConstants: MIX = MIX GAIN = GAIN HARMON_INFO = _('') + HARMON_PARA1 = _('') + HARMON_PARA2 = _('') + HARMON_PARA3 = _('') + HARMON_PARA4 = _('The overall gain (volume) of the sound source.') EQ4BAND = _('Equalizer 4 bands') FREQ1 = _('Band one gain') FREQ2 = _('Band two gain') FREQ3 = _('Band three gain') FREQ4 = _('Band four gain') - EQ4BAND_INFO = _('') + EQ4BAND_INFO = _('A 4 band equalizer is an effect that splits the spectrum into 4 bands and allows the bands to be set at different levels.') + EQ4BAND_PARA1 = _('The gain (volume) of band 1.') + EQ4BAND_PARA2 = _('The gain (volume) of band 2.') + EQ4BAND_PARA3 = _('The gain (volume) of band 3.') + EQ4BAND_PARA4 = _('The gain (volume) of band 4.') CHORUS = _('Chorus') LFODEPTH = _('LFO Depth') @@ -257,7 +341,11 @@ class SynthLabConstants: DELAY = _('Delay') FEEDBACK = FEEDBACK CHORUS_INFO = _('A chorus effect is a condition in the way people perceive similar sounds coming from multiple sources.') - + CHORUS_PARA1 = _('LFO Depth: The amplitude of the LFO signal.') + CHORUS_PARA2 = _('LFO Frequency: the frequency of the LFO signal.') + CHORUS_PARA3 = _('Delay: The amount of delay between the two signals.') + CHORUS_PARA4 = _('The overall gain (volume) of the sound source.') + SYNTHTYPES = [[LFO, RANDOM, ADSR, TRACKPADX, TRACKPADY], [FM, BUZZ, VCO, PLUCK, NOISE, SAMPLE, VOICE, GRAIN, ADDSYNTH], [DELAY, DIST, FILTER, RINGMOD, REVERB, HARMON, EQ4BAND, CHORUS], [ADSR]] |