Ejemplo n.º 1
0
    void PlayNewSong()
    {
        string documentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).ToString();
        string path            = documentsFolder + "/AGR2280/Custom Music/";

        string[] availableFiles = Directory.GetFiles(path, "*.mp3");

        // Pick song to stream
        songToPlay = UnityEngine.Random.Range(0, availableFiles.Length);

        if (channel != null)
        {
            channel = null;
        }
        PlayingMusic = null;

        result           = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
        result           = system.createSound(availableFiles [songToPlay], FMOD.MODE.CREATESTREAM, ref PlayingMusic);
        result           = system.playSound(music, PlayingMusic, false, ref channel);
        result           = system.createDSPByType(FMOD.DSP_TYPE.HIGHPASS, ref musicHighPass);
        result           = system.createDSPByType(FMOD.DSP_TYPE.LOWPASS, ref musicLowPass);
        result           = channel.addDSP(musicHighPass, ref highPassFilter);
        result           = channel.addDSP(musicLowPass, ref lowPassFilter);
        firstSongStarted = true;
    }
Ejemplo n.º 2
0
        public static void StopAllSounds()
        {
            if (!(GameDataManager.GameType == GameDataManager.GameTypes.DS1 ||
                  GameDataManager.GameType == GameDataManager.GameTypes.DS1R ||
                  GameDataManager.GameType == GameDataManager.GameTypes.DS3 ||
                  GameDataManager.GameType == GameDataManager.GameTypes.SDT))
            {
                return;
            }

            Main.WinForm.Invoke(new Action(() =>
            {
                int channelsPlaying = 0;
                result = _system.getChannelsPlaying(ref channelsPlaying);

                if (result == RESULT.ERR_INVALID_PARAM || result == RESULT.ERR_INVALID_HANDLE)
                {
                    return;
                }

                for (int i = 0; i < MAX_CHANNELS; i++)
                {
                    FMOD.Channel channel = null;

                    result = _system.getChannel(i, ref channel);

                    if (result == RESULT.ERR_INVALID_PARAM || result == RESULT.ERR_INVALID_HANDLE)
                    {
                        continue;
                    }

                    result = channel.stop();
                }
            }));
        }
Ejemplo n.º 3
0
        public bool IsPlaying(FMOD.Channel channel) //채널이 play중인지 return하는 함수
        {
            bool returnbool = false;

            channel.isPlaying(out returnbool);
            return(returnbool);
        }
Ejemplo n.º 4
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);
    }
Ejemplo n.º 5
0
 public static Channel FromFmod(FMOD.Channel channel)
 {
     if (channel == null)
     {
         throw new ArgumentNullException(nameof(channel));
     }
     return(new Channel(channel));
 }
Ejemplo n.º 6
0
        public void Play(IMediaFile file)
        {
            this.CleanUpSound(ref this.sound);

            this.timer.Start();

            this.CurrentMediaFile = file;

            var mode = FMOD.MODE._2D | FMOD.MODE.CREATESTREAM | FMOD.MODE.LOOP_OFF | FMOD.MODE.UNICODE;

            if (file.IsVBR)
            {
                mode |= FMOD.MODE.ACCURATETIME;
            }
            if (this.Equalizer != null)
            {
                mode |= MODE.SOFTWARE;
            }
            else
            {
                mode |= MODE.HARDWARE;
            }
            var result = this.system.createSound(file.FullFileName, mode, ref this.sound);

            if (!result.ERRCHECK())
            {
                return;
            }

            uint lenms = 0;

            result = this.sound.getLength(ref lenms, FMOD.TIMEUNIT.MS);
            result.ERRCHECK();
            this.LengthMs = lenms;

            FMOD.Channel channel = null;
            result = this.system.playSound(FMOD.CHANNELINDEX.FREE, this.sound, false, ref channel);
            if (!result.ERRCHECK())
            {
                return;
            }

            this.State = PlayerState.Play;
            file.State = PlayerState.Play;

            if (channel != null)
            {
                this.channelInfo = new ChannelInfo()
                {
                    Channel = channel, File = file
                };
                result = this.channelInfo.Channel.setCallback(this.channelEndCallback);
                result.ERRCHECK();

                result = this.channelInfo.Channel.setVolume(this.Volume / 100f);
                result.ERRCHECK();
            }
        }
