aRts audio server
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

116 行
3.2KB

  1. /*
  2. Copyright (C) 2000 Stefan Westerfeld
  3. stefan@space.twc.de
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. Permission is also granted to link this program with the Qt
  16. library, treating Qt like a library that normally accompanies the
  17. operating system kernel, whether or not that is in fact the case.
  18. */
  19. #include "gslpp/datahandle.h"
  20. #include "soundserver.h"
  21. #include "stdsynthmodule.h"
  22. #include "artsflow.h"
  23. #include "connect.h"
  24. #include <stdio.h>
  25. #include <unistd.h>
  26. #include <fcntl.h>
  27. #include <iostream>
  28. #include <math.h>
  29. using namespace std;
  30. using namespace Arts;
  31. int main(int argc, char **argv)
  32. {
  33. if(argc<2)
  34. {
  35. cerr << "USAGE: " << argv[0] << " [filename]\n";
  36. exit(1);
  37. }
  38. Dispatcher dispatcher;
  39. SoundServer server = Reference("global:Arts_SoundServer");
  40. cout << "opening '" << argv[1] << "' locally...\n";
  41. GSL::WaveFileInfo info(argv[1]);
  42. if(info.error())
  43. {
  44. cerr << "GSL error " << info.error() <<
  45. " (" << gsl_strerror(info.error()) << ") while loading info.\n";
  46. exit(1);
  47. }
  48. cout << "file contains " << info.waveCount() << " waves:\n";
  49. for(int i=0; i<info.waveCount(); i++)
  50. {
  51. GSL::WaveDescription desc= info.waveDescription(i);
  52. cout << " wave " << i << ": " << desc.name() <<
  53. " (" << desc.channelCount() << " channels):\n";
  54. for(int ci=0; ci<desc.chunkCount(); ci++)
  55. {
  56. GSL::WaveChunkDescription cDesc= desc.chunkDescription(ci);
  57. cout << " chunk " << ci << ": "
  58. << cDesc.oscillatorFrequency()
  59. << "hz, recorded with " << cDesc.mixerFrequency()
  60. << ", loop type: " << cDesc.loopType() << "\n";
  61. }
  62. }
  63. cout << "opening '" << argv[1] << "' in soundserver for playback...\n";
  64. if(server.isNull())
  65. {
  66. cerr << "Can't connect to sound server" << endl;
  67. return 1;
  68. }
  69. WaveDataHandle handle = DynamicCast(server.createObject("Arts::WaveDataHandle"));
  70. if(!handle.load(argv[1]))
  71. {
  72. cerr << "server can't load wave file '" << argv[1] << "'" << endl;
  73. return 1;
  74. }
  75. printf("channels = %d\n", handle.channelCount());
  76. //printf("samplingrate = %f\n", handle.samplingRate());
  77. printf("length[values] = %ld\n", handle.valueCount());
  78. DataHandlePlay phandle = handle.createPlayer();
  79. /*DataHandlePlay phandle =
  80. DynamicCast(server.createObject("Arts::DataHandlePlay"));
  81. phandle.handle(handle);
  82. // .createReversed() .createTranslated(0,100000,40000)
  83. */
  84. Synth_BUS_UPLINK bu =
  85. DynamicCast(server.createObject("Arts::Synth_BUS_UPLINK"));
  86. connect(phandle,"outvalue",bu,"left");
  87. connect(phandle,"outvalue",bu,"right");
  88. bu.busname("out_soundcard");
  89. phandle.start();
  90. bu.start();
  91. while(!phandle.finished())
  92. sleep(1);
  93. }