Centrafuse SDK Logo ALPHA 2 RELEASE


ICFRadio Interface Reference

List of all members.

Public Member Functions

bool InitializeRadio ()
 Initialize radio hardware.
void ShutdownRadio ()
 Shutdown radio hardware.
void Mute ()
 Mute radio output volume.
void UnMute ()
void StandbyRadio (int currentFreq)
 Radio Standby, called when system goes into standby and/or power saving mode.
bool ResumeRadio (int currentFreq)
 Radio Resume, called when system resumes from standby / poser saving mode.
int TuneFreq (int Freq)
 Shall set the tuner frequency.
int SeekFreq (RADIO_DIRECTION searchDirection, int currentFreq)
 Seek.
bool SetTuneBand (RADIO_TUNE_BAND Band)
 Set tuner band (AM / FM).
int GetStation ()
string GetRDSInformation ()
 Get RDS information if available.
bool StereoLockSupport ()
 Indicates whether the radio supports a stereo lock flag. This is used for seeking, when seek functions are not available, to know when the radio has locked onto a station. If you have working seek functions, return false.
bool StereoLock ()
 Indicates whether the radio is locked onto a station, by knowing if it has a stereo lock.

Properties

string RadioDevice [get]
 Radio device.

Detailed Description

Radio interface. Centrafuse Radio Modules are (Microsoft termed) "Class libraries", built from projects in .NET that produce a dll library object that Centrafuse can load at runtime. These dll's must expose at least 1 class which inherits from ICFRadio, available through the Centrafuse Plugin Interface Dll, cfplugin.dll, which must be referenced by plugin's project.

Your radio interface will inherit the ICFRadio class, and will need to implement a set of functions defined by ICFRadio to allow Centrafuse to communicate to it. Some examples are:

One a radio module is written and compiled, you can simply create a directory in the Centrafuse runtime folder, at RadioModules/[RADIOMODULE_NAME], place your dll(s) there, and Centrafuse will include it into the list of available radio interfaces to use.


Member Function Documentation

string GetRDSInformation (  ) 

Get RDS information if available.

Returns:
Returns RDS information, return null if RDS is not supported.
int GetStation (  ) 

Get current tuner station/frequency.

Returns:
Returns current station. Return -1 if getting current station is not supported. This method is used to show the station scrolling as you seek. When using asynchronous seek methods this will be used to determine when it has locked onto a station and show the seek while in progress.
bool InitializeRadio (  ) 

Initialize radio hardware.

Returns:
Returns true if initialization is successful, false otherwise.

The following sample code is taken from the example HQCT project from the SDK Examples directory. As with many radio modules, the HQCT example project only references a lower level dll written in C that communicates directly with the radio hardware. The exported C functions are imported into the example code, and the API provided by the radio hardware dll is used accordingly. It is easy to see using the example project though the straight forward set of functions that must be implemented in order for Centrafuse to be able to control your radio hardware.

 public bool InitializeRadio()
 {
     CFTools.writeLog("HQCT", "");
     try
     {
         init = HQCT.InitHQCT();
         if (init == false)
         {
             CFTools.writeLog("HQCT", "HQCT.InitHQCT() Failed, retrying 3 times...");
             for (int i = 1; i <= 3 && init == false; i++)
             {
                 CFTools.writeLog("HQCT", "HQCT.InitHQCT() Retry " + i.ToString() + "...");
                 System.Threading.Thread.Sleep(750 * i);
                 init = HQCT.InitHQCT();
             }
         }

         CFTools.writeLog("HQCT", "init = " + init.ToString());

         if (init)
         {
             moduletypeStr = GetModuleType();

             if(currentband == RADIO_TUNE_BAND.FM_BAND)
                 HQCT.HQCTSwitchBand(true);
             else
                 HQCT.HQCTSwitchBand(false);

             XmlDocument configxml = new XmlDocument();
             configxml.Load(CFTools.AppDataPath + "\\RadioModules\\HQCT\\HQCT.xml");

             int bass = -12;              // -14 - +14
             int treble = 9;             // -14 - +14
             int loudness = -5;         // -20 - +0
             int volume = -30;           // -60 - +20
             int seeksensitivity = 2;

             try { bass = Int32.Parse(configxml.SelectSingleNode("/HQCT/BASS").InnerText); }
             catch {}

             try { treble = Int32.Parse(configxml.SelectSingleNode("/HQCT/TREBLE").InnerText); }
             catch {}

             try { loudness = Int32.Parse(configxml.SelectSingleNode("/HQCT/LOUDNESS").InnerText); }
             catch {}

             try { volume = Int32.Parse(configxml.SelectSingleNode("/HQCT/VOLUME").InnerText); }
             catch {}

             try { seeksensitivity = Int32.Parse(configxml.SelectSingleNode("/HQCT/SEEKSENSITIVITY").InnerText); }
             catch {}

             HQCT.HQCTSetSoundSource(0);
             HQCT.HQCTBass(bass);
             HQCT.HQCTTreble(treble);
             HQCT.HQCTLoudness(loudness);
             HQCT.HQCTVolume(volume);
             HQCT.HQCTSetSeekSentive(seeksensitivity);
         }
     }
     catch(Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }

     return init;
 }
void Mute (  ) 

Mute radio output volume.

bool ResumeRadio ( int  currentFreq  ) 

Radio Resume, called when system resumes from standby / poser saving mode.

Returns:
Returns true if initialization is successful, false otherwise.
int SeekFreq ( RADIO_DIRECTION  searchDirection,
int  currentFreq 
)

Seek.

Returns:
Returns radio frequency. Return -1 if seek not available. Return -2 if you are using asynchronous seeking methods.
bool SetTuneBand ( RADIO_TUNE_BAND  Band  ) 

Set tuner band (AM / FM).

Returns:
Return false if multiple bands not supported.
void ShutdownRadio (  ) 

Shutdown radio hardware.

The following sample code is taken from the example HQCT project from the SDK Examples directory. As with many radio modules, the HQCT example project only references a lower level dll written in C that communicates directly with the radio hardware. The exported C functions are imported into the example code, and the API provided by the radio hardware dll is used accordingly. It is easy to see using the example project though the straight forward set of functions that must be implemented in order for Centrafuse to be able to control your radio hardware.

 public void ShutdownRadio()
 {
     CFTools.writeLog("HQCT", "");
     try
     {
                   if(init)
         {
             HQCT.HQCTMute(true);
             HQCT.FreeHQCT();
         }
     }
     catch(Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }
 }
void StandbyRadio ( int  currentFreq  ) 

Radio Standby, called when system goes into standby and/or power saving mode.

bool StereoLock (  ) 

Indicates whether the radio is locked onto a station, by knowing if it has a stereo lock.

Returns:
Returns whether the radio is locked onto a station, by knowing if it has a stereo lock.
bool StereoLockSupport (  ) 

Indicates whether the radio supports a stereo lock flag. This is used for seeking, when seek functions are not available, to know when the radio has locked onto a station. If you have working seek functions, return false.

Returns:
Returns whether the radio supports a stereo lock flag.
int TuneFreq ( int  Freq  ) 

Shall set the tuner frequency.

Returns:
Returns tuner frequency.
void UnMute (  ) 

UnMute radio output volume.


Property Documentation

string RadioDevice [get]

Radio device.

The folowing code illustrates how to implement this property using C#.

 public string RadioDevice
 {
     get
     {
        return "HQCT";
     }
 }




Copyright © 2010 Flux Media, Inc. (U.S. Copyright Registration Number: TXu-1-239-794)