Ejemplo n.º 7
0
 public ChannelInfo(Channel channel, IMediaFile file, Action playNextFileAction)
 {
     this.Channel = channel;
     this.Channel.getSystemObject(out system).ERRCHECK();
     this.File = file;
     this.playNextFileAction = playNextFileAction;
     this.channelEndCallback = new FMOD.CHANNEL_CALLBACK(ChannelEndCallback);
     this.Channel.setCallback(this.channelEndCallback).ERRCHECK();
     this.Volume = 0f;
 }
Ejemplo n.º 8
0
 void OnApplicationQuit()
 {
     PlayingMusic.release();
     channel.stop();
     system.close();
     system.release();
     channel      = null;
     PlayingMusic = null;
     system       = null;
 }
Ejemplo n.º 9
0
 public void StopMusic()
 {
     PlayingMusic.release();
     channel.stop();
     system.close();
     system.release();
     channel      = null;
     PlayingMusic = null;
     system       = null;
 }
Ejemplo n.º 10
0
        protected void RegisterChannel(FMOD.Channel channel)
        {
            IntPtr raw = channel.getRaw();

            if (allChannels.ContainsKey(raw))
            {
                allChannels.Remove(raw);
            }
            allChannels.Add(raw, this);
        }
Ejemplo n.º 11
0
        //This function is used to add a delay in the detection to playback ratio.
        //For example, if an obstacle is spawned to the music, it will be spawned immediately
        //upon the song detecting a beat, when oftentimes we want to line up that obstacle
        //with the point in the music it plays. So, the obstacle will spawn before the song gets
        //to the beat detected point.
        //Use milliseconds to express the amount of delay time you want between playback and detection.
        public void loadSongToDelay(int milliseconds)
        {
            delayedSong = true;
            songChannel1.setVolume(0);

            audio2 = new FMOD.Sound();
            FMODErrorCheck(system.createStream(songString, FMOD.MODE.SOFTWARE, ref audio2));

            songChannel2 = new FMOD.Channel();
            FMODErrorCheck(system.playSound(FMOD.CHANNELINDEX.FREE, audio2, true, ref songChannel2));
            songChannel2.setChannelGroup(channelMusic);
            timeToDelay = milliseconds;
        }
Ejemplo n.º 12
0
    void LateUpdate()
    {
        FMOD.Channel channel  = _mutedSourceJustForUserSpeed.Channel;
        TimeSpan     timespan = TimeSpan.FromMilliseconds(0);

        if (channel != null)
        {
            uint position;
            channel.getPosition(out position, FMOD.TIMEUNIT.MS);

            timespan = TimeSpan.FromMilliseconds(position);
        }

        _userProgression.text = String.Format("{0:D2}:{1:D2} / {2:D2}:{3:D2}",
                                              timespan.Minutes, timespan.Seconds,
                                              _totalTimeTimeSpan.Minutes, _totalTimeTimeSpan.Seconds);
    }
Ejemplo n.º 13
0
    // Use this for initialization
    void Start()
    {
        channel = new FMOD.Channel();

        soundInfo                    = new FMOD.CREATESOUNDEXINFO();
        soundInfo.cbsize             = Marshal.SizeOf(soundInfo);
        soundInfo.suggestedsoundtype = FMOD.SOUND_TYPE.MPEG;

        lowLevelSystem = FMODUnity.RuntimeManager.LowlevelSystem;
        FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup);
        lowLevelSystem.setStreamBufferSize(64000, FMOD.TIMEUNIT.RAWBYTES);
        channel.setMode(FMOD.MODE.IGNORETAGS | FMOD.MODE.MPEGSEARCH);
        lowLevelSystem.createStream("http://stream4.nadaje.com:15274/live", //"http://stream.gensokyoradio.net:8000/stream/1/" "http://stream4.nadaje.com:12818/test"
                                    FMOD.MODE.DEFAULT | FMOD.MODE.NONBLOCKING | FMOD.MODE.CREATESTREAM | FMOD.MODE.MPEGSEARCH,
                                    ref soundInfo,
                                    out radioStream);

        StartCoroutine(WaitForStreamBuffer());
    }
