예제 #1
0
        public StreamedBufferSoundSource(SoundInstanceStreamedBuffer instance, MediaSynchronizer synchronizer, string mediaDataUrl, long startPosition, long length)
            : base(instance, NumberOfBuffers, MaxBufferSizeBytes)
        {
            mediaSynchronizer  = synchronizer;
            this.mediaDataUrl  = mediaDataUrl;
            this.startPosition = startPosition;
            this.length        = length;

            NewSources.Add(this);
        }
예제 #2
0
        //==========================================================================================

        /// <summary>
        /// This type of DynamicSoundSource is streamed from Disk and reads compressed Celt encoded data, used internally.
        /// </summary>
        /// <param name="instance">The associated SoundInstance</param>
        /// <param name="fileProvider">The file provider to read the stream from</param>
        /// <param name="soundStreamUrl">The compressed stream internal URL</param>
        /// <param name="numberOfPackets"></param>
        /// <param name="sampleRate">The sample rate of the compressed data</param>
        /// <param name="channels">The number of channels of the compressed data</param>
        /// <param name="maxCompressedSize">The maximum size of a compressed packet</param>
        public CompressedSoundSource(SoundInstance instance, IVirtualFileProvider fileProvider, string soundStreamUrl, int numberOfPackets, int sampleRate, int channels, int maxCompressedSize) :
            base(instance, NumberOfBuffers, SamplesPerBuffer * MaxChannels * sizeof(short))
        {
            looped                 = instance.IsLooping;
            this.channels          = channels;
            this.maxCompressedSize = maxCompressedSize;
            this.fileProvider      = fileProvider;
            this.soundStreamUrl    = soundStreamUrl;
            this.sampleRate        = sampleRate;
            this.numberOfPackets   = numberOfPackets;
            playRange              = new PlayRange(TimeSpan.Zero, TimeSpan.Zero);

            NewSources.Add(this);
        }
예제 #3
0
        public CompressedSoundSource(SoundInstance instance, byte[] byteBuffer, int numberOfPackets, int numberOfSamples, int sampleRate, int channels, int maxCompressedSize)
            : base(instance, NumberOfBuffers, SamplesPerBuffer * MaxChannels * sizeof(short))
        {
            looped                 = instance.IsLooping;
            this.channels          = channels;
            this.maxCompressedSize = maxCompressedSize;
            this.soundStreamUrl    = null;
            this.byteBuffer        = byteBuffer;
            this.sampleRate        = sampleRate;
            this.numberOfPackets   = numberOfPackets;
            this.samples           = numberOfSamples;
            playRange              = new PlayRange(TimeSpan.Zero, TimeSpan.Zero);

            NewSources.Enqueue(this);
        }
예제 #4
0
파일: wn-wikt.cs 프로젝트: reactxx/rewise
    public static NewSources createNewSource()
    {
        var news  = new NewSources();
        var ctx   = new Context(false);
        var maxId = ctx.ids.Where(kv => !kv.Key.StartsWith("wn-wikt-")).Select(kv => int.Parse(kv.Value.Split('=')[2])).Max();

        Tuple <int, string> addId(string lang)
        {
            maxId++;
            var val = $"wn-wikt-{maxId}={lang}=entry={maxId}";

            news.ids.Add(val);
            return(new Tuple <int, string>(maxId, val));
        }

        using (var dbCtx = wordNetDB.Context.getContext()) {
            var synsets = dbCtx.Synsets.Where(s => s.LangId == "eng")
                          .Select(s => new { s.Id, partOfSpeech = s.Senses.FirstOrDefault().Entry.PartOfSpeech, /*entryIds = s.Senses.Select(ss => ss.EntryId)*/ })
                          .ToArray()
                          .ToDictionary(s => ctx.getOrigId(s.Id));
            var entries = dbCtx.Entries.Where(e => e.OriginNoWikt)
                          .Select(e => new Entry {
                Id = e.Id, LangId = e.LangId, PartOfSpeech = e.PartOfSpeech, Lemma = e.Lemma, OriginNoWikt = e.OriginNoWikt
            })
                          .ToHashSet(new Entry());
            var translations = dbCtx.Translations.Where(e => e.OriginNoWikt)
                               .Select(e => new Translation {
                LangId = e.LangId, TransEntryId = e.TransEntryId, EngSynsetId = e.EngSynsetId, OriginNoWikt = e.OriginNoWikt
            })
                               .ToHashSet(new Translation());
            var langs = dbCtx.Langs.Where(e => e.OriginNoWikt)
                        .Select(e => new Lang {
                Id = e.Id, OriginNoWikt = e.OriginNoWikt
            })
                        .ToDictionary(e => e.Id);
            foreach (var tab in parseTabFiles())
            {
                if (tab.lemma == "přístup")
                {
                    if (tab == null)
                    {
                        continue;
                    }
                }
                // ****** preparing and checking
                var id = $"eng-10-{tab.synsetId}";
                if (!synsets.TryGetValue(id, out var synset))
                {
                    // some lemmas from CLDR, e.g. "dop." or "dop." for czech;
                    // Console.WriteLine(id);
                    continue;
                }
                if (!tab.synsetId.EndsWith(synset.partOfSpeech))
                {
                    Console.WriteLine($"{tab.synsetId} does not ends with {synset.partOfSpeech}");
                    continue;
                }
                if (!langs.ContainsKey(tab.lang))
                {
                    news.langs.Add(langs[tab.lang] = new Lang {
                        Id = tab.lang, OriginNoWikt = false
                    });
                }
                // ************* adding Entry, Translation and id
                var newEntry = new Entry {
                    LangId = tab.lang, PartOfSpeech = synset.partOfSpeech, Lemma = tab.lemma, OriginNoWikt = false
                };
                var newTranslation = new Translation {
                    LangId = tab.lang, EngSynsetId = synset.Id
                };
                if (!entries.TryGetValue(newEntry, out var origEntry))
                {
                    var newId = addId(tab.lang);
                    newEntry.Id = newId.Item1;
                    news.entries.Add(newEntry);
                    Debug.Assert(entries.Add(newEntry));
                    newTranslation.TransEntryId = newId.Item1;
                    news.translations.Add(newTranslation);
                    Debug.Assert(translations.Add(newTranslation));
                }
                else
                {
                    newTranslation.TransEntryId = origEntry.Id;
                    if (translations.Contains(newTranslation))
                    {
                        continue;
                    }
                    news.translations.Add(newTranslation);
                    Debug.Assert(translations.Add(newTranslation));
                }
            }
        }
        return(news);
    }