Programmer Guide/Macro Library/BSF: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 61: | Line 61: | ||
;Notes: | ;Notes: | ||
*This function uses a two step dialog. In the first the soundfile name is selected. The second is used to select the soundfile parameters. | *This function uses a two step dialog. In the first the soundfile name is selected. The second is used to select the soundfile parameters. | ||
*The new soundfile is always the created using the '''Windows WAVE''' format. | |||
*On return, the soundfile is created but not opened. | *On return, the soundfile is created but not opened. | ||
;See also: | ;See also: | ||
Line 74: | Line 75: | ||
|} | |} | ||
;Notes: | ;Notes: | ||
*The dialog can open soundfiles in the '''Windows WAVE''' and the '''S_TOOLS 5''' format. | |||
*On return, the soundfile is checked (existence, format) but not opened. | *On return, the soundfile is checked (existence, format) but not opened. | ||
;See also: | ;See also: | ||
==Open== | ==Open== | ||
;<code>BSF OPEN <var>path</var> [ ; <var>mode</var> ; <var>srate</var> [ ; <var>nch</var> ; <var>code</var> ; <var>type</var> ; <var>offset</var> ]</code>: Create and/or open a soundfile. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>path</var> | |||
|Path of the soundfile to be opened or created.<BR>Note: If the asterisk '''*''' is used for <var>path</var>, an unique soundfile is '''created''' in the temp. directory (see <code>@TempDir</code>. In this case, the argument <var>mode</var> is ignored. | |||
| | |||
|- | |||
|<var>mode</var> | |||
|<code>CREATE</code> → Create a new soundfile. If the file <var>path</var> exists, it is replaced by the new soundfile.<BR> | |||
<code>READ</code> → Open an existing soundfile for readonly-access.<BR> | |||
<code>WRITE</code> → Open an existing soundfile for read- and write-access. The file is created if it do not exist!<BR> | |||
<code>AUTO</code> → Open an existing soundfile. Select the access type automatically (try read/write first and than readonly). | |||
|<code>WRITE</code> | |||
|- | |||
|<var>srate</var> | |||
|Sampling rate in Hz. | |||
|<code>44100</code> | |||
|- | |||
|<var>nch</var> | |||
|Number of channels. | |||
|<code>1</code> | |||
|- | |||
|<var>code</var> | |||
|Signal sample size (number of bits) and code.<BR> | |||
<code>PCM8, PCM16, PCM24, PCM32</code> → 8/16/24/32 bit integer twos-complement<BR> | |||
<code>FLOAT</code> → 32 bit IEEE floating point | |||
|<code>PCM16</code> | |||
|- | |||
|<var>type</var> | |||
|File format.<BR> | |||
<code>WAVE</code> → Windows WAVE format (Microsoft) | |||
<code>ST5</code> → S_TOOLS 5 format (ISF) | |||
<code>BINARY</code> → plain binary file; may contain a unknown <var>offset</var>-byte header | |||
|<code>WAVE</code> | |||
|- | |||
|<var>offset</var> | |||
|The size of the header of a plain binary soundfile. | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<code>0</code> ||The soundfile was successfully selected, opened or created. | |||
|- | |||
|<code>-2</code> ||error: can not assign unique tempfile name | |||
|- | |||
|<code>-3</code> ||error: sampling rate out of range | |||
|- | |||
|<code>-4</code> ||error: number of channels out of range | |||
|- | |||
|<code>-5</code> ||error: size of binary-files must be greater/equal 0 | |||
|- | |||
|> <code>0</code> ||a {{STX}} error code | |||
|} | |||
;Notes: | |||
*If a soundfile is already opened, it is selected and its open-counter is incremented. | |||
*If a soundfile is opened the first time, the open-counter is set to 1. | |||
*This function updates the shared soundfile table (<code>SoundFileList</code>) and the table <code>BSFOpenList</code> (if called in a [[Programmer_Guide/BScript|BScript]] application) | |||
*The arguments <var>srate</var>, <var>nch</var>, <var>code</var> and <var>type</var> are only used if a new soundfile is created (<var>mode</var> is <code>WRITE</code> or <code>AUTO</code>) or if the <var>type</var> <code>BINARY</code> is used. If an existing soundfile with a known header format is opened, these parameters are read from the soundfile header. | |||
*If a soundfile of type <code>BINARY</code> is opened, the soundfile parameters <var>srate</var>, <var>nch</var> and <var>code</var> must always be specified, because the format and content of the (optional) header of such files is not known. The header of binary files must be located at the file begin and must consist of <var>offset</var> (≥ 0) bytes. If a binary file is created, no header is written and <var>offset</var> must be <code>0</code>. | |||
;See also: | |||
==Close== | ==Close== | ||
Revision as of 07:44, 12 May 2011
- File: BSF.STX, linked to library STX.LIB
- Title: soundfile handling
- Content
- Variables and items used by this library
name type description @ParSoundFileNew global variable default values for function NewDialog @ListAudioSampleCode global variable list of defined sample code keywords @MaxAudioChannels global variable maximum number of soundfile channels @MaxAudioSRate global variable maximum sampling rate in Hz @ListAudioSRate global variable list of standard sampling rate values @TempDir global variable directory for temporary files BSFOpenList table item list of open soundfiles (only for BScript applications); this table is used by the functions Open, Close and CloseAll
SoundFileList shell variable name of the shared soundfile table item (see BSTXIni)
NewDialog
BSF NEWDIALOG [ srate [ ; nch ; code ]
- Dialog to create a new soundfile.
argument | description | default |
---|---|---|
srate | Sampling rate in Hz | last dialog value |
nch | Number of channels. | last dialog value |
code | Signal sample size (number of bits) and code. | last dialog value |
RESULT | description | |
path | The full pathname of the created soundfile. | |
empty string | If the dialog was canceled or the creation fails. |
- Notes
- This function uses a two step dialog. In the first the soundfile name is selected. The second is used to select the soundfile parameters.
- The new soundfile is always the created using the Windows WAVE format.
- On return, the soundfile is created but not opened.
- See also
OpenDialog
BSF OPENDIALOG
- Dialog to open an existing soundfile.
RESULT | description |
---|---|
path | The full pathname of the selected soundfile. |
empty string | If the dialog was canceled or the soundfile check fails. |
- Notes
- The dialog can open soundfiles in the Windows WAVE and the S_TOOLS 5 format.
- On return, the soundfile is checked (existence, format) but not opened.
- See also
Open
BSF OPEN path [ ; mode ; srate [ ; nch ; code ; type ; offset ]
- Create and/or open a soundfile.
argument | description | default |
---|---|---|
path | Path of the soundfile to be opened or created. Note: If the asterisk * is used for path, an unique soundfile is created in the temp. directory (see @TempDir . In this case, the argument mode is ignored.
|
|
mode | CREATE → Create a new soundfile. If the file path exists, it is replaced by the new soundfile.
|
WRITE
|
srate | Sampling rate in Hz. | 44100
|
nch | Number of channels. | 1
|
code | Signal sample size (number of bits) and code.
|
PCM16
|
type | File format.
|
WAVE
|
offset | The size of the header of a plain binary soundfile. | |
RESULT | description | |
0 |
The soundfile was successfully selected, opened or created. | |
-2 |
error: can not assign unique tempfile name | |
-3 |
error: sampling rate out of range | |
-4 |
error: number of channels out of range | |
-5 |
error: size of binary-files must be greater/equal 0 | |
> 0 |
a STx error code |
- Notes
- If a soundfile is already opened, it is selected and its open-counter is incremented.
- If a soundfile is opened the first time, the open-counter is set to 1.
- This function updates the shared soundfile table (
SoundFileList
) and the tableBSFOpenList
(if called in a BScript application) - The arguments srate, nch, code and type are only used if a new soundfile is created (mode is
WRITE
orAUTO
) or if the typeBINARY
is used. If an existing soundfile with a known header format is opened, these parameters are read from the soundfile header. - If a soundfile of type
BINARY
is opened, the soundfile parameters srate, nch and code must always be specified, because the format and content of the (optional) header of such files is not known. The header of binary files must be located at the file begin and must consist of offset (≥ 0) bytes. If a binary file is created, no header is written and offset must be0
.
- See also