New Sound Datatypes

miker1264 · 3080

miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
on: November 23, 2021, 03:24:15 PM
After working with Sound Datatype Conversion for a short while I've concluded that we need more datatypes!

Maybe MOD, MED, MIDI, OGG, MP3 & WMA to start.
We already have WAV & 8SVX.

But the AROS DatTypes System for Sound Files has some issues. It seems Wave has its own datatype but 8svx datatype only has a Load Function.  But Wave can save using DTWM_RAW and 8svx can also save a copy of itself. So save functions for AIFF & 8SVX must be included in Sound Datatype Sound_Write.

There are two problems that I've discovered. DTWM_RAW saves correctly. Open an 8svx in MultiView then choose Save As. It saves a complete copy of the 8svx file. But if we try Save As IFF it fails to write an IFF-8SVX file. I suspect there is something wrong inside Sound_Write for Sound Datatype.

There's another problem. It seems the Sound_New should be able to return an empty sound datatype object but it keeps failing. So I suspect there is a problem with Sound_New. But getting a sound datatype object of an existing file does work.

I have more research to do...  8)



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #1 on: November 23, 2021, 03:34:52 PM
8SVX It is a data subtype of the IFF file container format, in fact the tested conversion program saves an 8SVX with IFF extension !


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #2 on: November 23, 2021, 03:51:09 PM
8SVX It is a data subtype of the IFF file container format, in fact the tested conversion program saves an 8SVX with IFF extension !

8SVX is the Commodore Amiga IFF-8SVX file format. I suspect Save As in MultiView for sound files should save 8SVX with 8SVX or IFF file extension. But AIFF is the Apple Audio IFF which should have its own datatype. It isn't Commodore-specific.

First I must figure out how to make MultiView method DTWM_IFF to trigger Sound_Write which calls Write_AIFF or Write_8SVX. We'll see which format it saves. I suspect 8SVX. Then I'll look at Sound_New. Both functions in Sound Datatype.

« Last Edit: November 23, 2021, 03:57:26 PM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #3 on: November 23, 2021, 05:18:23 PM
Interesting. If you open a wave file in MultiView and select Save As IFF it will fail. But if you open an 8svx file and do the same it will succeed in saving an 8svx file. So why the difference?

DTM_Write message is sent to Sound Datatype. In Sound_Write it only examines that write mode. So it considers DTWM_RAW the same as DTWM_IFF. The only caveat is later in the write function it decides the output format based on input format. There are only two options: AIFF & 8SVX. So if the input is 8svx and we choose Save As IFF ( DTWM_IFF ) it will save 8svx. But there is no provision for saving any other format as 8svx.



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #4 on: November 23, 2021, 05:42:35 PM
Interesting. If you open a wave file in MultiView and select Save As IFF it will fail. But if you open an 8svx file and do the same it will succeed in saving an 8svx file. So why the difference?
[/quote,

I think it's due to Multiview "going crazy", once we tell it that an "IFF" is an image then we tell it that a music file is also "IFF", I think this creates the conflict.

If you try to give this command:

DTConv Test.Wave sound.8svx sound iff -> you will get a "corrupted" ILBM file


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #5 on: November 23, 2021, 06:08:18 PM
AMIGASYSTEM

When you open the resulting IFF file in a Hex Editor what does it say at the top? I suspect it has an ILBM icon because it has an IFF file extension. Either the file is empty ( 0 bytes ) or not valid.
« Last Edit: November 23, 2021, 06:17:48 PM by miker1264 »



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #6 on: November 23, 2021, 06:45:15 PM
No the file is recognized even without extension.
The is not an empty file, it is a hybrid file as big as Wave, but it is not a sound :)


miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #7 on: November 23, 2021, 09:02:20 PM
That looks like an empty IFF file.   :)

Anyhow...problem solved. The scientific method at work.  8)

MultiView can now open a Wav file and Save As IFF to save an 8SVX file.

