setPosition() public method

public setPosition ( uint position, TIMEUNIT postype ) : RESULT
position uint
postype TIMEUNIT
return RESULT
Esempio n. 1
0
 public void Seek(TimeSpan position)
 {
     if (status == STATUS.PLAY && channel != null)
     {
         channel.setPosition((uint)position.TotalMilliseconds, TIMEUNIT.MS);
     }
 }
Esempio n. 2
0
 public void SetPosition(uint pos)
 {
     if (channel != null)
     {
         result = channel.setPosition(pos, FMOD.TIMEUNIT.MS);
     }
 }
Esempio n. 3
0
        public void SetProgress(float Value)
        {
            if (_channel == null || _sound == null)
            {
                return;
            }

            uint len = 0;

            _sound.getLength(out len, TIMEUNIT.MS);
            _channel.setPosition((uint)(len * Value), TIMEUNIT.MS);
        }
Esempio n. 4
0
 public void Position(uint lenms)
 {
     if (channel != null)
     {
         channel.setPosition(lenms, FMOD.TIMEUNIT.MS);
     }
 }
Esempio n. 5
0
    // Use this for initialization
    void Start () {
        lowLevelSystem = RuntimeManager.LowlevelSystem;
        channel = new FMOD.Channel();
        lowLevelSystem.getMasterChannelGroup(out channelGroup);

        soundInfo = new FMOD.CREATESOUNDEXINFO();
        soundInfo.cbsize = Marshal.SizeOf(soundInfo);
        soundInfo.decodebuffersize = (uint)sampleRate / 10;
        soundInfo.length = (uint)(sampleRate * numberOfChannels * sizeof(short));
        soundInfo.numchannels = numberOfChannels;
        soundInfo.defaultfrequency = sampleRate;
        soundInfo.format = FMOD.SOUND_FORMAT.PCM16;

        soundInfo.pcmreadcallback = PCMReadCallback;
        soundInfo.pcmsetposcallback = PCMSetPositionCallback;

        lowLevelSystem.setStreamBufferSize(65536, FMOD.TIMEUNIT.RAWBYTES);
        lowLevelSystem.createStream("SoundGeneratorStream", FMOD.MODE.OPENUSER, ref soundInfo, out generatedSound);

        generatedSound.setMode(FMOD.MODE.OPENUSER | FMOD.MODE._3D | FMOD.MODE._3D_LINEARSQUAREROLLOFF);

        lowLevelSystem.playSound(generatedSound, channelGroup, true, out channel);
        channel.setLoopCount(-1);
        channel.setMode(FMOD.MODE.LOOP_NORMAL);
        channel.setPosition(0, FMOD.TIMEUNIT.MS);
        channel.set3DMinMaxDistance(minDistance, maxDistance);
        Update();
        channel.setPaused(false);
    }
Esempio n. 6
0
        public void SetPosition(UInt32 Position)
        {
            if (!SoundSystem.AudioFound)
            {
                return;
            }

            ActiveChannel.setPosition(Position, TIMEUNIT.MS);
        }
Esempio n. 7
0
 void PlayFMODSound()
 {
     lowlevelSystem.playSound(generatedSound1, channelGroupforInstrument, false, out channel1forInstrument);
     channel1forInstrument.setPosition(0, TIMEUNIT.MS);
     channel1forInstrument.setPaused(false);
     lowlevelSystem.playSound(generatedSound2, channelGroupforInstrument2, false, out channel2forInstrument);
     channel2forInstrument.setPosition(0, TIMEUNIT.MS);
     channel2forInstrument.setPaused(false);
 }
Esempio n. 8
0
    public void JoinReference(CustomAudioSource reference)
    {
        uint currentPosition, currentReferencePosition;

        if (Channel == null)
        {
            return;
        }
        Channel.getPosition(out currentPosition, TIMEUNIT.PCM);
        reference.Channel.getPosition(out currentReferencePosition, TIMEUNIT.PCM);
        var gapRatio = Mathf.Round((currentPosition / (float)currentReferencePosition) * 1000) / 1000;

        Speed  = reference.Speed - (gapRatio - 1) * 10;
        Volume = reference.Volume - Mathf.Abs(gapRatio - 1) * 100;
        if (currentPosition - currentReferencePosition >= 100 || currentPosition - currentReferencePosition == 0)
        {
            return;
        }
        Channel.setPosition(currentReferencePosition, TIMEUNIT.PCM);
        Speed = reference.Speed;
    }
