From d823a57aec432898701f136da37e7aecabf3ac34 Mon Sep 17 00:00:00 2001 From: Oli Date: Fri, 05 Oct 2007 20:54:08 +0000 Subject: mic recording in SynthLab --- (limited to 'TamTamSynthLab.activity/SynthLab') diff --git a/TamTamSynthLab.activity/SynthLab/SynthLabConstants.py b/TamTamSynthLab.activity/SynthLab/SynthLabConstants.py index 490eccc..77ead26 100755 --- a/TamTamSynthLab.activity/SynthLab/SynthLabConstants.py +++ b/TamTamSynthLab.activity/SynthLab/SynthLabConstants.py @@ -23,7 +23,7 @@ class SynthLabConstants: [ [], [[25,-25,37,-14], [25,-12,37,-1], [25,1,37,12], [25,13,37,25]], [[-8,27,3,40]], [[-8,-40,3,-27]] ], [ [], [], [], [[-4,-40,7,-29]] ] ] # insert wire locations into map - GATE_OFFSET = 15 + GATE_OFFSET = 15 for oT in GATE_MAP: for gT in oT: for m in gT: @@ -32,7 +32,7 @@ class SynthLabConstants: # snap to edges if x < -HALF_SIZE+GATE_OFFSET: x = m[0] elif x > HALF_SIZE-GATE_OFFSET: x = m[2] - if y < -HALF_SIZE+GATE_OFFSET: y = m[1] + if y < -HALF_SIZE+GATE_OFFSET: y = m[1] elif y > HALF_SIZE-GATE_OFFSET: y = m[3] m.append( ( x, y ) ) @@ -62,6 +62,7 @@ class SynthLabConstants: 'voice': [1, 3, 5, 1, 0, 2, 0, 8, 1, 10, 0, 2, FLOAT, INTEGER, FLOAT], 'grain': [1, 4, 1, 1, 0, 2, 0, 99, 0, 1, 0, 2, FLOAT, INTEGER, FLOAT], 'addSynth': [1, .005, 5, 1, 0, 2, 0, 20, 0, 9, 0, 2, FLOAT, FLOAT, INTEGER], + 'mic': [5, 1, 1, 1, 1, 10, 1, 4, 0, 4, 0, 2, FLOAT, INTEGER, FLOAT], 'wguide': [100, 3000, .8, 1, 0, 200, 100, 5000, 0, 1, 0, 2, FLOAT1, INTEGER, FLOAT], 'distort': [800, .7, .7, 1, 0, 1000, 0, 1, 0, 1, 0, 2, INTEGER, FLOAT, FLOAT], 'filter': [1000, .6, 0, 1, 200, 5000, 0, 1, 0, 2, 0, 2, INTEGER, FLOAT, INTEGER], @@ -72,18 +73,18 @@ class SynthLabConstants: 'chorus': [.5, 1., 5., .5, 0, 3, 0, 10, 0, 30, 0, 1, FLOAT, FLOAT, FLOAT]} CONTROL_TYPES = ['lfo', 'rand', 'adsr', 'trackpadX', 'trackpadY'] - CONTROL_TYPES_SEL = [type + 'sel' for type in CONTROL_TYPES] + #CONTROL_TYPES_SEL = [type + 'sel' for type in CONTROL_TYPES] CONTROL_TYPES_PLUS = [type + '+' for type in CONTROL_TYPES] - SOURCE_TYPES = ['fm', 'buzz', 'vco', 'pluck', 'noise', 'sample', 'voice', 'grain', 'addSynth'] - SOURCE_TYPES_SEL = [type + 'sel' for type in SOURCE_TYPES] + SOURCE_TYPES = ['fm', 'buzz', 'vco', 'pluck', 'noise', 'sample', 'voice', 'grain', 'addSynth', 'mic'] + #SOURCE_TYPES_SEL = [type + 'sel' for type in SOURCE_TYPES] SOURCE_TYPES_PLUS = [type + '+' for type in SOURCE_TYPES] FX_TYPES = ['wguide', 'distort','filter', 'ring', 'reverb', 'harmon', 'eq4band', 'chorus'] - FX_TYPES_SEL = [type + 'sel' for type in FX_TYPES] + #FX_TYPES_SEL = [type + 'sel' for type in FX_TYPES] FX_TYPES_PLUS = [type + '+' for type in FX_TYPES] OUTPUT_TYPE = ['adsr'] OUTPUT_TYPE_SEL = ['adsrsel'] CHOOSE_TYPE = [CONTROL_TYPES, SOURCE_TYPES, FX_TYPES, OUTPUT_TYPE] - CHOOSE_TYPE2 = [CONTROL_TYPES_SEL, SOURCE_TYPES_SEL, FX_TYPES_SEL, OUTPUT_TYPE_SEL] + #CHOOSE_TYPE2 = [CONTROL_TYPES_SEL, SOURCE_TYPES_SEL, FX_TYPES_SEL, OUTPUT_TYPE_SEL] CHOOSE_TYPE_PLUS = [CONTROL_TYPES_PLUS, SOURCE_TYPES_PLUS, FX_TYPES_PLUS] # SynthLab Tooltips @@ -101,10 +102,10 @@ class SynthLabConstants: OFFSET = _('Offset') LFO_INFO = _('A low frequency oscillation (LFO) is an inaudible, pulsing wave used to change another sound.') LFO_PARA1 = _('The volume of the LFO wave. More volume means more effect.') - LFO_PARA2 = _('The speed of the wave.') + LFO_PARA2 = _('The speed of the wave.') LFO_PARA3 = _('The type of wave that will be used for the LFO.') LFO_PARA4 = _('The time by which the LFO is delayed.') - + RANDOM = _('Random') MIN = _('Minimum') MAX = _('Maximum') @@ -115,7 +116,7 @@ class SynthLabConstants: RANDOM_PARA2 = _('The biggest number allowed.') RANDOM_PARA3 = _('The speed of the sequence.') RANDOM_PARA4 = _('The number to initialize the number generator') - + ADSR = _('Envelope') ATTACK = _('Attack') DECAY = _('Decay') @@ -229,7 +230,7 @@ class SynthLabConstants: GAIN = GAIN VOICE_INFO = _('An electronic voice.') VOICE_PARA1 = _('The pitch of the sound.') - VOICE_PARA2 = _('The shape of the sound based on vowells.') + VOICE_PARA2 = _('The shape of the sound based on vowels.') VOICE_PARA3 = _('The speed of the wave.') VOICE_PARA4 = _('The volume of the sound.') @@ -255,6 +256,17 @@ class SynthLabConstants: ADDSYNTH_PARA3 = _('The shape of the wave.') ADDSYNTH_PARA4 = _('The volume of the sound.') + MIC = _('Microphone input') + DURATION = _('Length of the memory') + BIN = _('memory number') + SPEED = _('Playback speed') + GAIN = GAIN + MIC_INFO = _('Microphone input is record into a buffer for playback (right-clic on the objet to record sound)') + MIC_PARA1 = _('Length of the memory') + MIC_PARA2 = _('This parameter can not be modified') + MIC_PARA3 = _('Speed playback changes duration and pitch of the sound') + MIC_PARA4 = _('The volume of the sound') + #Effects DELAY = _('Delay') FREQ = FREQ @@ -345,9 +357,9 @@ class SynthLabConstants: CHORUS_PARA2 = _('The pitch of the LFO signal.') CHORUS_PARA3 = _('The amount of delay between the two signals.') CHORUS_PARA4 = _('The volume of the sound.') - + SYNTHTYPES = [[LFO, RANDOM, ADSR, TRACKPADX, TRACKPADY], - [FM, BUZZ, VCO, PLUCK, NOISE, SAMPLE, VOICE, GRAIN, ADDSYNTH], + [FM, BUZZ, VCO, PLUCK, NOISE, SAMPLE, VOICE, GRAIN, ADDSYNTH, MIC], [DELAY, DIST, FILTER, RINGMOD, REVERB, HARMON, EQ4BAND, CHORUS], [ADSR]] SYNTHPARA = { _('lfo'): [AMP, FREQ, WAVEFORM, OFFSET, LFO_INFO, LFO_PARA1, LFO_PARA2, LFO_PARA3, LFO_PARA4], @@ -364,6 +376,7 @@ class SynthLabConstants: _('voice'): [FREQ, VOWEL, VIBRATO, GAIN, VOICE_INFO, VOICE_PARA1, VOICE_PARA2, VOICE_PARA3, VOICE_PARA4], _('grain'): [FREQ, SAMPLEN, INDEX, GAIN, GRAIN_INFO, GRAIN_PARA1, GRAIN_PARA2, GRAIN_PARA3, GRAIN_PARA4], _('addSynth'): [FREQ, SPREAD, WAVE, GAIN, ADDSYNTH_INFO, ADDSYNTH_PARA1, ADDSYNTH_PARA2, ADDSYNTH_PARA3, ADDSYNTH_PARA4], + _('mic'): [DURATION, BIN, SPEED, GAIN, MIC_INFO, MIC_PARA1, MIC_PARA2, MIC_PARA3, MIC_PARA4], _('wguide'): [FREQ, LFILTER, FEEDBACK, GAIN, DELAY_INFO, DELAY_PARA1, DELAY_PARA2, DELAY_PARA3, DELAY_PARA4], _('distort'): [FREQ, RESON, DISTL, GAIN, DIST_INFO, DIST_PARA1, DIST_PARA2, DIST_PARA3, DIST_PARA4], _('filter'): [FREQ, FSLOPE, FTYPE, GAIN, FILTER_INFO, FILTER_PARA1, FILTER_PARA2, FILTER_PARA3, FILTER_PARA4], diff --git a/TamTamSynthLab.activity/SynthLab/SynthLabMain.py b/TamTamSynthLab.activity/SynthLab/SynthLabMain.py index 662aa78..6622076 100644 --- a/TamTamSynthLab.activity/SynthLab/SynthLabMain.py +++ b/TamTamSynthLab.activity/SynthLab/SynthLabMain.py @@ -9,6 +9,7 @@ import time import shelve from gettext import gettext as _ import os +import commands from sugar.graphics.toolcombobox import ToolComboBox from common.Util.ThemeWidgets import BigComboBox @@ -50,6 +51,7 @@ class SynthLabMain(gtk.EventBox): self.recordWait = 0 self.recCount = 0 self.new = True + self.selectGate = False self.sliderGate = True self.duration = 2 self.viewType = '' @@ -322,7 +324,7 @@ class SynthLabMain(gtk.EventBox): self.choosenType = self.synthObjectsParameters.types[self.instanceID] else: self.choosenType = 0 - + self.objComboBox.set_active(self.choosenType) #Not sure about this self.slider1.grab_focus() @@ -332,6 +334,7 @@ class SynthLabMain(gtk.EventBox): def changeObject(self, widget): self.choosenType = widget.props.value + if self.sliderGate: self.new = True self.resize() if self.instanceID != 12: self.synthObjectsParameters.setType(self.instanceID, self.choosenType) @@ -411,7 +414,12 @@ class SynthLabMain(gtk.EventBox): slider3Snap = SynthLabConstants.TYPES[selectedType][14][1] self.p1Adjust.set_all(slider1Init, slider1Min, slider1Max, slider1Step, slider1Step, 0) - self.p2Adjust.set_all(slider2Init, slider2Min, slider2Max, slider2Step, slider2Step, 0) + if selectedType == 'mic': + self.p2Adjust.set_all(self.instanceID-3, slider2Min, slider2Max, slider2Step, slider2Step, 0) + self.slider2.set_sensitive(False) + else: + self.p2Adjust.set_all(slider2Init, slider2Min, slider2Max, slider2Step, slider2Step, 0) + self.slider2.set_sensitive(True) self.p3Adjust.set_all(slider3Init, slider3Min, slider3Max, slider3Step, slider3Step, 0) self.p4Adjust.set_all(slider4Init, slider4Min, slider4Max, 0.01, 0.01, 0) @@ -419,7 +427,7 @@ class SynthLabMain(gtk.EventBox): self.slider2.set_digits(slider2Snap) self.slider3.set_digits(slider3Snap) - self.new = True + #self.new = True def sendTables( self, widget, data ): if self.sliderGate: @@ -594,6 +602,7 @@ class SynthLabMain(gtk.EventBox): else: self.select( i ) return + if self.action == "draw-wire": # didn't hit anything self.doneWire() else: @@ -601,6 +610,19 @@ class SynthLabMain(gtk.EventBox): i = self.wireUnderLoc( event.x, event.y ) if i >= 0: self.deleteWire( i ) + elif event.button == 3: + for i in range(self.objectCount-1,-1,-1): + if self.bounds[i][0] < event.x < self.bounds[i][2] and self.bounds[i][1] < event.y < self.bounds[i][3]: + if i in [4,5,6,7]: + if self.synthObjectsParameters.types[i] == 9: + snd = i - 3 + dur = self.synthObjectsParameters.sourcesParameters[(i % 4) * 4] + os.system('rm ' + Config.SNDS_DIR + '/labmic' + str(snd)) + (s1,o1) = commands.getstatusoutput("arecord -f S16_LE -t wav -r 16000 -d " + str(dur) + " " + Config.SNDS_DIR + '/tempMic.wav') + (s2, o2) = commands.getstatusoutput("csound " + Config.FILES_DIR + "/cropSynthLab.csd") + (s3, o3) = commands.getstatusoutput("mv " + Config.SNDS_DIR + "/micTemp " + Config.SNDS_DIR + "/" + 'labmic' + str(snd)) + (s4, o4) = commands.getstatusoutput("rm " + Config.SNDS_DIR + "/tempMic.wav") + return def handleMotion( self, widget, event ): -- cgit v0.9.1