Ejemplo n.º 14
0
    private string path = "Assets/3rdPerson+Fly/Sounds/"; // Path of the sound to listen

    void Start()
    {
        path = path + soundName;

        _channel      = new Channel();
        _channelGroup = new FMOD.ChannelGroup();


        _alt_pan_pos = new FMOD.VECTOR();
        _rigidBody   = gameObject.GetComponent <Rigidbody>();

        // Convert game object 3d attributes to FMOD.ATTRIBUTES_3D struct
        _attributes3D = RuntimeUtils.To3DAttributes(gameObject, _rigidBody);

        _soundManager.Create(path, FMOD.MODE.LOOP_NORMAL, out _sound);
        _soundManager.Play(_sound, _channelGroup, false, out _channel, _attributes3D.position, _attributes3D.velocity, _alt_pan_pos);
        _soundManager.ChangeVolume(volume);

        // minDistance: distancia a partir de la cual el sonido comienza a atenuarse
        // maxDistance: distancia a partir de la cual el sonido no se atenúa más (el volumen no es necesariamente 0.0)
        _channel.set3DMinMaxDistance(3.0f, 40.0f);
    }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        channel        = new FMOD.Channel();
        lowLevelSystem = FMODUnity.RuntimeManager.LowlevelSystem;
        FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup);

        lowLevelSystem.createSound("Assets\\Sounds\\guitar.mp3", FMOD.MODE.DEFAULT, out guitarSong);
        string songName = "";

        guitarSong.getName(out songName, 20);
        Debug.Log("Playing song: " + songName, gameObject);
        guitarSong.setMode(FMOD.MODE.OPENUSER | FMOD.MODE._3D | FMOD.MODE._3D_LINEARSQUAREROLLOFF);

        lowLevelSystem.playSound(guitarSong, channelGroup, true, out channel);
        channel.set3DMinMaxDistance(minDistance, maxDistance);
        channel.setLoopCount(-1);
        channel.setMode(FMOD.MODE.LOOP_NORMAL);
        FMOD.ATTRIBUTES_3D attributes  = FMODUnity.RuntimeUtils.To3DAttributes(gameObject);
        FMOD.VECTOR        alt_pan_pos = Vector3.zero.ToFMODVector();
        channel.set3DAttributes(ref attributes.position, ref attributes.velocity, ref alt_pan_pos);

        channel.setPaused(false);
    }
Ejemplo n.º 16
0
        protected override void OnSpawn()
        {
            base.OnSpawn();

            sound = AudioUtil.CreateSound(soundName);
        }
Ejemplo n.º 17
0
        private static void Play(string path, bool isBGM)
        {
            var file = NLVFS.NLVFS.LoadFile(path);
            if (file == null)
            {
                NLog.Warn("fmod Play file not Found " + path);
                return;
            }

            var info = new CREATESOUNDEXINFO();
            info.length = (uint)file.Length;
            Sound s;
            var result = _fmod.createSound(file, MODE.OPENMEMORY, ref info, out s);
            if (result != RESULT.OK)
            {
                NLog.Error("fmod createSound " + result);
            }
            
            Channel channel;
            result = _fmod.playSound(s, null, false, out channel);
            _fmod.update();
            int index;
            channel.getIndex(out index);
            if (result != RESULT.OK)
            {
                NLog.Error("fmod playSound " + result);
            }

            if (isBGM)
            {
                _channelBGM = channel;
            }
        }
Ejemplo n.º 18
0
        public void Stop()
        {
            if (_channel == null || _nowPlaying == null)
                return;

            bool playing = false;
            bool paused = false;
            RESULT result = _channel.isPlaying(ref playing);
            ErrCheck(result);
            result = _channel.getPaused(ref paused);
            ErrCheck(result);
            if (playing || paused)
            {
                _log.DebugFormat("Stopping current song: {0}", _nowPlaying.Name);

                result = _channel.stop();
                ErrCheck(result);
                if (_sound != null)
                {
                    result = _sound.release();
                    ErrCheck(result);
                }
            }

            _channel = null;
            _nowPlaying = null;

            _log.Debug("Song stopped!");
        }
