inputting_20real-time_20audio
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
inputting_20real-time_20audio [2024/04/19 16:05] – BBCSDL version added (tentative) richardrussell | inputting_20real-time_20audio [2024/04/19 17:43] (current) – richardrussell | ||
---|---|---|---|
Line 46: | Line 46: | ||
You could of course present the choices and accept the selection in different ways, for example a dialogue box containing a list box plus OK and Cancel buttons. | You could of course present the choices and accept the selection in different ways, for example a dialogue box containing a list box plus OK and Cancel buttons. | ||
- | ==== Choosing the number and size of the buffers | + | ==== Choosing the buffer |
- | The first step is to decide how many audio buffers you need and how large they should be. To some extent this is an arbitrary decision, but it will depend on things like //latency// (how much time elapses between the audio arriving and it being processed by your program) and the amount of work needed to process the received audio data.\\ \\ | + | The first step is to decide how large the audio buffer |
<code bb4w> | <code bb4w> | ||
- | nBuffers% = 3 | ||
SamplesPerBuffer% = 1024 | SamplesPerBuffer% = 1024 | ||
</ | </ | ||
Line 71: | Line 70: | ||
</ | </ | ||
- | ==== Opening the audio device and creating the buffers | + | ==== Opening the audio device and creating the buffer |
- | Now the audio capture device can be opened and the buffers | + | Now the audio capture device can be opened and the buffer |
<code bb4w> | <code bb4w> | ||
Line 79: | Line 78: | ||
IF Device% = 0 ERROR 100, " | IF Device% = 0 ERROR 100, " | ||
- | SamplingRate% = have.freq% | ||
BytesPerBuffer% = have.size% | BytesPerBuffer% = have.size% | ||
WordsPerBuffer% = BytesPerBuffer% DIV 4 | WordsPerBuffer% = BytesPerBuffer% DIV 4 | ||
- | DIM Buffers{(nBuffers%-1) Data%(WordsPerBuffer% - 1)} | + | DIM Buffer%(WordsPerBuffer% - 1) |
</ | </ | ||
Line 98: | Line 96: | ||
==== Inputting in real-time ==== | ==== Inputting in real-time ==== | ||
- | Once the above code has been executed you need to process the received audio buffers fast enough to keep up with the incoming data. The following code constantly | + | Once the above code has been executed you need to process the received audio buffers fast enough to keep up with the incoming data. The following code constantly |
<code bb4w> | <code bb4w> | ||
REPEAT | REPEAT | ||
- | | + | p%% = ^Buffer%(0) |
- | | + | R% = BytesPerBuffer% |
- | R% = BytesPerBuffer% | + | PROCprocessbuffer(p%%, |
- | PROCprocessbuffer(p%%, | + | REPEAT |
- | REPEAT | + | SYS " |
- | SYS " | + | p%% += I% : R% -= I% |
- | p%% += I% : R% -= I% | + | UNTIL R% <= 0 |
- | UNTIL R% <= 0 | + | |
- | NEXT | + | |
UNTIL FALSE | UNTIL FALSE | ||
+ | END | ||
</ | </ | ||
inputting_20real-time_20audio.1713542735.txt.gz · Last modified: 2024/04/19 16:05 by richardrussell