Programmer Guide/Macro Library/BSF: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 35: | Line 35: | ||
|- | |- | ||
|SoundFileList ||shell variable ||name of the shared soundfile table item (see [[../BSTXIni|BSTXIni]]) | |SoundFileList ||shell variable ||name of the shared soundfile table item (see [[../BSTXIni|BSTXIni]]) | ||
|- | |||
|AutoCloseSF ||close all soundfiles opened by a [[Programmer_Guide/BScript|BScript]] application. | |||
|} | |} | ||
==NewDialog== | ==NewDialog== | ||
Line 90: | Line 92: | ||
|<code>CREATE</code> → Create a new soundfile. If the file <var>path</var> exists, it is replaced by the new soundfile.<BR> | |<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>READ</code> → Open an existing soundfile for readonly-access.<BR> | ||
<code>WRITE</code> → Open | <code>WRITE</code> → Open a soundfile for read- and write-access. The file is created if it do not exist!<BR> | ||
<code>AUTO</code> → Open | <code>AUTO</code> → Open a soundfile and select the access type automatically (try read/write first and than readonly). | ||
|<code>WRITE</code> | |<code>WRITE</code> | ||
|- | |- | ||
Line 170: | Line 172: | ||
;See also: | ;See also: | ||
==CloseAll== | ==CloseAll== | ||
;<code>BSF CLOSEALL</code>: Close all soundfiles opened by a [[Programmer_Guide/BScript|BScript]] application. This function is automatically called at the end of the script execution if the variable <code>AutoCloseSF</code> equals <code>1</code>. | |||
;<code>BSF CLOSE <var>index</var> [ ; <var>del</var> ]</code>: Decrement open-counter of the soundfile and close it, if the open-counter equals zero. | |||
{|class="einrahmen" | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<code>0</code> ||Success. All soundfiles are closed. | |||
|- | |||
|> <code>0</code> ||Failed, some soundfiles are still open. The return value is a {{STX}} error code. | |||
|} | |||
;See also: | |||
==Select== | ==Select== | ||
;<code>BSF SELECT <var>path</var></code>: | |||
;<code>BSF SELECT <var>index</var></code>: Select (activate) the specified soundfile. | |||
{|class="einrahmen" | |||
!argument !!description !!default | |||
|- | |||
|<var>path</var> | |||
|Path of the soundfile to be selected. | |||
| | |||
|- | |||
|<var>index</var> | |||
|Zero based index of the soundfile to be selected. | |||
| | |||
|- | |||
!RESULT !!description | |||
|- | |||
|<code>0</code> ||Success. | |||
|- | |||
|> <code>0</code> ||Failed. The return value is a {{STX}} error code. | |||
|} | |||
;Notes: | |||
*To select a soundfile, it must be open. | |||
*Some commands (e.g. [[Programmer_Guide/Command_Reference/NEW|NEW WAVE]] or [[Programmer_Guide/Command_Reference/SEGMENT|SEGMENT]] are using the selected (activated) soundfile. | |||
;See also: | |||
==Truncate== | ==Truncate== |
Revision as of 08:41, 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) AutoCloseSF close all soundfiles opened by a BScript application.
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. | 0 .
|
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. The variables
CSF
andCSFH
contain the full path and the header parameters of the soundfile. - 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
Close
BSF CLOSE path [ ; del ]
BSF CLOSE index [ ; del ]
- Decrement open-counter of the soundfile and close it, if the open-counter equals zero.
argument | description | default |
---|---|---|
path | Path of the soundfile to be closed. | |
index | Zero based index of the soundfile (see Select). | |
del | Delete flag. If this flag is set to 1 (or yes ) and the specified soundfile is closed by this function, the soundfile and all corresponding metadata files are deleted.
|
0
|
RESULT | description | |
0 |
Success. | |
> 0 |
Failed. The return value is a STx error code. |
- Notes
- First the open-counter of the specified soundfile is decremented. If the open-counter equals zero, the soundfile is closed and (optional) deleted.
- This function updates the shared soundfile table (
SoundFileList
) and the tableBSFOpenList
(if called in a BScript application). - To really close a soundfile the number of
CLOSE
calls must be equal to the number ofOPEN
calls for this soundfile.
- See also
CloseAll
BSF CLOSEALL
- Close all soundfiles opened by a BScript application. This function is automatically called at the end of the script execution if the variable
AutoCloseSF
equals1
. BSF CLOSE index [ ; del ]
- Decrement open-counter of the soundfile and close it, if the open-counter equals zero.
RESULT | description |
---|---|
0 |
Success. All soundfiles are closed. |
> 0 |
Failed, some soundfiles are still open. The return value is a STx error code. |
- See also
Select
BSF SELECT path
BSF SELECT index
- Select (activate) the specified soundfile.
argument | description | default |
---|---|---|
path | Path of the soundfile to be selected. | |
index | Zero based index of the soundfile to be selected. | |
RESULT | description | |
0 |
Success. | |
> 0 |
Failed. The return value is a STx error code. |
- Notes
- To select a soundfile, it must be open.
- Some commands (e.g. NEW WAVE or SEGMENT are using the selected (activated) soundfile.
- See also