Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: .wav to Arbitrary Waveform

  1. #1
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    112

    .wav to Arbitrary Waveform

    Sorry if this one comes up frequently but i cant find anything i can understand:

    Is there any documentation on how to convert a .wav single cycle Waveform to something that can be used as arbitrary waveform array to be played by AudioSynthWaveform?

    Any hints, tipps or other help highly appreciated - many thanks in advance!

  2. #2
    Senior Member fdaniels's Avatar
    Join Date
    Oct 2020
    Location
    Ostwestfalen, Germany
    Posts
    112
    OK, i worked it out. Somehow. At least a feasible, but probably maximum unelegant way to get the Waveforms converted:

    1 Resample you singlecycle (16 Bit Mono) waveform so you get exactly 256 samples length, using Waveosaur or something even more sophisticated

    2 Export as a Text File

    3 Import to your favourite Spreadsheet application (i used RagTime....dont laugh at me, there is certainly a better way with some fancy scripting. I just needed ONE Waveform ;-) )

    4 Convert the apparently float to 16 Bit integer

    5 Export the integer part of the table together with nice fitting "," as Text to Paste into Teensyduino.

    6 Use an Array as below as arbitrary Wavform for AudioSynthWaveform or AudioSynthWaveformModulated


    Code:
    const int16_t mysticSynth076_Wave[256]={
    -10993  ,-10518  ,-9865 ,-8878 ,-6951 ,-6113 ,-5206 ,-2777 ,-273  ,2774  ,8324  ,
    10061 ,10983 ,12313 ,12875 ,14671 ,15844 ,17099 ,18247 ,19280 ,20473 ,20687 ,20581 ,19929 ,19847 ,19391 ,19495 ,19289 ,19176 ,19298 ,19243 ,19475 ,20046 ,20349 ,20747 ,21125 ,20561 ,
    20535 ,20694 ,19325 ,19117 ,18274 ,17382 ,17221 ,16641 ,14479 ,12983 ,11605 ,9391  ,8523  ,7499  ,6152  ,4057  ,3409  ,2050  ,-1288 ,-2348 ,-3454 ,-4790 ,-5372 ,-5865 ,-6728 ,-6500 ,
    -6597 ,-9560 ,-10799  ,-10911  ,-10936  ,-11299  ,-11865  ,-13168  ,-15059  ,-14272  ,-14520  ,-14750  ,-15351  ,-15409  ,-15500  ,-15723  ,-15157  ,-14902  ,-14650  ,-14624  ,-14099  ,-13345  ,
    -13068  ,-12739  ,-11270  ,-11033  ,-10577  ,-8507 ,-8394 ,-8715 ,-6553 ,-5084 ,-4836 ,-2894 ,-1719 ,-596  ,783 ,3603  ,4674  ,5114  ,5760  ,6455  ,7021  ,7234  ,7415  ,7904  ,7408  ,7428  ,
    6767  ,6926  ,5740  ,5911  ,5822  ,4501  ,4309  ,4285  ,3389  ,3136  ,3252  ,2055  ,1736  ,1269  ,1126  ,1278  ,1183  ,-976  ,-2556 ,-3825 ,-4848 ,-6878 ,-8029 ,-9100 ,-10135  ,-10564  ,
    -10865  ,-13248  ,-14075  ,-15137  ,-16133  ,-17270  ,-17476  ,-18722  ,-19834  ,-20706  ,-21173  ,-21372  ,-21100  ,-20861  ,-21007  ,-20801  ,-20651  ,-20308  ,-19987  ,-19622  ,-18808  ,
    -18582  ,-18593  ,-17806  ,-17443  ,-16786  ,-15834  ,-14955  ,-14460  ,-13624  ,-12590  ,-12119  ,-11540  ,-11650  ,-10845  ,-10097  ,-7801 ,-6865 ,-5460 ,-1722 ,-31 ,1349  ,2736  ,7506  ,10652 ,13408 ,
    16141 ,18599 ,20778 ,22984 ,23136 ,24147 ,28797 ,31127 ,32474 ,32127 ,31454 ,30954 ,30941 ,28824 ,28700 ,28587 ,27273 ,27786 ,27851 ,27477 ,27054 ,27194 ,28840 ,29043 ,28994 ,30072 ,
    30211 ,30074 ,29399 ,26992 ,25977 ,24240 ,21074 ,19676 ,18864 ,15032 ,9510  ,2258  ,-7940 ,-8308 ,-9310 ,-12298  ,-13033  ,-13232  ,-13157  ,-15079  ,-16023  ,-16695  ,-17523  ,-18465  ,-19549  ,
    -20945  ,-21898  ,-22213  ,-25385  ,-25159  ,-25832  ,-25004  ,-25973  ,-25690  ,-24679  ,-23794  ,-24252  ,-24398  ,-23215  ,-22498  ,-21283  ,-19434  ,-17713  ,-15867  ,-14336  ,-13670  ,-12754 
    };
    Last edited by fdaniels; 12-02-2020 at 12:53 PM.

  3. #3
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,255
    Quote Originally Posted by fdaniels View Post
    Sorry if this one comes up frequently but i cant find anything i can understand:

    Is there any documentation on how to convert a .wav single cycle Waveform to something that can be used as arbitrary waveform array to be played by AudioSynthWaveform?

    Any hints, tipps or other help highly appreciated - many thanks in advance!
    Use Python SoundFile package, python has libraries for almost everything too so exporting as csv is again
    just use the right library.

    Resampling can be done of course, ie with the scipy.signal library.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •