Prev: adding data to uitable
Next: Using slider to updating audio signal being played..real posttia sal22
From: Rick T on 9 Feb 2010 16:47 Sorry if this got posted twice gremlins started playing with my computers. Greetings All I'm trying to use a slider to adjust the frequency of an audio signal that is played out my audio card in "realtime" using matlab. I keep getting an error reference to non-existent field 'freq'. this is the line of code it saying has the error set(handles.freq,'Value',sliderValue); The thing is I created the freq variable right above it. Any suggestions/ should I be doing it this way? example code below: function slider1_Callback(hObject, eventdata, handles) sliderValue = get(handles.slider1,'Value'); %puts the slider value into the edit text component set(handles.sliderValue_editText,'String', num2str(sliderValue)); freq=1; set(handles.freq,'Value',sliderValue); %sets freq when slider changes %-------error it refers too above % Update handles structure guidata(hObject, handles); function sliderValue_editText_Callback(hObject, eventdata, handles) sliderValue = get(handles.sliderValue_editText,'String'); %convert from string to number if possible, otherwise returns empty sliderValue = str2num(sliderValue); %if user inputs something is not a number, or if the input is less than 0 %or greater than 100, then the slider value defaults to 0 if (isempty(sliderValue) || sliderValue < 0 || sliderValue > 300) set(handles.slider1,'Value',0); set(handles.freq,'Value',1); %sets freq when slider changes set(handles.sliderValue_editText,'String','0'); else set(handles.slider1,'Value',sliderValue); set(handles.freq,'Value',sliderValue); %sets freq when slider changes end function freq_Callback(hObject, eventdata, handles) ao=analogoutput('winsound'); ao.samplerate=44100; y = sin(freq*(0:(2*pi/44100):2*pi))'; % creates test signal from freq variable chan=addchannel(ao,1:2); ao.RepeatOutput = 3; % to output 3 times you need to repeat 3 USE RepeatOutput putdata(ao,[y y]) start(ao) % Don't forget to cleanup when done clear ao %delete(ao)
|
Pages: 1 Prev: adding data to uitable Next: Using slider to updating audio signal being played..real posttia sal22 |