生成DTMF音调

Dut*_*432 7 iphone generator dtmf

我想知道是否有人遇到过在iPhone SDK中生成音调的方法.我试图生成DTMF音调,似乎找不到任何实质性的东西.我希望能够指定播放音调的时间长度(即模拟按住按钮而不是简单地按下它.

我发现了一个名为iPhreak的开源应用程序.它应该产生DTMF音调来欺骗付费电话(我向你保证这不是我的意图 - 我的公司处理基于电话的内部通信系统).该应用程序的唯一问题是开源项目中缺少文件.也许其他人已经让这个项目在过去工作了?

如果有人知道我会在哪里找到这样的东西,我将非常感谢我的投票:)

Toa*_*oad 5

应该很容易产生自己.考虑到硬件可以以44.1 khz播放pcm缓冲区(16位样本)(它肯定可以使用某些库函数或其他函数),您只需要计算波形:

 const int PLAYBACKFREQ = 44100;
 const float PI2 = 3.14159265359f * 2;

 void generateDTMF(short *buffer, int length, float freq1, float freq2)
 {
      int i;
      short *dest = buffer;
      for(i=0; i<length; i++)
      {
           *(dest++) = (sin(i*(PI2*(PLAYBACKFREQ/freq1))) + sin(i (PI2*(PLAYBACKFREQ/freq2)))) * 16383;
      }
 }
Run Code Online (Sandbox Code Playgroud)

由于我正在使用添加剂合成(仅将正弦波加在一起),因此完成了16383.因此最大结果是-2.0 - 2.0所以在乘以16383后,我或多或少得到最大16位结果:-32768 - +32767

编辑:2个常见的是来自维基百科文章的频繁,其他人回答链接.两个独特的频率产生DTMF声音


mah*_*udz 5

答案很简单:

soundArray = [[NSArray alloc] initWithObjects: 
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-0.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-1.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-2.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-3.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-4.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-5.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-6.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-7.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-8.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-9.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-0.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-pound.caf"] autorelease],
    [[[SoundEffect alloc] initWithContentsOfFile: @"/System/Library/Audio/UISounds/dtmf-star.caf"] autorelease],
              nil];
Run Code Online (Sandbox Code Playgroud)

你有它.所有标准电话键盘的声音,阵列,准备好您的乐趣.