Esempio n. 9
0
 //following function is not from original author
 /// <summary>
 /// set the time position
 /// </summary>
 /// <param name="time">time in milliseconds</param>
 public void SetTimePosition(uint time, TIMEUNIT un = TIMEUNIT.MS)
 {
     songChannel1.setPosition(time, un);
 }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        frequency        = 800;
        amplitude        = 1.0f;
        sampleGenerator  = GenerateSineSample;
        sampleGenerator2 = GenerateTriangleSample;

        //referencja do komponentow FMOD - wysokiego poziomu (studio) i niskiego
        studioSystem   = FMODUnity.RuntimeManager.StudioSystem;
        lowlevelSystem = FMODUnity.RuntimeManager.LowlevelSystem;

        //odniesienie do glownego kanalu - do niego bedziemy przesylac nasz dzwiek
        channel = new Channel();
        channel1forInstrument = new Channel();
        channel2forInstrument = new Channel();
        channel3forSoundFile  = new Channel();
        FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup);
        FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroupforInstrument);
        FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroupforInstrument2);

        FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroupforSoundFile);

        //inicjalizacja FFT (w FMODzie jako komponent DSP) i linerenderera do wyswietlania equalizera
        FMODUnity.RuntimeManager.LowlevelSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out fft);
        fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)FMOD.DSP_FFT_WINDOW.HANNING);
        fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, windowSize * 2);
        lineRendererFFT = gameObject.AddComponent <LineRenderer>();
        lineRendererFFT.positionCount = windowSize;
        lineRendererFFT.startWidth    = 0.1f;
        lineRendererFFT.endWidth      = 0.1f;
        channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft);
        //channelGroupforInstrument.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft);
        //channelGroupforInstrument2.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft);
        channelGroupforSoundFile.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft);

        lineRendererSamples = lineRendererHolder.AddComponent <LineRenderer>();
        lineRendererSamples.positionCount = sampleRate / 100;
        lineRendererSamples.startWidth    = 0.1f;
        lineRendererSamples.endWidth      = 0.1f;

        //lowPassFilterGraphMarker = GameObject.CreatePrimitive(PrimitiveType.Cube);
        //lowPassFilterGraphMarker.transform.position = new Vector3(0, lineRendererSamples.transform.position.y, 0.0f);
        //lowPassFilterGraphMarker.transform.localScale = new Vector3(0.5f, 5.0f, 0.5f);
        //lowPassFilterGraphMarker.SetActive(false);
        //lowPassFilterGraphMarker.GetComponent<Renderer>().material.color = Color.red;

        //Debug - sprawdzamy czy dobrze udalo nam sie zlapac kanal dzwiekowy (nie mamy jeszcze
        //obslugi bledow FMOD_OK)
        uint version;

        lowlevelSystem.getVersion(out version);
        bool channelIsPlaying;

        channel.isPlaying(out channelIsPlaying);
        UnityEngine.Debug.Log(channelIsPlaying);
        uint bl;
        int  numbuf;

        lowlevelSystem.getDSPBufferSize(out bl, out numbuf);
        UnityEngine.Debug.Log("DSP buffer size is: " + bl + ", " + numbuf);

        //Wczytujemy i odtwarzamy testowy plik do obiektu 'sound'
        //Przypisujemy nasz kanal do tej samej grupy co glowny kanal dzwieku
        FMOD.Sound sound;
        string     nametest = "";

        lowlevelSystem.createSound("Assets\\Sounds\\test2.mp3", FMOD.MODE.DEFAULT, out sound);
        sound.getName(out nametest, 20);
        UnityEngine.Debug.Log(nametest);


        InitSampleGeneration();

        //debug
        // (sampleCreated)
        //{
        lowlevelSystem.playSound(generatedSound, channelGroup, true, out channel);
        channel.setLoopCount(-1);
        channel.setMode(MODE.LOOP_NORMAL);
        channel.setPosition(0, TIMEUNIT.MS);
        channel.setPaused(true);
        //}
        //else
        //{
        lowlevelSystem.playSound(sound, channelGroupforSoundFile, true, out channel3forSoundFile);
        channel3forSoundFile.setLoopCount(-1);
        channel3forSoundFile.setMode(MODE.LOOP_NORMAL);
        channel3forSoundFile.setPosition(0, TIMEUNIT.MS);
        channel3forSoundFile.setPaused(false);
        //}
        //lowPassFilterGraphMarker.SetActive(false);

        InitFilters();
        filterApplier.InitFilterApplier();
        instrument.InitFilterApplier();
    }