Advertisement
makispaiktis

Electracoustics - 8D Audio

Oct 23rd, 2021 (edited)
1,273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 2.17 KB | None | 0 0
  1. clc
  2. clear all
  3.  
  4. [d, Fs] = audioread('message.mp3');
  5. BOOST = 5;
  6.  
  7. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. display('1. Original Audio: ');
  9. display(' ');
  10. sound(d, Fs);
  11. delay(12);
  12. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13.  
  14. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. display('2. Left boosted Audio: ');
  16. display(' ');
  17. left = d;
  18. left(:, 1) = left(:, 1) * BOOST;
  19. sound(left, Fs);
  20. delay(12);
  21. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  22.  
  23. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. display('3. Right boosted Audio: ');
  25. display(' ');
  26. right = d;
  27. right(:, 2) = right(:, 2) * BOOST;
  28. sound(right, Fs);
  29. delay(12);
  30. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31.  
  32. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. display('4. 8D Audio changes during one sound message: ');
  34. display(' ');
  35. left = d(:, 1);
  36. right = d(:, 2);
  37. SIZE = size(left);
  38. trito = floor(SIZE / 3);
  39.  
  40. for i = 1 : trito
  41.     left(i) = left(i) * BOOST;
  42. end
  43. for i = 2*trito+1 : SIZE
  44.     right(i) = right(i) * BOOST;
  45. end
  46. new(:, 1) = left;
  47. new(:, 2) = right;
  48. sound(new, Fs);
  49. delay(12);
  50. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  51.  
  52. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. % 8D Audio - Normal transition
  54. display('8D Audio - Normal transition (right ----> left): ');
  55. display(' ');
  56. left = d(:, 1);
  57. right = d(:, 2);
  58. mysize = size(left);
  59. SIZE = mysize(1);
  60. % First, I will create the 2 ranges
  61. low1 = 1;
  62. high1= BOOST;
  63. range1 = linspace(low1, high1, SIZE);
  64. range2 = fliplr(range1);
  65. % Now, I will create left and right
  66. for i = 1:SIZE
  67.     left(i) = left(i) * range1(i);
  68.     right(i) = right(i) * range2(i);
  69. end
  70. % Sound
  71. new(:, 1) = left;
  72. new(:, 2) = right;
  73. sound(new, Fs);
  74. delay(12);
  75. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76.  
  77.  
  78. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. % Auxiliary Function
  80. function delay(seconds)
  81.     counter = 0;
  82.     for i = 1 : seconds * 10^9
  83.         counter = counter + 1;
  84.     end
  85. end
  86. % ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement