Exemplo n.º 1
0
    public virtual gxtkSample LoadSample(String path)
    {
        gxtkSample samp = new gxtkSample();

        if (!LoadSample__UNSAFE__(samp, path))
        {
            return(null);
        }
        return(samp);
    }
Exemplo n.º 2
0
    public virtual bool LoadSample__UNSAFE__(gxtkSample sample, String path)
    {
        SoundEffect sound = BBXnaGame.XnaGame().LoadSoundEffect(path);

        if (sound == null)
        {
            return(false);
        }
        sample.SetSound(sound);
        return(true);
    }
Exemplo n.º 3
0
    public virtual int PlaySample(gxtkSample sample, int channel, int flags)
    {
        gxtkChannel chan = channels[channel];

        if (chan.state != 0)
        {
            chan.inst.Stop();
        }

        SoundEffectInstance inst = sample.AllocInstance((flags & 1) != 0);

        if (inst == null)
        {
            chan.state = 0;
            return(-1);
        }

        for (int i = 0; i < 33; ++i)
        {
            gxtkChannel chan2 = channels[i];
            if (chan2.inst == inst)
            {
                chan2.sample = null;
                chan2.inst   = null;
                chan2.state  = 0;
                break;
            }
        }

        inst.Volume = chan.volume;
        inst.Pan    = chan.pan;
        inst.Pitch  = (float)(Math.Log(chan.rate) / Math.Log(2));
        inst.Play();

        chan.sample = sample;
        chan.inst   = inst;
        chan.state  = 1;

        return(0);
    }
Exemplo n.º 4
0
    public virtual int PlaySample(gxtkSample sample, int channel, int flags)
    {
        gxtkChannel chan = _channels[channel];

        for (int i = 0; i < 32; ++i)
        {
            gxtkChannel chan2 = _channels[i];
            if (chan2.sound == sample._sound && chan2.player.Status == SoundStatus.Stopped)
            {
                chan2.player.Dispose();
                chan2.player = null;
                chan2.sound  = null;
            }
        }

        SoundPlayer player = sample._sound.CreatePlayer();

        if (player == null)
        {
            return(-1);
        }

        if (chan.player != null)
        {
            chan.player.Stop();
            chan.player.Dispose();
        }

        player.Volume       = chan.volume;
        player.Pan          = chan.pan;
        player.PlaybackRate = chan.rate;
        player.Loop         = (flags & 1) != 0 ? true : false;
        player.Play();

        chan.player = player;
        chan.sound  = sample._sound;

        return(0);
    }
Exemplo n.º 5
0
    public virtual int PlaySample( gxtkSample sample,int channel,int flags )
    {
        gxtkChannel chan=channels[channel];

        if( chan.state!=0 ) chan.inst.Stop();

        SoundEffectInstance inst=sample.AllocInstance( (flags&1)!=0 );
        if( inst==null ){
            chan.state=0;
            return -1;
        }

        for( int i=0;i<33;++i ){
            gxtkChannel chan2=channels[i];
            if( chan2.inst==inst ){
                chan2.sample=null;
                chan2.inst=null;
                chan2.state=0;
                break;
            }
        }

        inst.Volume=chan.volume;
        inst.Pan=chan.pan;
        inst.Pitch=(float)( Math.Log(chan.rate)/Math.Log(2) );
        inst.Play();

        chan.sample=sample;
        chan.inst=inst;
        chan.state=1;

        return 0;
    }
Exemplo n.º 6
0
 public virtual bool LoadSample__UNSAFE__( gxtkSample sample,String path )
 {
     SoundEffect sound=BBXnaGame.XnaGame().LoadSoundEffect( path );
     if( sound==null ) return false;
     sample.SetSound( sound );
     return true;
 }
Exemplo n.º 7
0
 public virtual gxtkSample LoadSample( String path )
 {
     gxtkSample samp=new gxtkSample();
     if( !LoadSample__UNSAFE__( samp,path ) ) return null;
     return samp;
 }