コード例 #1
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    moduleLen = e.Result.Read(module, 0, module.Length);

        ASAP asap = new ASAP();

        asap.Load(this.Filename, module, moduleLen);
        this.Info = asap.GetInfo();
        if (this.Song < 0)
        {
            this.Song = this.Info.GetDefaultSong();
        }
        int duration = this.Info.GetLoop(this.Song) ? -1 : this.Info.GetDuration(this.Song);

        asap.PlaySong(this.Song, duration);

        Stop();
        CallJS("onLoad");
        this.MediaElement.SetSource(new ASAPMediaStreamSource(asap, duration));
    }
コード例 #2
0
    public ASAPWavStream(string inputFilename, int song, int duration)
    {
        byte[] module = new byte[ASAPInfo.MaxModuleLength];
        int    moduleLen;

        using (Stream s = File.OpenRead(inputFilename)) {
            moduleLen = s.Read(module, 0, module.Length);
        }
        Asap.Load(inputFilename, module, moduleLen);
        ASAPInfo info = Asap.GetInfo();

        if (song < 0)
        {
            song = info.GetDefaultSong();
        }
        if (duration < 0)
        {
            duration = info.GetDuration(song);
            if (duration < 0)
            {
                duration = 180 * 1000;
            }
        }
        Asap.PlaySong(song, duration);
        BufferLen = Asap.GetWavHeader(Buffer, ASAPSampleFormat.S16LE, false);
    }
コード例 #3
0
    static void ProcessFile(string inputFilename)
    {
        byte[] module = new byte[ASAPInfo.MaxModuleLength];
        int    moduleLen;

        using (Stream s = File.OpenRead(inputFilename)) {
            moduleLen = s.Read(module, 0, module.Length);
        }
        ASAP asap = new ASAP();

        asap.Load(inputFilename, module, moduleLen);
        ASAPInfo info = asap.GetInfo();

        if (Song < 0)
        {
            Song = info.GetDefaultSong();
        }
        if (Duration < 0)
        {
            Duration = info.GetDuration(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");
        }
        using (Stream s = File.Create(OutputFilename)) {
            byte[] buffer = new byte[8192];
            int    nBytes;
            if (OutputHeader)
            {
                nBytes = asap.GetWavHeader(buffer, Format, false);
                s.Write(buffer, 0, nBytes);
            }
            do
            {
                nBytes = asap.Generate(buffer, buffer.Length, Format);
                s.Write(buffer, 0, nBytes);
            } while (nBytes == buffer.Length);
        }
        OutputFilename = null;
        Song           = -1;
        Duration       = -1;
    }
コード例 #4
0
    public static int Main(string[] args)
    {
        if (args.Length == 0)
        {
            Console.WriteLine("Usage: ultrasap path/to/ASMA");
            return(1);
        }
        string asma = args[0];
        ASAP   asap = new ASAP();

        byte[] buffer = new byte[885];
        foreach (string file in Files)
        {
            byte[] module = File.ReadAllBytes(Path.Combine(asma, file));
            asap.Load(file, module, module.Length);
            ASAPInfo info = asap.GetInfo();
            for (int song = 0; song < info.GetSongs(); song++)
            {
                int duration = info.GetDuration(song);
                asap.PlaySong(song, duration);
                int[] n = new int[12];
                while (asap.Generate(buffer, buffer.Length, ASAPSampleFormat.U8) == buffer.Length)
                {
                    Check(asap, n, asap.Pokeys.BasePokey.PeriodCycles1, asap.Pokeys.BasePokey.Audc1);
                    Check(asap, n, asap.Pokeys.BasePokey.PeriodCycles2, asap.Pokeys.BasePokey.Audc2);
                    Check(asap, n, asap.Pokeys.BasePokey.PeriodCycles3, asap.Pokeys.BasePokey.Audc3);
                    Check(asap, n, asap.Pokeys.BasePokey.PeriodCycles4, asap.Pokeys.BasePokey.Audc4);
                }
                foreach (int i in n)
                {
                    if (i > 0)
                    {
                        Console.Write(info.GetSongs() == 1 ? file : file + "#" + (song + 1));
                        foreach (int j in n)
                        {
                            Console.Write("\t{0}", j);
                        }
                        Console.WriteLine();
                        break;
                    }
                }
            }
        }
        return(0);
    }
コード例 #5
0
ファイル: MetroASAP.cs プロジェクト: vitamin-caig/zxtune
    async Task PlayFile(StorageFile sf)
    {
        if (sf == null)
        {
            Exit();
            return;
        }
        byte[] module = new byte[ASAPInfo.MaxModuleLength];
        int    moduleLen;

        using (IInputStream iis = await sf.OpenSequentialReadAsync()) {
            IBuffer buf = await iis.ReadAsync(module.AsBuffer(), (uint)ASAPInfo.MaxModuleLength, InputStreamOptions.None);

            moduleLen = (int)buf.Length;
        }

        ASAP asap = new ASAP();

        asap.Load(sf.Name, module, moduleLen);
        ASAPInfo info     = asap.GetInfo();
        int      song     = info.GetDefaultSong();
        int      duration = info.GetLoop(song) ? -1 : info.GetDuration(song);

        asap.PlaySong(song, duration);

        this.MyMedia = new MediaElement {
            AudioCategory = AudioCategory.BackgroundCapableMedia,
            Volume        = 1,
            AutoPlay      = true
        };
        Window.Current.Content = this.MyMedia;
        await Task.Yield();

        this.MyMedia.SetSource(new ASAPRandomAccessStream(asap, duration), "audio/x-wav");

        MediaControl.TrackName               = info.GetTitleOrFilename();
        MediaControl.ArtistName              = info.GetAuthor();
        MediaControl.PlayPressed            += MediaControl_PlayPressed;
        MediaControl.PausePressed           += MediaControl_PausePressed;
        MediaControl.PlayPauseTogglePressed += MediaControl_PlayPauseTogglePressed;
        MediaControl.StopPressed            += MediaControl_StopPressed;
        MediaControl.IsPlaying               = true;
    }
コード例 #6
0
 static void Check(string path)
 {
     if (Directory.Exists(path))
     {
         foreach (string child in Directory.GetFileSystemEntries(path))
         {
             Check(child);
         }
     }
     else if (ASAPInfo.IsOurFile(path))
     {
         byte[] module = File.ReadAllBytes(path);
         try {
             ASAP asap = new ASAP();
             asap.Load(path, module, module.Length);
             asap.PlaySong(asap.GetInfo().GetDefaultSong(), -1);
         }
         catch (Exception ex) {
             Console.WriteLine("{0}: {1}", path, ex.Message);
         }
     }
 }
コード例 #7
0
 static void SetTime(string s)
 {
     Duration = ASAPInfo.ParseDuration(s);
 }
コード例 #8
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 moduleLen = e.Result.Read(module, 0, module.Length);

		ASAP asap = new ASAP();
		asap.Load(this.Filename, module, moduleLen);
		this.Info = asap.GetInfo();
		if (this.Song < 0)
			this.Song = this.Info.GetDefaultSong();
		int duration = this.Info.GetLoop(this.Song) ? -1 : this.Info.GetDuration(this.Song);
		asap.PlaySong(this.Song, duration);

		Stop();
		CallJS("onLoad");
		this.MediaElement.SetSource(new ASAPMediaStreamSource(asap, duration));
	}