010-68421378
sales@cogitosoft.com
Your location:Home>News Center >Industry News

LightningChart: Big Data Visualization Tools | SignalReader quickly opens files for playback, AudioInput captures System.Double values & Displayed in LightningChart

latest update:2018/06/21 Views:926
17.SignalReadercomponent SignalReadercomponentallowsreadingdata fromasignalsourcefile,andplayingitbackwith selectedrat...

 

17.SignalReadercomponent

 

SignalReadercomponentallowsreadingdata fromasignalsourcefile,andplayingitbackwith selectedrate.SignalReaderoutputdata streamformatissimilartoSignalGenerator,seechapter16.10.

 

SignalReadercomponentcurrentlysupportsacoupleofformats,wavandsid.

 

17.1Keyproperties

 

FileNamedefinesthefile toopened,likec:\\wavedata\\audioclip1.wav”Factorsetstheoutputfactor.Rawsignalsamplesaremultipliedwith thisvalue.OutputIntervalis similartoSignalGenerator’sproperty,seesection16.1.

IsLoopingallowsfilereadtojumptothebeginningofthe file,whentheendoffilehasbeenreached.

 

Afterthefile hasbeenopened,thefollowingpropertiescanbeusedtogetinformationofthefile:

 

ChannelCount:thechannelcountofthe file.SamplingFrequency:samplingfrequencyin Hz.FileSize:Filesizeinbytes.

Length:Samplecountforeachchannel.Itmaynotbeexactforall signalfileformats.

 

IsReaderEnabled:Statustellingisthe componentstartedandreadingdata. IfLoopingissettofalseandendoffileis reached,IsReaderEnabledwillchangetofalse.

 

17.2Openingfilequicklyforplayback

 

CallOpenFile()methodsuppliedwithafilename.Filenamemusthaveanextensionofsupportedformats.Then, callStart()method

 

signalReader.OpenFile(“c:\\wavedata\\audioclip1.wav”);

 

signalReader.Start();

 

It willstartplaybackofaPCM-formattedWAV file.

PlaybackcanbestoppedbycallingStopRequest()method.

 

 

Figure17-1.SignalReaderreadsawavfileandLightningChartSampleDataSeriesdrawthesignal.AcursorlineisusedtomarkcurrentreadingpositionandX-axisscrollposition.

 

AudioInputcomponentallowsuserto capturesignalfromWindows’recordingdevicetoSystem.Doublevalues.ThesevaluescanthenberenderedonLightningChartUltimate,sendtoan AudioOutputcomponent,savedtoafileetc

 

18.1Properties

 

BitsPerSampleGetsorsetshowmanybitsareallocatedper sample.Supportedvaluesare8and16.If othervalueisused,16isusedinstead.IssettablewhenIsInputEnabledis false.

 

IsInputEnabledGetsorsetsthestateofthisinstance(i.e. startsorstopsit).Settingthispropertytrueis thesameascallingStartmethodwherefalseisthesameascallingStopmethod.

 

IsStereoGetsorsetswhethertousetwochannels(stereo)orjustone(mono).Issettablewhen

IsInputEnabledis false.

 

LicenseKeyGetsorsetslicensekeyin normalorencryptedformat.

 

RecordingDeviceGetsorsetsthe currentrecordingdevice.Is settablewhenIsInputEnabledis false.Bysettingthispropertynull,Windows'defaultrecordingdeviceisused.

 

SamplesPerSecondGetsorsetssamplingfrequency.Is settablewhenIsInputEnabledisfalse.

 

ThreadInvokingGetsorsetswhetherthisinstanceautomaticallysynchronizesitseventstothemain

UI threadhenceeliminatingtheneedtocall Control.Invokemethodoncaller'sside.

 

VolumeGetsorsetsvolume(0-100).IssettablewhenIsInputEnabledis false.

 

18.2Methods

 

GetRecordingDevicesUsethisstaticmethodtogeta listofavailableWindowsrecordingdevices.

 

RequestStopSignalsthisAudioInputinstancetostop.Stopdoesnotoccurimmediatelyafterexitingthismethod.BysubscribingtoStoppedevent,callerisnotifiedwheneverythinghas stopped.

 

StartStartsreadingaudiofromselectedrecordingdevice.Startedeventistriggeredwheninternalthreadisabouttostart.

 

DataGeneratedOccurswhenanewsetofaudiodatahas beengenerated.Dataanditsfirstsample’s

timestampcanbereadfromaDataGeneratedEventArgsobjectthatisprovidedas aparameter.

 

StartedOccurswhenaudioinputhasbeenstarted.StartedEventArgsobjectthatis providedasa parameter,containsthreepublicfields:BitsPerSample,ChannelCountandSamplesPerSecond.

 

StoppedOccurswhenaudioinputhasbeenstopped.

 

18.4Usage(WinForms)

 

This chapterdescribestheusageofWinFormsversionofAudioInputclass.WPFversionwillbehandledinchapter17.5.

 

18.4.1Creation

 

CreateanewAudioInputinstanceeitherbymanuallyin yoursourcecodeorbydraggingand

droppingitfromVisualStudio’stoolboxonto yourform,usercontroletc.

 

If youdonotneedtoshowthe GUI(i.e. youuseyourown oryoucontrolAudioInputobjectfromyoursourcecode)then setVisiblepropertyfalse.Parentpropertyisalwaysrecommendedtosetso that whentheparentcontrolis disposedof,AudioInputinstancegetsdisposedof automatically.If thereisnoparentthendonotforgettocallDisposemethodwhen youaredonewithAudioInputinstance.Note,ifyoucreatea newAudioInputinstanceviaVisualStudiostoolboxthenParentis automaticallyset.

 

It isrecommendedto setLicenseKeypropertyso thatyourAudioInputinstanceusesanexplicitlicensekeyinsteadoftryingtofindonefromWindows’registry.Note,ifyouareusingatrial version/licensethenyoucanleaveLicenseKeypropertytoitsdefaultvalue.

 

18.4.2Eventhandling

 

TogetnewsamplesfromAudioInputinstanceyouneedtosubscribeatleasttoDataGeneratedevent.WhenDataGeneratedeventistriggeredyoucangetthenewsamplesandthefirstsampletimestampfromaDataGeneratedEventArgsobjectprovidedasa parameter.

If youwanttoknowwhenAudioInputinstancehasstarteditsaudiosamplingtaskyousubscribeto Started event.Youcangetthe numberofbits persample,isaudiomonoorstereoandhowmanysamplesper secondaregeneratedfromStartedEventArgsobjectthatisprovidedasa parameter.

 

If youwanttoknowwhenAudioInputinstancehasstoppedyousubscribetoStoppedevent.Ithasnoparametersanditssolepurposeistotelluserwheneverythinghas beenstopped.

 

Next:ReSharper:| LeadingCode Generation Tools|RefinedCode Navigation, all Around Improves C# 7 Language Support,In-depthCode Analysis, Smart Code Assistance
Prev:Ftrack personalization and personal customization

© Copyright 2000-2023  COGITO SOFTWARE CO.,LTD. All rights reserved