예제 #1
0
    public ASAPWavStream(string inputFilename, int song, int duration)
    {
        Stream s = File.OpenRead(inputFilename);

        byte[] module     = new byte[ASAP.ModuleMax];
        int    module_len = s.Read(module, 0, module.Length);

        s.Close();
        asap.Load(inputFilename, module, module_len);
        ASAP_ModuleInfo module_info = asap.GetModuleInfo();

        if (song < 0)
        {
            song = module_info.default_song;
        }
        if (duration < 0)
        {
            duration = module_info.durations[song];
            if (duration < 0)
            {
                duration = 180 * 1000;
            }
        }
        asap.PlaySong(song, duration);
        asap.GetWavHeader(buffer, ASAP_SampleFormat.S16LE);
        buffer_len = ASAP.WavHeaderBytes;
    }
예제 #2
0
    static void ProcessFile(string inputFilename)
    {
        Stream s = File.OpenRead(inputFilename);

        byte[] module     = new byte[ASAP.ModuleMax];
        int    module_len = s.Read(module, 0, module.Length);

        s.Close();
        ASAP asap = new ASAP();

        asap.Load(inputFilename, module, module_len);
        ASAP_ModuleInfo module_info = asap.GetModuleInfo();

        if (song < 0)
        {
            song = module_info.default_song;
        }
        if (duration < 0)
        {
            duration = module_info.durations[song];
            if (duration < 0)
            {
                duration = 180 * 1000;
            }
        }
        asap.PlaySong(song, duration);
        asap.MutePokeyChannels(muteMask);
        if (outputFilename == null)
        {
            int i = inputFilename.LastIndexOf('.');
            outputFilename = inputFilename.Substring(0, i + 1) + (outputHeader ? "wav" : "raw");
        }
        s = File.Create(outputFilename);
        byte[] buffer = new byte[8192];
        if (outputHeader)
        {
            asap.GetWavHeader(buffer, format);
            s.Write(buffer, 0, ASAP.WavHeaderBytes);
        }
        int n_bytes;

        do
        {
            n_bytes = asap.Generate(buffer, format);
            s.Write(buffer, 0, n_bytes);
        } while (n_bytes == buffer.Length);
        s.Close();
        outputFilename = null;
        song           = -1;
        duration       = -1;
    }
예제 #3
0
    void WebClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
    {
        this.webClient = null;
        if (e.Cancelled || e.Error != null)
        {
            return;
        }
        byte[] module     = new byte[e.Result.Length];
        int    module_len = e.Result.Read(module, 0, module.Length);

        ASAP asap = new ASAP();

        asap.Load(this.filename, module, module_len);
        ASAP_ModuleInfo module_info = asap.GetModuleInfo();

        if (this.song < 0)
        {
            this.song = module_info.default_song;
        }
        int duration = module_info.durations[this.song];

        if (duration < 0)
        {
            duration = this.defaultPlaybackTime;
        }
        else if (module_info.loops[this.song] && this.loopPlaybackTime != Once)
        {
            duration = this.loopPlaybackTime;
        }
        asap.PlaySong(this.song, duration);

        Stop();
        this.mediaElement          = new MediaElement();
        this.mediaElement.Volume   = 1;
        this.mediaElement.AutoPlay = true;
        this.mediaElement.SetSource(new ASAPMediaStreamSource(asap, duration));
    }