Ejemplo n.º 19
0
        //Loads a song into memory given a sample size and file-path to an audio file.
        //The most commonly used and accurate Sample Size is 1024.
        public void LoadSong(int sSize, string audioString)
        {
            //Take in Aruguments
            sampleSize = sSize;
            songString = audioString;

            stopW.Start();
            areWePlaying       = true;
            specFlux           = 0.0f;
            timeBetween        = 0;
            initialTime        = (int)stopW.ElapsedMilliseconds;
            currentTime        = 0;
            currentSeconds     = 0;
            lastSeconds        = 0;
            currentMillis      = 0;
            currentMinutes     = 0;
            median             = 0.0f;
            smoothMedian       = 0.0f;
            beatThreshold      = 0.6f;
            thresholdSmoother  = 0.6f;
            started            = false;
            lastBeatRegistered = new TimeStamp();
            audio        = new FMOD.Sound();
            songChannel1 = new FMOD.Channel();
            beatWait     = false;
            channelMusic = new FMOD.ChannelGroup();

            previousFFT = new float[sampleSize
                                    / 2 + 1];
            for (int i = 0; i < sampleSize / 2; i++)
            {
                previousFFT[i] = 0;
            }

            //Brute force for testing
            //songString = "Music/drums.wav";

            //Create channel and audio
            FMODErrorCheck(system.createChannelGroup(null, ref channelMusic));
            // CREATESOUNDEXINFO ex = new CREATESOUNDEXINFO();

            FMODErrorCheck(system.createStream(songString, FMOD.MODE.SOFTWARE, ref audio));

            audio.getLength(ref seconds, FMOD.TIMEUNIT.MS);
            audio.getDefaults(ref sampleRate, ref zeroF, ref zeroF, ref zero);
            seconds     = ((seconds + 500) / 1000);
            minutes     = seconds / 60;
            fullSeconds = (int)seconds;
            seconds     = seconds - (minutes * 60);

            FMODErrorCheck(system.playSound(FMOD.CHANNELINDEX.FREE, audio, true, ref songChannel1));

            //hzRange = (sampleRate / 2) / static_cast<float>(sampleSize);
            songChannel1.setChannelGroup(channelMusic);
            songChannel1.setPaused(true);

            Console.WriteLine("Song Length: " + minutes + ":" + seconds);
            Console.WriteLine("Sample Rate: " + sampleRate);

            //std::cout << "Freq Range: " << hzRange << std::endl;
            //songChannel1.setVolume(0);
        }
Ejemplo n.º 20
0
        public RESULT getChannel             (int channelid, out Channel channel)
        {
            channel = null;

            IntPtr channelraw;
            RESULT result = FMOD_System_GetChannel(rawPtr, channelid, out channelraw);
            channel = new Channel(channelraw);

            return result;
        }
Ejemplo n.º 21
0
 public void Play(FMOD.Sound sound, FMOD.ChannelGroup channelGroup, bool paused, out FMOD.Channel channel, FMOD.VECTOR pos, FMOD.VECTOR vel, FMOD.VECTOR alt_pan_pos)
 {
     _soundSystem.playSound(sound, channelGroup, paused, out channel);
     _channel = channel;
     _channel.set3DAttributes(ref pos, ref vel, ref alt_pan_pos);
 }
        //Loads a song into memory given a sample size and file-path to an audio file.
        //The most commonly used and accurate Sample Size is 1024.
        public void LoadSong(int sSize, string audioString)
        {
            //Take in Aruguments
            sampleSize = sSize;
            songString = audioString;

            stopW.Start();
            areWePlaying = true;
            specFlux = 0.0f;
            timeBetween = 0;
            initialTime = (int)stopW.ElapsedMilliseconds;
            currentTime = 0;
            currentSeconds = 0;
            lastSeconds = 0;
            currentMillis = 0;
            currentMinutes = 0;
            median = 0.0f;
            smoothMedian = 0.0f;
            beatThreshold = 0.6f;
            thresholdSmoother = 0.6f;
            started = false;
            lastBeatRegistered = new TimeStamp();
            audio = new FMOD.Sound();
            songChannel1 = new FMOD.Channel();

            channelMusic = new FMOD.ChannelGroup();

            previousFFT = new float[sampleSize
                / 2 + 1];
            for (int i = 0; i < sampleSize / 2; i++)
            {
                previousFFT[i] = 0;
            }

            //Brute force for testing
            //songString = "Music/drums.wav";

            //Create channel and audio
            FMODErrorCheck(system.createChannelGroup(null, ref channelMusic));
               // CREATESOUNDEXINFO ex = new CREATESOUNDEXINFO();

            FMODErrorCheck(system.createStream(songString, FMOD.MODE.SOFTWARE, ref audio));

            audio.getLength(ref seconds, FMOD.TIMEUNIT.MS);
            audio.getDefaults(ref sampleRate, ref zeroF, ref zeroF, ref zero);
            seconds = ((seconds + 500) / 1000);
            minutes = seconds / 60;
            fullSeconds = (int)seconds;
            seconds = seconds - (minutes * 60);

            FMODErrorCheck(system.playSound(FMOD.CHANNELINDEX.FREE, audio, true, ref songChannel1));

            //hzRange = (sampleRate / 2) / static_cast<float>(sampleSize);
            songChannel1.setChannelGroup(channelMusic);
            songChannel1.setPaused(true);

            Console.WriteLine("Song Length: " + minutes + ":" + seconds);
            Console.WriteLine("Sample Rate: " + sampleRate);

            //std::cout << "Freq Range: " << hzRange << std::endl;
            //songChannel1.setVolume(0);
        }
