October 28, 2021, 15:18:19

Author Topic: Audio Programming Basics  (Read 645 times)

Offline axg74

  • Jr. Member
  • **
  • Posts: 4
Audio Programming Basics
« on: April 04, 2021, 13:12:20 »
Hi there!
can anyone recommend a tutorial about audio programming in general. I mean not the physical basics, like different types of waveforms (eg. sine, square, triangle, sawtooth). And I know the that a waveform must be played several times in a second to produce different pitches, simply explained.

Greetings
AXG74
« Last Edit: April 04, 2021, 13:14:02 by axg74 »

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 364
    • Midimaster Music Education Software
Re: Audio Programming Basics
« Reply #1 on: April 04, 2021, 16:35:03 »
this is a big field...
Quote
...I mean not the physical basics, like different types of waveforms (eg. sine, square, triangle, sawtooth)....
It would help, if you would not describe, what you not want, but what you want to know!
 
How this samples are organized?
How to siml play given samples?
How to build samples from mathematics?

Which language do you use?

What is yout target?
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline axg74

  • Jr. Member
  • **
  • Posts: 4
Re: Audio Programming Basics
« Reply #2 on: April 09, 2021, 23:18:15 »
I want to use pure BlitzMAX for some audio-programming, but I have read to generate some sound in realtime, it´s required to have an audio-callback function to fill an audio-buffer with the upcomming data. But BlitzMAX has no audio-callback function ability, I think.

Best regards.

Offline Midimaster

  • Sr. Member
  • ****
  • Posts: 364
    • Midimaster Music Education Software
Re: Audio Programming Basics
« Reply #3 on: April 10, 2021, 00:27:50 »
You can reach what you want with only BlitzMax code. I would suggest to test new Samples (which you calculate by mathematics) in two steps: First create them in a harmless TAudioSample(), then play them with TSound(). This has the advantage, that you have no additional problem with buffers. Then, after you know, that the Sample-creating is perfect you can send them via a buffered way.

Directly testing new samples via buffers may cause crackles and breaks and you never know what the reason was.

Here in the forum are currently some topic about the same problems and questons. See my list.

The topics 1,2 and 3 use only BlizMax functions. topic 2 offers a new aproach to the build in FreeAudio-Module, but still native BlitzMax.
 
For CallBack you would need a third party module, which you can see in topic 4 and 5

I think there are no special tutorials about this, but you can follow these threads, which have the same targets as you:

topic 1:
Topic: Creating ZX SOUND
https://www.syntaxbomb.com/index.php/topic,8285.0.html
Baggey tries to find a fast solution for creating a sounds on the fly and play it immediately. He writes a Spectrum-ZX-Emulator and needs a simulation for the direct access to speakers like it was in the 1980th. I showed him a way of producing TSounds-Snipplets of 100msec and play them. You can learn about building TSamples.

topic 2:
Topic: A new Audio-Out Approach in BlitzMax FreeAudio RingBuffer
Inspired by his problem I started a worklog to get a real all time open buffer for audio, where you can send single bytes or packets of bytes as you like and they are played immediately. There are two concepts of real time audio: Callbacks or Ringbuffers. And this is the ringbuffer approach. You can learn about creating Samples Values and real time sending.

topic 3:
Hardcoals questions
https://www.syntaxbomb.com/index.php?action=profile;u=36
He has the same questions like you and often asks here for soutions. So follow his posts and learn a lot. f.e. this thread, which startet first with a different topic, but changed to audio playback questions in the end:
https://www.syntaxbomb.com/index.php/topic,8286.msg347048910.html#msg347048910
You can learn about organisation of the Sample-Streams.

topic 4:
Topic: A new Audio-Out Approach in BlitzMax FreeAudio RingBuffer
In the first post there are some links, which are striked. Follow these links to the PortAudio-library and an existing wrapper. PortAudio offers access to Audio via Callback and enables access to ASIO. This is ready to run with examples!

topic 5:
Topic: How to write a wrapper?
This is my current project. I want to write a wrapper for MiniAudio-Library, which offers a Callback-approach and would enable the use of WASAPI. I don't know when this will ever be runable. But this is about CallBack-Audio. 


As you see, there are two aproaches CallBack and Ringbuffer, which both reach the same result. In CallBack the Audiodevice asks you for new datas, in Ringbuffer you care about sending them right in time.

Feel free to join us in these topics or start your own topic now with specific questions.



« Last Edit: April 10, 2021, 12:17:34 by Midimaster »
See my current project on PlayStore: 20Tracks-Audio-Player https://play.google.com/store/apps/details?id=midimaster.twentytrackd

Offline axg74

  • Jr. Member
  • **
  • Posts: 4
Re: Audio Programming Basics
« Reply #4 on: May 13, 2021, 23:24:23 »
thank you very much for the reply and the tips. Today I started with a simple square wave and tried to find the chromatic tone scale. I had success. I have patience and time. I think I create audio samples for each tone and play them if needed. I keep it very simple, like a simple 80s home computer / console. My first console was a "Interton VC4000" :)

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal