예제 #1
0
        public static void EndRegistration( )
        {
            Int32 i;
            sfx_t sfx;
            Int32 size;

            for (i = 0; i < num_sfx; i++)
            {
                sfx = known_sfx[i];
                if (sfx.name == null)
                {
                    continue;
                }
                if (sfx.registration_sequence != s_registration_sequence)
                {
                    sfx.Clear();
                }
                else
                {
                }
            }

            for (i = 0; i < num_sfx; i++)
            {
                sfx = known_sfx[i];
                if (sfx.name == null)
                {
                    continue;
                }
                WaveLoader.LoadSound(sfx);
            }

            s_registering = false;
        }
예제 #2
0
        public static sfx_t RegisterSound(String name)
        {
            sfx_t sfx = null;

            if (!sound_started)
            {
                return(null);
            }
            sfx = FindName(name, true);
            sfx.registration_sequence = s_registration_sequence;
            if (!s_registering)
            {
                WaveLoader.LoadSound(sfx);
            }
            return(sfx);
        }
예제 #3
0
        public sfxcache_t LoadSound(sfx_t s)
        {
            if (s.isCached)
            {
                return(s.cache);
            }
            sfxcache_t sc = WaveLoader.LoadSound(s);

            if (sc != null)
            {
                InitBuffer(sc.data, s.bufferId, sc.speed);
                s.isCached   = true;
                s.cache.data = null;
            }

            return(sc);
        }
예제 #4
0
        public static void IssuePlaysound(playsound_t ps)
        {
            channel_t  ch;
            sfxcache_t sc;

            if (s_show.value != 0F)
            {
                Com.Printf("Issue " + ps.begin + "\\n");
            }
            ch = PickChannel(ps.entnum, ps.entchannel);
            if (ch == null)
            {
                FreePlaysound(ps);
                return;
            }

            if (ps.attenuation == ATTN_STATIC)
            {
                ch.dist_mult = ps.attenuation * 0.001F;
            }
            else
            {
                ch.dist_mult = ps.attenuation * 0.0005F;
            }
            ch.master_vol = ( Int32 )ps.volume;
            ch.entnum     = ps.entnum;
            ch.entchannel = ps.entchannel;
            ch.sfx        = ps.sfx;
            Math3D.VectorCopy(ps.origin, ch.origin);
            ch.fixed_origin = ps.fixed_origin;
            Spatialize(ch);
            ch.pos = 0;
            sc     = WaveLoader.LoadSound(ch.sfx);
            ch.end = paintedtime + sc.length;
            FreePlaysound(ps);
        }
예제 #5
0
        public static void PaintChannels(Int32 endtime)
        {
            Int32       i;
            Int32       end;
            channel_t   ch;
            sfxcache_t  sc;
            Int32       ltime, count;
            playsound_t ps;

            snd_vol = ( Int32 )(s_volume.value * 256);
            while (paintedtime < endtime)
            {
                end = endtime;
                if (endtime - paintedtime > PAInt32Buffer_SIZE)
                {
                    end = paintedtime + PAInt32Buffer_SIZE;
                }
                while (true)
                {
                    ps = s_pendingplays.next;
                    if (ps == s_pendingplays)
                    {
                        break;
                    }
                    if (ps.begin <= paintedtime)
                    {
                        SND_DMA.IssuePlaysound(ps);
                        continue;
                    }

                    if (ps.begin < end)
                    {
                        end = ( Int32 )ps.begin;
                    }
                    break;
                }

                if (s_rawend < paintedtime)
                {
                    for (i = 0; i < (end - paintedtime) * 2; i++)
                    {
                        paInt32Buffer.Put(i, 0);
                    }
                }
                else
                {
                    Int32 s;
                    Int32 stop;
                    stop = (end < s_rawend) ? end : s_rawend;
                    for (i = paintedtime; i < stop; i++)
                    {
                        s = i & (MAX_RAW_SAMPLES - 1);
                        paInt32Buffer.Put((i - paintedtime) * 2, s_rawsamples.Get(2 * s));
                        paInt32Buffer.Put((i - paintedtime) * 2 + 1, s_rawsamples.Get(2 * s) + 1);
                    }

                    for ( ; i < end; i++)
                    {
                        paInt32Buffer.Put((i - paintedtime) * 2, 0);
                        paInt32Buffer.Put((i - paintedtime) * 2 + 1, 0);
                    }
                }

                for (i = 0; i < MAX_CHANNELS; i++)
                {
                    ch    = channels[i];
                    ltime = paintedtime;
                    while (ltime < end)
                    {
                        if (ch.sfx == null || (ch.leftvol == 0 && ch.rightvol == 0))
                        {
                            break;
                        }
                        count = end - ltime;
                        if (ch.end - ltime < count)
                        {
                            count = ch.end - ltime;
                        }
                        sc = WaveLoader.LoadSound(ch.sfx);
                        if (sc == null)
                        {
                            break;
                        }
                        if (count > 0 && ch.sfx != null)
                        {
                            if (sc.width == 1)
                            {
                                PaintChannelFrom8(ch, sc, count, ltime - paintedtime);
                            }
                            else
                            {
                                PaintChannelFrom16(ch, sc, count, ltime - paintedtime);
                            }
                            ltime += count;
                        }

                        if (ltime >= ch.end)
                        {
                            if (ch.autosound)
                            {
                                ch.pos = 0;
                                ch.end = ltime + sc.length;
                            }
                            else if (sc.loopstart >= 0)
                            {
                                ch.pos = sc.loopstart;
                                ch.end = ltime + sc.length - ch.pos;
                            }
                            else
                            {
                                ch.sfx = null;
                            }
                        }
                    }
                }

                TransferPaInt32Buffer(end);
                paintedtime = end;
            }
        }
예제 #6
0
        public static void StartSound(Single[] origin, Int32 entnum, Int32 entchannel, sfx_t sfx, Single fvol, Single attenuation, Single timeofs)
        {
            if (!sound_started)
            {
                return;
            }
            if (sfx == null)
            {
                return;
            }
            if (sfx.name[0] == '*')
            {
                sfx = RegisterSexedSound(cl_entities[entnum].current, sfx.name);
            }
            sfxcache_t sc = WaveLoader.LoadSound(sfx);

            if (sc == null)
            {
                return;
            }
            var         vol = ( Int32 )(fvol * 255);
            playsound_t ps  = AllocPlaysound();

            if (ps == null)
            {
                return;
            }
            if (origin != null)
            {
                Math3D.VectorCopy(origin, ps.origin);
                ps.fixed_origin = true;
            }
            else
            {
                ps.fixed_origin = false;
            }
            ps.entnum      = entnum;
            ps.entchannel  = entchannel;
            ps.attenuation = attenuation;
            ps.volume      = vol;
            ps.sfx         = sfx;
            var start = ( Int32 )(cl.frame.servertime * 0.001F * dma.speed + s_beginofs);

            if (start < paintedtime)
            {
                start      = paintedtime;
                s_beginofs = ( Int32 )(start - (cl.frame.servertime * 0.001F * dma.speed));
            }
            else if (start > paintedtime + 0.3F * dma.speed)
            {
                start      = ( Int32 )(paintedtime + 0.1F * dma.speed);
                s_beginofs = ( Int32 )(start - (cl.frame.servertime * 0.001F * dma.speed));
            }
            else
            {
                s_beginofs -= 10;
            }

            if (timeofs == 0F)
            {
                ps.begin = paintedtime;
            }
            else
            {
                ps.begin = ( Int64 )(start + timeofs * dma.speed);
            }
            playsound_t sort = new playsound_t();

            ps.next      = sort;
            ps.prev      = sort.prev;
            ps.next.prev = ps;
            ps.prev.next = ps;
        }