Generate a tone .pb example ?

Just starting out? Need help? Post your questions and find answers here.
Olli
Addict
Addict
Posts: 1240
Joined: Wed May 27, 2020 12:26 pm

Re: Generate a tone .pb example ?

Post by Olli »

:mrgreen:

AZJIO, thanks for the back info : I am coding on the 2016 version !!!

(44.1 KHz 16 bits 1 channel. Short note, I prefer let our friend infratec manage high-end : 44.1 KHz 24 bits 2 channels or more ! Maybe ADPCM also... "deutsche Qualität" !)

fixed for LTS version :

Code: Select all

structure wav
 array w.w(21)
endStructure
initSound()
*wav.wav = allocateMemory(sizeOf(wav) )
initializeStructure(*wav, wav)
base64decoder("UklGRgAAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQ", @*wav\w(0), 40)
with *wav
 wMax = 62800
 reDim \w(wMax + 22)
 size = (wMax + 23) * 2
 PokeL(@\w(2), size - 8)
 PokeL(@\w(20), size - 44)
 ampli.d = 800
 for i = 0 to wMax
  \w(i + 22) = cos(i / (7 - sin(t.d) ) ) * ampli
  ampli * 0.999
  t + 0.00015
 next
 snd = catchSound(#pb_any, @\w(0) )
 repeat
  playSound(snd, #pb_sound_multiChannel)
  delay(400)
 until inputRequester("", "Just press enter to play", "")
endWith
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: Generate a tone .pb example ?

Post by firace »

Olli wrote: Fri Oct 28, 2022 3:39 pm :mrgreen:

AZJIO, thanks for the back info : I am coding on the 2016 version !!!

(44.1 KHz 16 bits 1 channel. Short note, I prefer let our friend infratec manage high-end : 44.1 KHz 24 bits 2 channels or more ! Maybe ADPCM also... "deutsche Qualität" !)

fixed for LTS version :

Code: Select all

structure wav
 array w.w(21)
endStructure
initSound()
*wav.wav = allocateMemory(sizeOf(wav) )
initializeStructure(*wav, wav)
base64decoder("UklGRgAAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQ", @*wav\w(0), 40)
with *wav
 wMax = 62800
 reDim \w(wMax + 22)
 size = (wMax + 23) * 2
 PokeL(@\w(2), size - 8)
 PokeL(@\w(20), size - 44)
 ampli.d = 800
 for i = 0 to wMax
  \w(i + 22) = cos(i / (7 - sin(t.d) ) ) * ampli
  ampli * 0.999
  t + 0.00015
 next
 snd = catchSound(#pb_any, @\w(0) )
 repeat
  playSound(snd, #pb_sound_multiChannel)
  delay(400)
 until inputRequester("", "Just press enter to play", "")
endWith
Nice code!
Is it possible to customize the tone frequency, duration and/or waveform?
Olli
Addict
Addict
Posts: 1240
Joined: Wed May 27, 2020 12:26 pm

Re: Generate a tone .pb example ?

Post by Olli »

Hello firace,

if I did not answer to your question, it is because I do not see what does it prevent us to modify the frequency, the duration and the waveform.

However, what we can listen to, is a liquid drop. If you change the frequency, the duration or the waveform, I doubt you will listen a liquid drop...
Post Reply