There were actually two problems. In Sound Datatype the Sound_Write function is the SuperMethod. Normally a datatype has two methods: OM_NEW & DTM_WRITE. The first links the Load function of the datatype with Datatypes Library for getting new datatypes. The second links the Save function of
the datatype or if DT Write Method is not DTWM_RAW then it is supposed to defer to the SuperMethod.In this case it would send the DTWM_IFF message to the Sound Datatype function Sound_Write.

But as I mentioned earlier the Sound_Write function in Sound Datatype doesn't have an allowance for DTWM_IFF only DTWM_RAW. So I added a new method for Sound Datatype as follows in dispatch.c:

            if( dtw->MethodID == DTM_WRITE && dtw->dtw_Mode == DTWM_IFF )
          {
             dbug( kprintf( "My dtw_Mode = DTWM_IFF\n" ); )
            D(bug("[sound.datatype] - My dtw_Mode = DTWM_IFF\n"));
            err = WriteSVX( cb, o, iff, id );
          }

So if the DT Write Method is DTWM_IFF I'm forcing it to convert and save as an IFF-8SVX file.

The second problem I already alluded to...the Wave Datatype DTM_WRITE method was missing some important information. It was missing the part that sends it to the SuperMethod in Sound Datatype.

    else
    {
       /* Pass msg to superclass (which writes an IFF-8SVX sound file)... */
       return DoSuperMethodA( cl, obj, (Msg)msg );
    }

After those two minor changes I can now open a Wave file and Save As IFF-8SVX. Nice!  8)


« Last Edit: November 23, 2021, 10:24:12 PM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #8 on: November 23, 2021, 09:19:07 PM
Notice that there are only two files in Ram Disk - the Wave file I saved with MultiView Save As and the 8SVX file I saved with MultiView Save As IFF when I opened the original Wave file.

« Last Edit: November 23, 2021, 09:47:07 PM by miker1264 »



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #9 on: November 23, 2021, 09:23:08 PM
Just so you can't say but how do you know it saved an 8SVX file and not an imposter hybrid ?



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #10 on: November 23, 2021, 09:26:56 PM
Here are the compiled 68k datatypes that I used to open a Wave file in MultiView and save 8SVX with Save As IFF.

Temporarily rename your older sound datatype & wave datatype. Then just copy these two new ones to your Classes/Datatypes.

So open a Wave file and give it a try.  :P
« Last Edit: November 23, 2021, 09:49:12 PM by miker1264 »



AMIGASYSTEM

  • Global Moderator
  • Legendary Member
  • *****
    • Posts: 3740
    • Karma: +69/-2
  • AROS One
    • AROS One
Reply #11 on: November 24, 2021, 01:21:15 AM
Just so you can't say but how do you know it saved an 8SVX file and not an imposter hybrid ?
Mine was just a guess, I add that DTConv x86 version doesn't generate that file, it just creates a 0 byte file

Thanks for the new version which I will test shortly.


OlafS3

  • Legendary Member
  • *****
    • Posts: 544
    • Karma: +50/-8
Reply #12 on: November 24, 2021, 04:02:50 AM
Here are the compiled 68k datatypes that I used to open a Wave file in MultiView and save 8SVX with Save As IFF.

Temporarily rename your older sound datatype & wave datatype. Then just copy these two new ones to your Classes/Datatypes.

So open a Wave file and give it a try.  :P

I will test it. Thanks



miker1264

  • Legendary Member
  • *****
    • Posts: 1827
    • Karma: +84/-6
Reply #13 on: November 24, 2021, 10:44:48 AM
One set of problems done. Now I'm trying to find out why getting an empty sound datatype object from basename fails.

So I placed more debug messages in sound datatype in Sound_NEW to confirm the problem then try to fix it as well.

Not sure if you can see near the bottom of the output screen - Error! Object Creation Failed.

Sure enough! It fails to return a sound datatype object. Now I must find out why.  ;)



OlafS3

  • Legendary Member
  • *****
    • Posts: 544
    • Karma: +50/-8
Reply #14 on: November 24, 2021, 10:51:35 AM
we trust in you  :)