Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9. class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13. string _FileName = "D:\\Uczelnia\\Technologie multimedialne\\LAB2\\audio.mp3";
  14. byte[] p;
  15. p = File.ReadAllBytes(_FileName);
  16. byte[] Stm = StereoToMono(p);
  17.  
  18. for (int i = 0; i < Stm.Length; i++)
  19. {
  20. Console.Out.WriteLine(Stm[i]);
  21. }
  22. Console.ReadKey();
  23.  
  24. }
  25. public static byte[] StereoToMono(byte[] input)
  26. {
  27. byte[] output = new byte[input.Length / 2];
  28. int outputIndex = 0;
  29. try
  30. {
  31. for (int n = 0; n < input.Length; n += 4)
  32. {
  33. output[outputIndex++] = input[n];
  34. output[outputIndex++] = input[n + 1];
  35. }
  36. }
  37. catch (Exception e)
  38. {
  39. return output;
  40. }
  41. return output;
  42. }
  43.  
  44.  
  45. private byte[] MonoToStereo(byte[] input)
  46. {
  47. byte[] output = new byte[input.Length * 2];
  48. int outputIndex = 0;
  49. try
  50. {
  51. for (int n = 0; n < input.Length; n += 2)
  52. {
  53.  
  54. output[outputIndex++] = input[n];
  55. output[outputIndex++] = input[n + 1];
  56.  
  57. output[outputIndex++] = input[n];
  58. output[outputIndex++] = input[n + 1];
  59. }
  60. }
  61. catch (Exception e)
  62. {
  63. return output;
  64. y}
  65. return output;
  66. }
  67.  
  68.  
  69.  
  70.  
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement