[This is preliminary documentation and is subject to change.]

Cuts and converts an audio file into a new audio clip. Developer specifies the target audio codec.

Namespace:  PhoneSherpa.Services
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
ValueNameBitrateFrequencyChannels
1IMA ADPCM88800220501
2IMA ADPCM40000110251
3IMA ADPCM3200080001
6AMR5150n/a1
7AMR7400n/a1
8AMR12200n/a1
9IMA ADPCM3200080001
10IMA ADPCM40000110251
11IMA ADPCM80000220501
12PCM6400080001
13PCM12800080001
14PCM160000110251
15GSM 6.1016000110251
16GSM 6.1032000220501
17GSM 6.1064000441001
18CCITT A-Law6400080001
19CCITT A-Law80000110251
20CCITT A-Law160000220501
21CCITT u-Law6400080001
22CCITT u-Law80000110251
23CCITT u-Law160000220501
27AMR-WB12650n/a1
28AMR-WB18250n/a1
29AMR-WB23850n/a1
36MP332000160001
37MP340000240001
38MP364000441001
42WMA1600080001
43WMA32000220501
44WMA64000441001
54QCP1600080001
60AAC16000240001
61AAC32000320001
62AAC64000441001
63IMA BlkBrry40000110251
64MP3 Flash24000220501

Below is an example of how to use this function:

CopyVB.NET
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

See Also