File Formats
  Vorlesungen     Download     DBS     Sprachen     Oberflächen     Impressum     Datenschutz  
dBase format
bmp format
mp3 format
wav format
flac format
pdf format
Allgemein:
Startseite
Vorlesungen
Labore
Sinnvolle Programme
Lineare Regression
GUI-Entwurfsarbeit
Single-Format
Design Pattern-Termine
Observer1
Bsp2
Json-Array
Json-Dialogelemente
Webtechnologien

wav

Wav Format

The wav format is used to play with a modern Diagital Analog Converter (DAC).
It is the CD-Format with 44,1 kHz and a sampling rate 16 Bit.
It is compressed but without any lost information, such as a mp3 file.

I hear music with flacs, dsf and wav file with a T&A DAC 8 DSD.
But the Media Player I choose want to regist all files.
For me, that was uncomfortable, so I wrote MY own audio player.

Properties:
- There is a tree list for the folder of the solngs
- One can choose one or many folder to read the songs.
- The are read recursivly.
- The program can stop, start, and play behind and forward to the song.
- The program can change the volume ot the music.
- The program show the title, samplingrate and bitrate from the songs.

Therefore I have to read the mp3, wav and flac file, to read the informations.

Description_Audioplayer.pdf

AudioPlayer.exe
AudioPlayer.zip
AudioPlayer-Source.zip


Source in c#


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.IO;

namespace AudioPlayer.Tools {
  public class Wave {
    public String filename = "";
    public String album = "";
    public String artist = "";
    public String title = "";


    public int samplerate = 0;
    public int minutes = 0;
    public int seconds = 0;
    public int bitcount = 0;

    public Wave(String filename) {
      this.filename = filename;
    }

    /*  Little Endian-Format !!X
      *      R I F F ? ? ? ? W A V E f m t 
        000000 52 49 46 46 94 75 2D 02 57 41 56 45 66 6D 74 20  RIFF?u-.WAVEfmt_
            wchannel       44 kHZ
            -----      ----------- 
        000010 10 00 00 00  01 00 02 00 44 AC  00 00 10 B1 02 00  ........D¬...±..
        000020 04 00 10 00 64 61 74 61 70 75 2D 02 00 00 00 00  ....datapu-.....
    */
    public bool readSamplerate() {
      FileStream fin = new FileStream(this.filename, FileMode.Open, FileAccess.Read);
      BinaryReader bin = new BinaryReader(fin);
      // RIFF 36553660 2490707202

      byte[] headerSoll = { 0x52, 0x49, 0x46, 0x46 };
      byte[] header = new byte[headerSoll.Length];
      header = bin.ReadBytes(header.Length);
      for (int i = 0; i < headerSoll.Length; i++) {
        if (headerSoll[i] != header[i]) {
          Basis.ErrorMsg("Error, the audiofile is not a Wav-File (RIFF)\r\n" + filename, "Error");
          bin.Close();
          fin.Close();
          return false;
        }
      } // 94752D02
      byte[] waveSoll = { 0x57, 0x41, 0x56, 0x41 };
      byte[] waveIst = new byte[waveSoll.Length];
      waveIst = bin.ReadBytes(4); // dummy Bytes dazwishcen
      waveIst = bin.ReadBytes(waveIst.Length);
      for (int i = 0; i < headerSoll.Length; i++) {
        if (headerSoll[i] != header[i]) {
          Basis.ErrorMsg("Error, the audiofile is not a Wav-File (WAVE)\r\n" + filename, "Error");
          bin.Close();
          fin.Close();
          return false;
        }
      }

      byte[] ftm = new byte[4];
      ftm = bin.ReadBytes(ftm.Length); // 66 6D 74 20

      byte[] formatTag = new byte[2];
      formatTag = bin.ReadBytes(formatTag.Length); // 01 00 little endian

      byte[] channels = new byte[2];
      channels = bin.ReadBytes(channels.Length); // 01 00 little endian

      byte[] dummy = new byte[4];
      dummy = bin.ReadBytes(dummy.Length); // 01 00 little endian

      byte[] samplerates = new byte[4];
      dummy = bin.ReadBytes(dummy.Length); // 01 00 little endian
      samplerates[0] = dummy[3];
      samplerates[1] = dummy[2];
      samplerates[2] = dummy[1];
      samplerates[3] = dummy[0];
            
      int b0 = (int)samplerates[0];
      int b1 = (int)samplerates[1];
      int b2 = (int)samplerates[2];
      int b3 = (int)samplerates[3];
      samplerate = (b0 << 24) | (b1 << 16) | (b2 << 8) | (b3);

      //fin.Seek(0x12, SeekOrigin.Begin); // jump to the first byte of the sampleRate

      dummy = new byte[5];
      dummy = bin.ReadBytes(dummy.Length); // 01 00 little endian

      byte[] bitsPerSamples = new byte[2];
      bitsPerSamples = bin.ReadBytes(bitsPerSamples.Length); // 01 00 little endian
      int bc1 = bitsPerSamples[1];
      int bc0 = bitsPerSamples[0];


      bitcount = (bc0 << 8) | bc1;

      bin.Close();
      fin.Close();
      return true;
    }
    


  }
}