生成DTMF音调 [英] Generate DTMF Tones

查看:153
本文介绍了生成DTMF音调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am wondering if anyone has come across a way to generate tones in the iPhone SDK. I am trying to generate DTMF tones, and can't seem to find anything substantial out there. I want to be able to specify how long to play the tone for as well (i.e. to simulate holding the button down as opposed to just pressing it briefly..

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

I found an open source app called iPhreak. It supposedly generates DTMF tones to fool payphones (I Assure you this is not my intention - my company deals with telephone based Intercom systems). The only problem with that application is that there are files missing from the open source project. Perhaps someone else has gotten this project to work in the past?

如果有人知道我会在哪里寻找这样的东西,我会非常赞赏我的投票:)

If anyone has any idea on where I would look for something like this, I would be very appreciative with my votes :)

推荐答案

应该很容易自己生成。
假设硬件可以以44.1 khz播放pcm缓冲区(16位样本)(肯定可以使用某些库函数或其他函数),你只需要计算波形:

should be easy enough to generate yourself. given that the hardware can playback a pcm buffer (16bit samples) at 44.1 khz (which it surely can with some library function or the other), you're only left with calculating the waveform:

 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;
      }
 }

自从我使用加性合成以来16383已完成(只是将正弦波加在一起)。因此最大结果是-2.0 - 2.0所以在乘以16383之后我得到或多或少的最大16位结果:-32768 - +32767

the 16383 is done since I'm using additive synthesis (just adding the sinewaves together). Therefore the max result is -2.0 - 2.0 So after multiplying by 16383 I get more or less the max 16 bit result: -32768 - +32767

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

the 2 frequenties are the frequenties from the wikipedia article the other person who answered linked to. Two unique frequencies make a DTMF sound

这篇关于生成DTMF音调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