User Tools

Site Tools


playing_20part_20of_20a_20wav_20file

Playing part of a WAV file

by Richard Russell, April 2013

If you want to play just a section of a WAV file, you can do so using code similar to the following:

  SYS "mciSendString", "open """ + wavfile$ + """ alias wav1", 0, 0, 0
  SYS "mciSendString", "play wav1 from 10000 to 20000", 0, 0, 0

Where wavfile$ is the path and file specification.

Here the start (from) and finish (to) positions are specified as constants (in milliseconds) but you can easily construct a suitable command string using variables:

  SYS "mciSendString", "open """ + wavfile$ + """ alias wav1", 0, 0, 0
  SYS "mciSendString", "play wav1 from " + STR$(start%) + " to " + STR$(finish%), 0, 0, 0

Ideally once the file has finished playing you should close the device as follows:

  SYS "mciSendString", "close wav1", 0, 0, 0
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
playing_20part_20of_20a_20wav_20file.txt · Last modified: 2018/04/15 14:04 by richardrussell