Ejemplo n.º 23
0
        public RESULT playSound              (Sound sound, ChannelGroup channelGroup, bool paused, ref Channel channel)
        {
            RESULT result      = RESULT.OK;
            IntPtr      channelraw;
            Channel     channelnew  = null;

            if (channel != null)
            {
                channelraw = channel.getRaw();
            }
            else
            {
                channelraw  = new IntPtr();
            }

            IntPtr channelGroupRaw = (channelGroup != null) ? channelGroup.getRaw() : (IntPtr)0;


            try
            {
                result = FMOD_System_PlaySound(systemraw, sound.getRaw(), channelGroupRaw, (paused ? 1 : 0), ref channelraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (channel == null)
            {
                channelnew = new Channel();
                channelnew.setRaw(channelraw);
                channel = channelnew;
            }
            else
            {
                channel.setRaw(channelraw);
            }
                             
            return result;                                                                    
        }
Ejemplo n.º 24
0
        public RESULT getChannel(int channelid, ref Channel channel)
        {
            RESULT result      = RESULT.OK;
            IntPtr      channelraw  = new IntPtr();
            Channel     channelnew  = null;

            try
            {
                result = FMOD_System_GetChannel(systemraw, channelid, ref channelraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (channel == null)
            {
                channelnew = new Channel();
                channelnew.setRaw(channelraw);
                channel = channelnew;
            }
            else
            {
                channel.setRaw(channelraw);
            }

            return result;
        }
Ejemplo n.º 25
0
        public DeckControl()
        {
            _mixerBackground = new Image();
            _mixerBackground.Height = 488;
            _mixerBackground.Width = 710;
            BitmapImage bmp = new BitmapImage();
            bmp.BeginInit();
            bmp.UriSource = new Uri("png/deck_background.png", UriKind.Relative);
            bmp.EndInit();
            _mixerBackground.Source = bmp;
            this.Children.Add(_mixerBackground);

            _recordController = new RecordController(RECORD_DIAMETER, RECORD_DIAMETER);
            _recordController.Margin = new Thickness(RECORD_MARGIN_LEFT, RECORD_MARGIN_TOP, 0, 0);
            _recordController.SetBackgroundImage(@"png/record.png");
            _recordController.Width = RECORD_DIAMETER;
            _recordController.Height = RECORD_DIAMETER;
            _recordController.TouchDown += new EventHandler<TouchEventArgs>(RecordTouchDown);
            _recordController.TouchUp += new EventHandler<TouchEventArgs>(RecordTouchUp);
            _recordController.TouchMove += new EventHandler<TouchEventArgs>(RecordTouchMove);
            _recordController.DragEnter += new System.Windows.DragEventHandler(RecordDragEnter);
            _recordController.DragLeave += new System.Windows.DragEventHandler(RecordDragLeave);
            _recordController.Drop += new System.Windows.DragEventHandler(RecordDrop);
            _recordController.AllowDrop = true;
            this.Children.Add(_recordController);

            _highPassKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _highPassKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP, 0, 0);
            _highPassKnob.SetBackgroundImage(@"png/dial_background.png");
            _highPassKnob.SetCenterImage(@"png/dial_knob.png");
            _highPassKnob.Width = KNOB_DIAMETER;
            _highPassKnob.Height = KNOB_DIAMETER;
            //_highPassKnob.TouchDown += new EventHandler<TouchEventArgs>(HPKnobTouchDown);
            //_highPassKnob.TouchUp += new EventHandler<TouchEventArgs>(HPKnobTouchUp);
            _highPassKnob.TouchMove += new EventHandler<TouchEventArgs>(HPKnobTouchMove);
            this.Children.Add(_highPassKnob);

            _lowPassKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _lowPassKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP + KNOB_DIAMETER * 1 + KNOB_PADDING * 1, 0, 0);
            _lowPassKnob.SetBackgroundImage(@"png/dial_background.png");
            _lowPassKnob.SetCenterImage(@"png/dial_knob.png");
            _lowPassKnob.Width = KNOB_DIAMETER;
            _lowPassKnob.Height = KNOB_DIAMETER;
            _lowPassKnob.TouchMove += new EventHandler<TouchEventArgs>(LPKnobTouchMove);
            this.Children.Add(_lowPassKnob);

            _reverbKnob = new KnobControl(KNOB_DIAMETER, KNOB_DIAMETER);
            _reverbKnob.Margin = new Thickness(KNOB_MARGIN_LEFT, KNOB_MARGIN_TOP + KNOB_DIAMETER * 2 + KNOB_PADDING * 2, 0, 0);
            _reverbKnob.SetBackgroundImage(@"png/dial_background.png");
            _reverbKnob.SetCenterImage(@"png/dial_knob.png");
            _reverbKnob.Width = KNOB_DIAMETER;
            _reverbKnob.Height = KNOB_DIAMETER;
            this.Children.Add(_reverbKnob);
            

            angle = 1;
            _recordMidPoint = new System.Windows.Point(_recordController.Width / 2 + _recordController.Margin.Left, _recordController.Height / 2 + _recordController.Margin.Top);
            rotate = new RotateTransform(1, _recordController.Width / 2, _recordController.Height / 2);
            transform = new TransformGroup();
            transform.Children.Add(rotate);

            dispatcherTimer = new DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1);
            dispatcherTimer.Start();

            system = new FMOD.System();
            FMOD.RESULT result = Factory.System_Create(ref system);
            system.init(8, INITFLAGS.NORMAL, (IntPtr)null);
            channel = new Channel(system);
            channel.Initialize(0);
            channel.SetHighPass(1.0f);
            _isPlaying = false;
        }
 public RESULT OnEndMusic(IntPtr channelraw, FMOD.CHANNEL_CALLBACKTYPE type, IntPtr commanddata1, IntPtr commanddata2)
 {
     if (EndMusic != null)
         EndMusic(currentMusicPath, new EventArgs());
     musicChannel = null;
     return RESULT.OK;
 }
 public void Stop()
 {
     if (musicChannel != null)
     {
         RESULT result = musicChannel.stop();
         musicChannel = null;
         ErrCheck(result);
     }
 }
Ejemplo n.º 28
0
        public WavEffect(FMOD.System system, string path, bool loop, float baseVol)
        {
            this.system = system;
            callback = new CHANNEL_CALLBACK(SyncCallback);

            baseVolume = baseVol;
            volume = 1;

            system.createSound(path, MODE.SOFTWARE | (loop ? MODE.LOOP_NORMAL : MODE.LOOP_OFF), ref sound);
            channel = new Channel();
            playCount = 0;
        }
Ejemplo n.º 29
0
 public void Dispose()
 {
     if(m_fadeTimer.Enabled) {
         m_fadeTimer.Enabled = false;
     }
     bool playing = false;
     if(m_channel != null) {
         m_channel.isPlaying(ref playing);
         if(playing) {
             m_channel.stop();
         }
         m_channel = null;
     }
     if(m_sound != null) {
         m_sound.release();
         m_sound = null;
     }
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 30
0
        public RESULT playDSP                (DSP dsp, bool paused, out Channel channel)
        {
            channel = null;

            IntPtr channelraw;
            RESULT result = FMOD5_System_PlayDSP(rawPtr, dsp.getRaw(), paused, out channelraw);
            channel = new Channel(channelraw);

            return result;
        }
Ejemplo n.º 31
0
        public RESULT getChannel(int index, ref Channel channel)
        {
            var result = RESULT.OK;
            var channelraw = new IntPtr();
            Channel channelnew = null;

            try
            {
                result = FMOD_ChannelGroup_GetChannel(channelgroupraw, index, ref channelraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (channel == null)
            {
                channelnew = new Channel();
                channelnew.setRaw(channelraw);
                channel = channelnew;
            }
            else
            {
                channel.setRaw(channelraw);
            }

            return result;
        }
Ejemplo n.º 32
0
 public RESULT getChannel(int channelid, out Channel channel)
 {
     channel = null;
     IntPtr raw;
     RESULT result = System.FMOD5_System_GetChannel(this.rawPtr, channelid, out raw);
     channel = new Channel(raw);
     return result;
 }
        //This function is used to add a delay in the detection to playback ratio.
        //For example, if an obstacle is spawned to the music, it will be spawned immediately
        //upon the song detecting a beat, when oftentimes we want to line up that obstacle
        //with the point in the music it plays. So, the obstacle will spawn before the song gets
        //to the beat detected point.
        //Use milliseconds to express the amount of delay time you want between playback and detection.
        public void loadSongToDelay(int milliseconds)
        {
            delayedSong = true;
            songChannel1.setVolume(0);

            audio2 = new FMOD.Sound();
            FMODErrorCheck(system.createStream(songString, FMOD.MODE.SOFTWARE, ref audio2));

            songChannel2 = new FMOD.Channel();
            FMODErrorCheck(system.playSound(FMOD.CHANNELINDEX.FREE, audio2, true, ref songChannel2));
            songChannel2.setChannelGroup(channelMusic);
            timeToDelay = milliseconds;
        }
Ejemplo n.º 34
0
 public RESULT playSound(Sound sound, ChannelGroup channelGroup, bool paused, out Channel channel)
 {
     channel = null;
     IntPtr channelGroup2 = (!(channelGroup != null)) ? IntPtr.Zero : channelGroup.getRaw();
     IntPtr raw;
     RESULT result = System.FMOD5_System_PlaySound(this.rawPtr, sound.getRaw(), channelGroup2, paused, out raw);
     channel = new Channel(raw);
     return result;
 }
Ejemplo n.º 35
0
        public RESULT playDSP                (DSP dsp, ChannelGroup channelGroup, bool paused, out Channel channel)
        {
            channel = null;

            IntPtr channelGroupRaw = (channelGroup != null) ? channelGroup.getRaw() : IntPtr.Zero;

            IntPtr channelraw;
            RESULT result = FMOD_System_PlayDSP(rawPtr, dsp.getRaw(), channelGroupRaw, paused, out channelraw);
            channel = new Channel(channelraw);

            return result;
        }
Ejemplo n.º 36
0
 internal void UnloadSongs()
 {
     _log.Info("Unloading SongManager...");
     Stop();
     _log.Debug("Setting song channel to NULL...");
     _channel = null;
     _nowPlaying = null;
     _log.Debug("Clearing song list...");
     _songs.Clear();
 }
Ejemplo n.º 37
0
        public RESULT getChannel             (int index, out Channel channel)
        {
            channel = null;

            IntPtr channelraw;
            RESULT result = FMOD_ChannelGroup_GetChannel(getRaw(), index, out channelraw);
            channel = new Channel(channelraw);

            return result;
        }
Ejemplo n.º 38
0
 private Channel(FMOD.Channel channel)
     : this()
 {
     FmodChannel = channel;
 }
Ejemplo n.º 39
0
        public RESULT playSound(CHANNELINDEX channelid, Sound sound, bool paused, ref Channel channel)
        {
            RESULT result      = RESULT.OK;
            IntPtr      channelraw;
            Channel     channelnew  = null;

            if (channel != null)
            {
                channelraw = channel.getRaw();
            }
            else
            {
                channelraw  = new IntPtr();
            }

            try
            {
                result = FMOD_System_PlaySound(systemraw, channelid, sound.getRaw(), (paused ? 1 : 0), ref channelraw);
            }
            catch
            {
                result = RESULT.ERR_INVALID_PARAM;
            }
            if (result != RESULT.OK)
            {
                return result;
            }

            if (channel == null)
            {
                channelnew = new Channel();
                channelnew.setRaw(channelraw);
                channel = channelnew;
            }
            else
            {
                channel.setRaw(channelraw);
            }

            return result;
        }
Ejemplo n.º 40
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();
    }