×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Problem Merging Two Sounds

Problem Merging Two Sounds

Problem Merging Two Sounds

(OP)
Hi, I've created a simple sound copy and paste M-file with GUI that will allow you to select a section of a sound and paste it into a new matrix.

I now want it to allow me to paste another section that will join onto the end of the sound already in the matrix. When I try and do this I get the error:

Warning: Integer operands are required for colon operator when used as index.
> In WaveEditor>sndedit_paste_Callback at 315
  In gui_mainfcn at 75
  In WaveEditor at 44
Warning: Integer operands are required for colon operator when used as index.
> In WaveEditor>sndedit_paste_Callback at 315
  In gui_mainfcn at 75
  In WaveEditor at 44
??? Error using ==> plot
Vectors must be the same lengths.

Code:

function snd_copy_Callback(hObject, eventdata, handles)
snd_section = [handles.snd(handles.snd_startposx:handles.snd_endposx)];
handles.snd_section = snd_section
set(handles.snd_pos, 'String', 'Section Copied');
guidata(hObject, handles);

Copies a section of the sound matrix into a new one. For example, the new matrix will be "snd_section: [1x31457 double]".

function sndedit_paste_Callback(hObject, eventdata, handles)
if (handles.sndedit_toggle == 0)
    sndedit = handles.snd_section;
    axes(handles.sndedit_axes);
    hold on
    pl = plot(sndedit);
    set(pl, 'HitTest', 'off')
    handles.sndedit = sndedit
    handles.sndedit_toggle = 1
else
    sndedit_temp = handles.sndedit;
    handles.sndedit = [sndedit_temp(1:sndedit_temp) ,handles.snd_section(1:handles.snd_section)];
    axes(handles.sndedit_axes);
    CLA
    hold on
    pl = plot(handles.sndedit);
    set(pl, 'HitTest', 'off')
end
guidata(hObject, handles);

Upon first paste, sound is pasted into new matrix and plotted. Upon next paste it will try and join the "snd_section" to the end of "sndedit" and then plot again. The lines where the errors occur are the bold ones.

I've tried this by just creating sound matrixes in the workspace and doing snd3 = [snd1(1:104411) ,snd2(1:264544)]which works but won't when I try and implement it here. I know is somthing to do with the end values but can't see why it won't work.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources