idamnjanovic@1: function SMALL_playAudio(SMALL) ivan@128: %% Plays reconstructed and original signals ivan@128: % Function gets as input SMALL structure and play the original and ivan@128: % the reconstructed signal ivan@128: idamnjanovic@24: % idamnjanovic@24: % Centre for Digital Music, Queen Mary, University of London. idamnjanovic@24: % This file copyright 2009 Ivan Damnjanovic. idamnjanovic@24: % idamnjanovic@24: % This program is free software; you can redistribute it and/or idamnjanovic@24: % modify it under the terms of the GNU General Public License as idamnjanovic@24: % published by the Free Software Foundation; either version 2 of the idamnjanovic@24: % License, or (at your option) any later version. See the file idamnjanovic@24: % COPYING included with this distribution for more information. ivan@128: %% ivan@128: idamnjanovic@1: idamnjanovic@1: idamnjanovic@8: SMALL.solver.reconstructed = SMALL.Problem.reconstruct(SMALL.solver.solution); idamnjanovic@1: ch=''; idamnjanovic@1: while 1 idamnjanovic@1: request = input('\nWhat do you want to hear? \n 1. Original signal \n 2. Mixed \n 3. Reconstructed signal \n 4. Quit player\n','s'); idamnjanovic@1: request = sscanf(request,'%d'); idamnjanovic@1: switch request idamnjanovic@1: case 1 idamnjanovic@1: fprintf('Original signal has %d sources.\n Which one do you want to hear?', size(SMALL.Problem.signal,2)) idamnjanovic@1: fprintf('Enter a number between 1 and %d', size(SMALL.Problem.signal,2)) idamnjanovic@1: ch=input('','s'); idamnjanovic@1: ch=sscanf(ch,'%d'); idamnjanovic@1: if (ch>=1)&&(ch<=size(SMALL.Problem.signal,2)) idamnjanovic@1: soundsc(SMALL.Problem.signal(:,ch),8000); idamnjanovic@1: end idamnjanovic@1: case 2 idamnjanovic@1: fprintf('Number of channels in mixed signal is %d.\n Which one do you want to hear?', size(SMALL.Problem.b,2)) idamnjanovic@1: fprintf('Enter a number between 1 and %d', size(SMALL.Problem.signal,2)) idamnjanovic@1: ch=input('','s'); idamnjanovic@1: ch=sscanf(ch,'%d'); idamnjanovic@1: if (ch>=1)&&(ch<=size(SMALL.Problem.b,2)) idamnjanovic@1: soundsc(SMALL.Problem.b(:,ch),8000); idamnjanovic@1: end idamnjanovic@1: case 3 idamnjanovic@1: fprintf('Reconstructed signal has %d sources.\n Which one do you want to hear?', size(SMALL.solver.reconstructed,2)) idamnjanovic@1: fprintf('Enter a number between 1 and %d', size(SMALL.Problem.signal,2)) idamnjanovic@1: ch=input('','s'); idamnjanovic@1: ch=sscanf(ch,'%d'); idamnjanovic@1: if (ch>=1)&&(ch<=size(SMALL.solver.reconstructed,2)) idamnjanovic@1: soundsc(SMALL.solver.reconstructed(:,ch),8000); idamnjanovic@1: end idamnjanovic@1: case 4 idamnjanovic@1: return; idamnjanovic@1: end idamnjanovic@1: end idamnjanovic@1: end