IOS Instant Chat audio format Turn NSData

Source: Internet
Author: User
WAV: Losslessis a sound file format developed by Microsoft that conforms to the Piffresource Interchange File format specification for storing audio information resources for the Windows platform and is supported by the Windows platform and its applications. “*. WAV "format support MSADPCM, Ccittalaw and other compression algorithms, support a variety of audio digits, sampling frequency and channel, the standard format of WAV files and CD format, is also a 44.1K sampling frequency, rate 88k/seconds, 16-bit quantization digits, see the bar,   WAV format sound file quality and CD, is also the current PC on the popular sound file format, almost all audio editing software "know" wav format. Here, incidentally, the AIFF (audiointerchange fileformat) format developed by Apple and the AU format developed for UNIX systems are very much like WAV and support their common music formats in most audio editing software. MP3: Popular The MP3 format was born in Germany in the 80 's, and the so-called MP3 refers to the audio portion of the MPEG standard, the MPEG audio layer. According to the compression quality and coding processing of different 3 layers, corresponding to "*.MP1"/"*.MP2"/"*.mp3" These 3 kinds of sound files. What needs to be noticed is that the compression of MPEG audio files is a lossy compression, MPEG3 audio Coding has a high compression rate of 10:1~12:1, while basically keeping the low audio part not distorted, But at the expense of the sound file 12KHz to 16KHz High Audio this part of the quality in exchange for the size of the file, the same length of the music file, with the *.mp3 format to store, generally only 1/10 of the *.wav file, and the sound quality to the CD format or WAV format sound files. Because of its small file size, good sound quality, so at the beginning of its inception there is no other audio format can match, and thus for the development of *.mp3 format provides a good condition.   Until now, this format is still rage, as the mainstream audio format is difficult to be shaken. MP3 format Compression Music sampling frequency has many kinds, may use the 64Kbps or the lower sampling frequency to save the space, also may use the 320Kbps standard to achieve the extremely high sound quality. We used the MP3 encoder with the Fraunhoferiis Mpeg Lyaer3 (now the best encoder) MusicMatch Jukebox6.0 encoded a 3-minute song in 128Kbps frequency to get 2.82MB MP3 files. Using the default CBR (fixed sampling frequency) technology can sample a song at a fixed frequency, while VBR (variable sampling frequency) can increase the frequency of sampling while the music is "busy" to obtain higher sound quality, but the resulting MP3 file may not play on some players. We set the level of VBR to be the same as the sound quality of the previous CBR file, resulting in a VBRMP3 file of 2.9MB. MIDI: Composer's favorite people who often play music should often hear the word midi (musicalinstrument Digital Interface), which allows digital synthesizers and other devices to exchange data. The mid file format is inherited by MIDI. The mid file is not a recorded sound, but a set of instructions that record the sound and then tell the sound card how to reproduce the music. Such a MIDI file uses only about 5~10KB for every 1 minutes of music stored. Today, mid files are mainly used for original instrument works, amateur performances of pop songs, audio games and electronic greeting cards. The effect of *.mid file replay is entirely dependent on the sound card's grade. The greatest use of *.mid format is in the field of computer composition. *.mid files can be written in the composition software, but also through the sound card of the midi mouth of the external sequencer playing music into the computer, made *.mid files. WMA: The most powerful WMA (Windows Media Audio) format is from Microsoft's heavyweight, the background is strong, the sound quality is stronger than the MP3 format, farther than the RA format, it and Japanese Yamaha company developed VQF format, is to reduce the data flow but maintain the quality of the method to achieve than MP3 compression For a higher rate, the compression rate of WMA can generally reach about 1:18, and the other advantage of WMA is that content providers can use DRM (digitalrights Management) schemes such as Windows Media Rights Manager7 Add anti-copy protection. This built-in copyright protection technology can limit the playback time and the number of times and even play the machine and so on, which is the Pirates of the chaos of the music company is a good gospel, in addition, WMA also supports the audio stream (stream) technology, suitable for online playback on the network, as Microsoft Preemption Network Music The pioneers can be said to be technologically advanced, strong, and more convenient than the need to install additional players like MP3, and the seamless bundling of Windows operating systems and WindowsMedia players allows you to play WMA music directly as long as you have Windows operating systems installed. The new version of Windows MediaPlayer7.0 has increased the ability to convert CDs directly to WMA sound format, and in the new operating system, WMA is the default encoding format, and you know what happened to Netscape, and now the wolf is here again. WMA This format can be used to adjust the sound quality when recording. In the same format, the sound quality can be comparable to the CD, the compression rate of high can be used for webcasts. Although the network is not very popular now, but in the large-scale promotion of Microsoft has been more and more recognition of the site and strong support, in the field of network music is almost *.mp3, in the network broadcast, is also carved up the world of real lay. As a result, almost all audio formats feel the pressure of the WMA format.

-(void) viewdidload

{

[Superviewdidload];

Self.view.backgroundColor = [Uicolor Whitecolor];

dispatch_queue_t dispatchqueue = Dispatch_get_global_queue (dispatch_queue_priority_default,0);

Dispatch_async (dispatchqueue,^ (void) {

Nsstring*filepath = [[Nsbundlemainbundle] pathforresource:@ "Test" oftype:@ "MP3"];

nsdata* data= [NSData Datawithcontentsoffile:filepath];

Nserror*error = nil;

Self.audioplay = [[Avaudioplayer alloc] Initwithdata:data error:&error];

if (_audioplay!= nil) {

Self.audioPlay.delegate = self;

} else {

NSLog (@ "Error");

NSLog (@ "%@", error.description);

}

});

Do no additional setup after loadingthe view.

}
The use of asyncsocket for data transmission,, if not high requirements for the information can be used Asyncudpsocket

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.