[This is preliminary documentation and is subject to change.]
Assembly: App_Code.fxrph_yi (in App_Code.fxrph_yi)
Version: 0.0.0.0
Syntax
| C# |
|---|
public WS..::.EditAudioContentResult EditAudioContent( string AccessKey, string SourceFile, double StartSec, double EndSec, int Codec, string OutputFileExtension, int Amplify, double FadeInSec, double FadeOutSec ) |
| Visual Basic (Declaration) |
|---|
Public Function EditAudioContent ( _ AccessKey As String, _ SourceFile As String, _ StartSec As Double, _ EndSec As Double, _ Codec As Integer, _ OutputFileExtension As String, _ Amplify As Integer, _ FadeInSec As Double, _ FadeOutSec As Double _ ) As WS..::.EditAudioContentResult |
| JScript |
|---|
public function EditAudioContent( AccessKey : String, SourceFile : String, StartSec : double, EndSec : double, Codec : int, OutputFileExtension : String, Amplify : int, FadeInSec : double, FadeOutSec : double ) : WS..::.EditAudioContentResult |
Parameters
- AccessKey
- Type: System..::.String
Security key allocated to a developer enabling access to the web service API.
- SourceFile
- Type: System..::.String
Internal source file name within Phone Sherpa system. Expressed as a random and unique file name without a path. Typically the output of LoadFileFromURL(...), but can be any internal SourceFile handle to an audio file.Supported audio formats: mp3, wma, wav, aac, mp4, m4a, aif, snd, and au. Files encoded with DRM are not supported regardless of format.
- StartSec
- Type: System..::.Double
Time in the source audio file to begin the output clip. Expressed in seconds. Use 0.0 to start at the beginning of the source audio track. Ex: "12.6"
- EndSec
- Type: System..::.Double
Time in the source audio file to end the output clip. Expressed in seconds. Use 0.0 to end the clip at the end of the source audio track. Ex: "143.1"
- Codec
- Type: System..::.Int32
An enumeration value of supported audio codecs. See codec table for audio property details on each codec. These codecs are not intended for general audio conversion, rather, they have been selected and optimized to target phone playback through the external speaker. Good ratios of compression and audio quality have been factored into the selection of the codecs supported.
- OutputFileExtension
- Type: System..::.String
The extension of the resultant audio clip file name. This allows for setting non standard file exentions for known types. This setting is optional, setting the value to an empty string "" will use the default extension associated with the selected codec.Ex: one can convert to a wav codec and give it the ".adp" extension for playback on certian Blackberry devices. It is uncommon, however, to use an extension other than the standard for the codec type.
- Amplify
- Type: System..::.Int32
Amplifies the baseline volume on the output audio clip. Enumeration values for this parameter in percentage of volumne boost:
0 = 0%, 1 = 25%, 2 = 50%, 3 = 100%
- FadeInSec
- Type: System..::.Double
The number of seconds to apply a linear fade in from the start of the output audio clip. Use 0.0 for no fade in. Typical fade in values (if present) are 1.5 to 3.0 seconds.
- FadeOutSec
- Type: System..::.Double
The number of seconds to apply a linear fade out from before the end of the output audio clip. Use 0.0 for no fade out. Typical fade out values (if present) are 1.5 to 3.0 seconds.
Return Value
An internal source file handle to the converted audio clip.
Remarks
EditAudioContent is the generalized form of the EditAudioContentForPhone function. This is typically used when a developer already knows the target audio codec and supported file size of a phone model. Phone Sherpa supports several non standard and proprietary output audio codecs specifically for phone playback. This function makes these codecs available to the developer.
Converting audio files for phone playback has several considerations. Paramount is the supported audio formats by the target phone model; handsets can only play very specific audio formats. Additionally, most phones only play particular encodings of a format. Example: many Motorola handsets play mp3 formats, but support only particular bitrate encodings. It is not sufficient to send any mp3 encoding to most Motorola handsets.
Time length of the audio clip is a 2nd consideration. Most handsets go to voice mail after 4 rings...typically 20-22 seconds after the first ring. Making ringtone clips longer than 30 seconds is a waste of file size on the hand set.
Another key consideration is file size. Most phones have a maximum supported file size for audio clips used as ringtones. This varys greatly from handset to handset, resulting in clips not playing fully or clips not even able to be downloaded to the phone. File size is a function of selected codec bitrate X file length in seconds. Choosing lower bitrate (and lower quality) codecs or reducing the duration of a clip can reduce the output file size.
Amplification is needed only in cases where a handset is known to have poor playback abilities through its external speaker. Amplifying output files 50% or more typcialy results in poor audio quality, as any "loud" parts of the audio are "clipped" or chopped out of the audio waveform. The output file maybe loud but it may also be unrecognizable.
The ConvertedFile in the result object can be used in any function that takes a SourceFile parameter, such as the SendContentToPhone(...) function.
| Codec Enumeration Values | ||||
| Value | Name | Bitrate | Frequency | Channels |
| 1 | IMA ADPCM | 88800 | 22050 | 1 |
| 2 | IMA ADPCM | 40000 | 11025 | 1 |
| 3 | IMA ADPCM | 32000 | 8000 | 1 |
| 6 | AMR | 5150 | n/a | 1 |
| 7 | AMR | 7400 | n/a | 1 |
| 8 | AMR | 12200 | n/a | 1 |
| 9 | IMA ADPCM | 32000 | 8000 | 1 |
| 10 | IMA ADPCM | 40000 | 11025 | 1 |
| 11 | IMA ADPCM | 80000 | 22050 | 1 |
| 12 | PCM | 64000 | 8000 | 1 |
| 13 | PCM | 128000 | 8000 | 1 |
| 14 | PCM | 160000 | 11025 | 1 |
| 15 | GSM 6.10 | 16000 | 11025 | 1 |
| 16 | GSM 6.10 | 32000 | 22050 | 1 |
| 17 | GSM 6.10 | 64000 | 44100 | 1 |
| 18 | CCITT A-Law | 64000 | 8000 | 1 |
| 19 | CCITT A-Law | 80000 | 11025 | 1 |
| 20 | CCITT A-Law | 160000 | 22050 | 1 |
| 21 | CCITT u-Law | 64000 | 8000 | 1 |
| 22 | CCITT u-Law | 80000 | 11025 | 1 |
| 23 | CCITT u-Law | 160000 | 22050 | 1 |
| 27 | AMR-WB | 12650 | n/a | 1 |
| 28 | AMR-WB | 18250 | n/a | 1 |
| 29 | AMR-WB | 23850 | n/a | 1 |
| 36 | MP3 | 32000 | 16000 | 1 |
| 37 | MP3 | 40000 | 24000 | 1 |
| 38 | MP3 | 64000 | 44100 | 1 |
| 42 | WMA | 16000 | 8000 | 1 |
| 43 | WMA | 32000 | 22050 | 1 |
| 44 | WMA | 64000 | 44100 | 1 |
| 54 | QCP | 16000 | 8000 | 1 |
| 60 | AAC | 16000 | 24000 | 1 |
| 61 | AAC | 32000 | 32000 | 1 |
| 62 | AAC | 64000 | 44100 | 1 |
| 63 | IMA BlkBrry | 40000 | 11025 | 1 |
| 64 | MP3 Flash | 24000 | 22050 | 1 |
Below is an example of how to use this function:
Public Sub EditAndDeliverRingtone(ByVal UserPhoneInfo As PhoneSherpa.Services.UserPhoneInformation, ByVal SourceFile As String, ByVal FriendlyFileName As String, ByVal StartSec As Double, ByVal EndSec As Double, ByVal FadeInSec As Double, ByVal FadeOutSec As Double) Dim SherpaService As New PhoneSherpa.Services.WS 'Take the editor parameters and clip/convert the source file for the user's phone model. Dim RingtoneEdit_Response As New PhoneSherpa.Services.EditAudioContentResult Dim Codec As Integer = 37 'MP3_Medium codec (40kbps, 24khz, 1 channel) RingtoneEdit_Response = SherpaService.EditAudioContent("My_WSAccessKey", SourceFile, StartSec, EndSec, Codec, "", 0, FadeInSec, FadeOutSec) 'Check the response to ensure the call worked If RingtoneEdit_Response.Result.ErrorCode = 0 Then 'Bill the user or take some other action within the host application code '[host actions here] 'Deliver the converted ringtone clip the the user's phone 'This assumes that host applicatoin has presented a UI for selecting phone model or is pulling this information from its 'own account system Dim SendToPhone_Response As New PhoneSherpa.Services.SendContentToPhoneResult SendToPhone_Response = SherpaService.SendContentToPhone("My_WSAccessKey", UserPhoneInfo, RingtoneEdit_Response.ConvertedFile, FriendlyFileName) If SendToPhone_Response.Result.ErrorCode = 0 Then 'ringtone delivery succeeded, redirect user to a success page and display ringtone install instructions '... Else 'error - the send ringtone to phone call failed, redirect to an error handler End If Else 'error - the ringtone edit call failed, redirect to an error handler End If End Sub