Please help. I am doing a speech, music, environment classification. I want to convert the code below into a 'switch' equivalent to used for multiple if else if pDSP<pDMU && pDSP<pDEN fprintf('%s ', myFile(j).name) fprintf('- This is SPEECH\n') %label speech else if pDMU<pDEN fprintf('%s ', myFile(j).name) fprintf('- This is MUSIC\n') %label music else fprintf('%s ', myFile(j).name) fprintf('- This is Environment Sound\n') %label environment end end
switch speech, music, environment
Started by ●March 10, 2007
Reply by ●March 11, 20072007-03-11
kingdavid3 wrote:> Please help. I am doing a speech, music, environment classification. I want > to convert the code below into a 'switch' equivalent to used for multiple > if else > if pDSP<pDMU && pDSP<pDEN > fprintf('%s ', myFile(j).name) > fprintf('- This is SPEECH\n') %label speech > else if pDMU<pDEN > fprintf('%s ', myFile(j).name) > fprintf('- This is MUSIC\n') %label music > else > fprintf('%s ', myFile(j).name) > fprintf('- This is Environment Sound\n') %label environment > end > endIf I had to guess, I'd say that you are asking about how to write C. There are better newsgroups for that, but I suggest book or an on-line tutorial. http://www.google.com/search?q=C+tutorial Jerry -- Engineering is the art of making what you want from things you can get. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Reply by ●March 11, 20072007-03-11
On Mar 10, 5:41 pm, "kingdavid3" <aris.da...@gmail.com> wrote:> Please help. I am doing a speech, music, environment classification. I want > to convert the code below into a 'switch' equivalent to used for multiple > if else > if pDSP<pDMU && pDSP<pDEN > fprintf('%s ', myFile(j).name) > fprintf('- This is SPEECH\n') %label speech > else if pDMU<pDEN > fprintf('%s ', myFile(j).name) > fprintf('- This is MUSIC\n') %label music > else > fprintf('%s ', myFile(j).name) > fprintf('- This is Environment Sound\n') %label environment > end > endThe above code doesn't easily map to a switch statement. In C, the case values that you put in a switch statement must be constant values that are comparable (via the == operator) to the argument to the switch. For example: int i; switch(i) { case 0: // do stuff break; case 1: // do stuff break; // ... } Your case doesn't really call for a switch-case structure, if you ask me. If you absolutely wanted to use a switch statement, you could perform the comparisons ahead of time and set a flag indicating the "type" of the audio (speech, music, or environment), then switch on the flag values. Jason