Thread Subject: Using slider to updating audio signal being played tia sal22

Subject: Using slider to updating audio signal being played tia sal22

From: Rick T

Date: 9 Feb, 2010 21:40:19

Message: 1 of 1

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

% 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

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com