RocketDivision.Com Forum IndexRocketDivision.Com
RDS - software that rocks!
 
 FAQFAQ             
        

Copy Audio CD #2

 
      RocketDivision.Com Forum Index -> StarBurn SDK
View previous topic :: View next topic  
AuthorMessage
SpinDoctor



Joined: 08 Jul 2004
Posts: 51
Location: Germany

PostPosted: Mon Jul 26, 2004 1:34 pm    Post subject: Copy Audio CD #2

Hi again.
I changed my "Copy Audio CD" source as told. This is (pseudo) what I do:


for each track on source-disc
{
StarBurn_CdvdBurnerGrabber_GrabTrack(...);
}

StarBurn_CdvdBurnerGrabber_SetBUP( Writer, ... );

StarBurn_CdvdBurnerGrabber_SendOPC( Writer, ... );

for each track from HD
{
StarBurn_CdvdBurnerGrabber_TrackAtOnceFromFile(..., IsXA = FALSE, IsNextSessionAllowed = TRUE, ...);
}

StarBurn_CdvdBurnerGrabber_CloseSession( Writer, ... );


My questions now:

1) Is this the way, you would do it (as in Grab&Burn)?
2) Do I have to send BUP/OPC for each track or only once?
3) Each of the copied tracks is 2 seconds longer as the original, how can I manually change the gap? (sometimes the gap is wanted, sometimes not!) I could decide it from the source-disc-information (starting- and ending time...)

Best wishes from here and many thanks
Spin
Back to top
anton (staff)
Site Admin


Joined: 18 Jun 2004
Posts: 1459
Location: Ukraine

PostPosted: Mon Jul 26, 2004 8:28 pm    Post subject: Re: Copy Audio CD #2

Welll... Very close Smile Except we're trying to use Disc-At-Once or Session-At-Once if possible. But this should not be so important for you.

You need to send OPC and enable BUP only once. In the very beginning, before writing first track.

For avoiding gaps you may wish to use Session-At-Once or Disc-At-Once burning mode. Track-At-Once is not very flexible in setting track-to-track pause.

SpinDoctor wrote:
Hi again.
I changed my "Copy Audio CD" source as told. This is (pseudo) what I do:


for each track on source-disc
{
StarBurn_CdvdBurnerGrabber_GrabTrack(...);
}

StarBurn_CdvdBurnerGrabber_SetBUP( Writer, ... );

StarBurn_CdvdBurnerGrabber_SendOPC( Writer, ... );

for each track from HD
{
StarBurn_CdvdBurnerGrabber_TrackAtOnceFromFile(..., IsXA = FALSE, IsNextSessionAllowed = TRUE, ...);
}

StarBurn_CdvdBurnerGrabber_CloseSession( Writer, ... );


My questions now:

1) Is this the way, you would do it (as in Grab&Burn)?
2) Do I have to send BUP/OPC for each track or only once?
3) Each of the copied tracks is 2 seconds longer as the original, how can I manually change the gap? (sometimes the gap is wanted, sometimes not!) I could decide it from the source-disc-information (starting- and ending time...)

Best wishes from here and many thanks
Spin

_________________
Regards,
Anton Kolomyeytsev

Rocket Division Software
Back to top
SpinDoctor



Joined: 08 Jul 2004
Posts: 51
Location: Germany

PostPosted: Mon Jul 26, 2004 8:31 pm    Post subject: Re: Copy Audio CD #2

anton (staff) wrote:
For avoiding gaps you may wish to use Session-At-Once or Disc-At-Once burning mode. Track-At-Once is not very flexible in setting track-to-track pause.


...but this doesn't work on CD-RW, does it?
Back to top
anton (staff)
Site Admin


Joined: 18 Jun 2004
Posts: 1459
Location: Ukraine

PostPosted: Mon Jul 26, 2004 8:58 pm    Post subject: Re: Copy Audio CD #2

Should work fine! Unless I did add 2 second pauses...

SpinDoctor wrote:
anton (staff) wrote:
For avoiding gaps you may wish to use Session-At-Once or Disc-At-Once burning mode. Track-At-Once is not very flexible in setting track-to-track pause.


...but this doesn't work on CD-RW, does it?

_________________
Regards,
Anton Kolomyeytsev

Rocket Division Software
Back to top
SpinDoctor



Joined: 08 Jul 2004
Posts: 51
Location: Germany

PostPosted: Mon Jul 26, 2004 9:09 pm    Post subject: the (nearly) complete source...

m_stMediaEntry is of kind MEDIA_ENTRY.
m_bProcessing is an instance-variable, set by the dialogs cancel-button...
for ease (temporary), I only process Audio-Tracks...
m_iTracks is a variable to hold the number of grabed tracks (might differ from m_stMediaEntry.stTOC_INFORMATION.m__UCHAR__NumberOfTracks because of filtering the Data-Tracks)
As you can see, I "abuse" my own CopyCallback-Function and send a TrackBegin/TrackEnd notification (it's "historical" - I once grabbed the whole disc...)

1) creating wav's (simple)
Code:
          nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Create( &astCDEntry[ m_iSourceDrive ].pvDiscObject,
                                                                ( PCHAR )( &szExceptionText ),
                                                                sizeof( szExceptionText ),
                                                                &lStatus,
                                                                &stCDB_FAILURE_INFORMATION,
                                                                ( PCALLBACK )( CopyCallback ),
                                                                this,
                                                                astCDEntry[ m_iSourceDrive ].ucPortID,
                                                                astCDEntry[ m_iSourceDrive ].ucBusID,
                                                                astCDEntry[ m_iSourceDrive ].ucTargetID,
                                                                astCDEntry[ m_iSourceDrive ].ucLUN,
                                                                0 /* DEFAULT_CACHE_SIZE_IN_MBS */             );

          if ( nEXCEPTION_NUMBER != EN_SUCCESS || astCDEntry[ m_iSourceDrive ].pvDiscObject == NULL )
            {
              break;
            }

          lStatus = ERROR_SUCCESS;
          nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SetSpeeds( astCDEntry[ m_iSourceDrive ].pvDiscObject,
                                                                    ( PCHAR )( &szExceptionText ),
                                                                    sizeof( szExceptionText ),
                                                                    &lStatus,
                                                                    &stCDB_FAILURE_INFORMATION,
                                                                    m_pSettings->uiCopyCDReadSpeed,
                                                                    0xFFFF );

          if ( nEXCEPTION_NUMBER != EN_SUCCESS )
            {
              break;
            }

          lStatus = ERROR_SUCCESS;
          nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Lock( astCDEntry[ m_iSourceDrive ].pvDiscObject,
                                                              ( PCHAR )( &szExceptionText ),
                                                              sizeof( szExceptionText ),
                                                              &lStatus,
                                                              &stCDB_FAILURE_INFORMATION                   );


          if ( nEXCEPTION_NUMBER != EN_SUCCESS )
            {
              break;
            }

          for ( int i = 0; m_bProcessing && i             {
              if ( m_stMediaEntry.stTOC_INFORMATION.m__TOC_ENTRY[ i ].m__BOOLEAN__IsValid )
                {
                  if ( m_stMediaEntry.stTOC_INFORMATION.m__TOC_ENTRY[ i ].m__BOOLEAN__IsAudio )
                    {
                      // grab this track
                      char szFilename[ MAX_PATH ];
                     
                      sprintf( szFilename, "%s\\Track%02i.wav", m_pSettings->szCopyCDBufferPath, i + 1 );
                     
                      ULONG ulTrack = i + 1;
                      CopyCallback( CN_CDVD_TRACK_BEGIN, this, ( PVOID )&ulTrack, NULL );
                     
                      lStatus = ERROR_SUCCESS;
                      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_GrabTrack( astCDEntry[ m_iSourceDrive ].pvDiscObject,
                                                                                ( PCHAR )( &szExceptionText ),
                                                                                sizeof( szExceptionText ),
                                                                                &lStatus,
                                                                                &stCDB_FAILURE_INFORMATION,
                                                                                i + 1,
                                                                                szFilename,
                                                                                10, //+++NUMBER_OF_READ_RETRIES,
                                                                                FALSE, //+++ IsBadBlockIgnore
                                                                                FALSE,  //+++ IsSingleLBTransferForced
                                                                                1 ); //+++READ_REPORT_DELAY_IN_SECONDS
                                                                           
                      CopyCallback( CN_CDVD_TRACK_END, this, ( PVOID )&ulTrack, NULL );

                      m_iTracks++;
                    }
                }
       
      StarBurn_CdvdBurnerGrabber_Release( astCDEntry[ m_iSourceDrive ].pvDiscObject,
                                          ( PCHAR )( &szExceptionText ),
                                          sizeof( szExceptionText ),
                                          &lStatus,
                                          &stCDB_FAILURE_INFORMATION                     );

      if ( m_iDestinationDrive == m_iSourceDrive )
        {
          StarBurn_CdvdBurnerGrabber_Eject( astCDEntry[ m_iSourceDrive ].pvDiscObject,
                                            ( PCHAR )( &szExceptionText ),
                                            sizeof( szExceptionText ),
                                            &lStatus,
                                            &stCDB_FAILURE_INFORMATION                     );
                                           
          CString s;
         
          s.Format( "Please remove the source-disc from drive %s and insert a blank disc!", astCDEntry[ m_iSourceDrive ].szDeviceName );
          if ( AfxMessageBox( s, MB_OKCANCEL ) != IDOK )
            {
              break;
            }
        }
       
      StarBurn_Destroy( &astCDEntry[ m_iSourceDrive ].pvDiscObject );
      astCDEntry[ m_iSourceDrive ].pvDiscObject = NULL;



2) write them to disc (also simple)

Code:
      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Create( &astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                            ( PCHAR )( &szExceptionText ),
                                                            sizeof( szExceptionText ),
                                                            &lStatus,
                                                            &stCDB_FAILURE_INFORMATION,
                                                            ( PCALLBACK )( WriteCallback ),
                                                            this,
                                                            astCDEntry[ m_iDestinationDrive ].ucPortID,
                                                            astCDEntry[ m_iDestinationDrive ].ucBusID,
                                                            astCDEntry[ m_iDestinationDrive ].ucTargetID,
                                                            astCDEntry[ m_iDestinationDrive ].ucLUN,
                                                            0 /* DEFAULT_CACHE_SIZE_IN_MBS */             );

      if ( nEXCEPTION_NUMBER != EN_SUCCESS || astCDEntry[ m_iDestinationDrive ].pvDiscObject == NULL )
        {
          break;
        }

      lStatus = ERROR_SUCCESS;
      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SetSpeeds( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                                ( PCHAR )( &szExceptionText ),
                                                                sizeof( szExceptionText ),
                                                                &lStatus,
                                                                &stCDB_FAILURE_INFORMATION,
                                                                0xFFFF,
                                                                m_pSettings->uiCopyCDWriteSpeed );
                                                         
      lStatus = ERROR_SUCCESS;
      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Lock( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                          ( PCHAR )( &szExceptionText ),
                                                          sizeof( szExceptionText ),
                                                          &lStatus,
                                                          &stCDB_FAILURE_INFORMATION                   );

      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_GetBUP( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                             ( PCHAR )( &szExceptionText ),
                                                             sizeof( szExceptionText ),
                                                             &lStatus,
                                                             &stCDB_FAILURE_INFORMATION,
                                                             &bBUPEnabled,
                                                             &bBUPSupported             );

      if ( nEXCEPTION_NUMBER != EN_SUCCESS )
        {
          break;
        }

      if ( bBUPSupported && !bBUPEnabled )
        {
          nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SetBUP( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                                 ( PCHAR )( &szExceptionText ),
                                                                 sizeof( szExceptionText ),
                                                                 &lStatus,
                                                                 &stCDB_FAILURE_INFORMATION,
                                                                 TRUE                                             );

          if ( nEXCEPTION_NUMBER != EN_SUCCESS )
            {
              break;
            }
        }

      //
      // Try to send OPC
      //
      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SendOPC( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                              ( PCHAR )( &szExceptionText ),
                                                              sizeof( szExceptionText ),
                                                              &lStatus,
                                                              &stCDB_FAILURE_INFORMATION             );

      if ( nEXCEPTION_NUMBER != EN_SUCCESS )
        {
          //+++ don't break!
          //break;
        }

      for ( int i = 0; m_bProcessing && i         {
          char szFilename[ MAX_PATH ];
         
          sprintf( szFilename, "%s\\Track%02i.wav", m_pSettings->szCopyCDBufferPath, i + 1 );
         
          lStatus = ERROR_SUCCESS;
          nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_TrackAtOnceFromFile( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                                              ( PCHAR )( &szExceptionText ),
                                                                              sizeof( szExceptionText ),
                                                                              &lStatus,
                                                                              &stCDB_FAILURE_INFORMATION,
                                                                              szFilename,
                                                                              FALSE, // CD-X
                                                                              FALSE, // test
                                                                              TRUE,  // next session
                                                                              1,
                                                                              1 );
                                                                             
          if ( nEXCEPTION_NUMBER != EN_SUCCESS )
            {
              break;
            }

          DoMessageLoop( this );
        }

      nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_CloseSession( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
                                                                   ( PCHAR )( &szExceptionText ),
                                                                   sizeof( szExceptionText ),
                                                                   &lStatus,
                                                                   &stCDB_FAILURE_INFORMATION             );





and so on...destroying objects...
between the code-fragments may be some more code (testing for success and some more GUI-stuff, of course)

why does the resulting disc have 1 session with 0 tracks???
Back to top
SpinDoctor



Joined: 08 Jul 2004
Posts: 51
Location: Germany

PostPosted: Tue Jul 27, 2004 7:49 am    Post subject: show me the way..

OK, then.
In order to avoid the gaps, I will have to probe the write modes before burning and then try to write DAO or SAO or TAO (in this order...).

the question now is:

wich functions do I use for each task?
(writing TAO is already implemented and works (with the known disadvantages) )
but what's up with DAO/SAO ???

I tried something like:

StarBurn_ISO9660JolietFileTree_Create( ... );
StarBurn_ISO9660JolietFileTree_Add( ..., pszPathWhereTheTracksAreStored, ... )
StarBurn_CdvdBurnerGrabber_GetTrackInformation( ..., TRACK_NUMBER_INVISIBLE, ... );
StarBurn_ISO9660JolietFileTree_BuildImage( ... );
StarBurn_CdvdBurnerGrabber_DiscAtOnceRawPWFromTree( ... )


...but the resulting disc looks more like a data-disc with the whole directory structure and does not have much to do with the original (beside other things, it's not playable in a player)...

Having a set of wav's - how do I create an Audio CD (with *.cda's in a flat directory) either in DAO or SAO ????? (looking through the samples, and doing it with trial and error will surely take more time than it will take, if you simply tell me things like: "call StarBurn... in order to..., then call ...") (remember, I do not deal with any kinda DVD, Data-discs or copy-protections...only Audio-CD's are of interest...maybe mixed-mode ones with data-tracks on it...)

show me the way, please
Spin
Back to top
anton (staff)
Site Admin


Joined: 18 Jun 2004
Posts: 1459
Location: Ukraine

PostPosted: Tue Jul 27, 2004 3:00 pm    Post subject: Re: show me the way..

You're getting data disc just b/s you're asking the library to create data disc Smile If you need to have AudioCD you need to look at DiscAtOnceFromFile and SessionAtOnceFromFile samples. And just pass a structure with filled WAV file names to StarBurn_CdvdBurnerGrabber_Disc(Session)AtOnceFromFile and not XxxFromTree. And you'll get AudioCD.

However you do not need to dump current code -- just use it to create so called "MP3 AudioCD". Data CD with individial MP3/WMA files. Quite a lot of stand alone devices (esp. car audio) accept compressed audio data CDs.

And I'm still checking your "0 track" issue. Can you try to write the code in the way you'll not allow next session? AudioCD are expected to be CLOSED (no next session possible). Stand alone boxes can skip opened AudioCDs and refuse to play them. FYI.

SpinDoctor wrote:
OK, then.
In order to avoid the gaps, I will have to probe the write modes before burning and then try to write DAO or SAO or TAO (in this order...).

the question now is:

wich functions do I use for each task?
(writing TAO is already implemented and works (with the known disadvantages) )
but what's up with DAO/SAO ???

I tried something like:

StarBurn_ISO9660JolietFileTree_Create( ... );
StarBurn_ISO9660JolietFileTree_Add( ..., pszPathWhereTheTracksAreStored, ... )
StarBurn_CdvdBurnerGrabber_GetTrackInformation( ..., TRACK_NUMBER_INVISIBLE, ... );
StarBurn_ISO9660JolietFileTree_BuildImage( ... );
StarBurn_CdvdBurnerGrabber_DiscAtOnceRawPWFromTree( ... )


...but the resulting disc looks more like a data-disc with the whole directory structure and does not have much to do with the original (beside other things, it's not playable in a player)...

Having a set of wav's - how do I create an Audio CD (with *.cda's in a flat directory) either in DAO or SAO ????? (looking through the samples, and doing it with trial and error will surely take more time than it will take, if you simply tell me things like: "call StarBurn... in order to..., then call ...") (remember, I do not deal with any kinda DVD, Data-discs or copy-protections...only Audio-CD's are of interest...maybe mixed-mode ones with data-tracks on it...)

show me the way, please
Spin

_________________
Regards,
Anton Kolomyeytsev

Rocket Division Software
Back to top
SpinDoctor



Joined: 08 Jul 2004
Posts: 51
Location: Germany

PostPosted: Tue Jul 27, 2004 3:52 pm    Post subject: Re: show me the way..

anton (staff) wrote:
You're getting data disc just b/s you're asking the library to create data disc


didn't knew I did so... Confused Very Happy

the rest sounds simple...maybe 2 questions:

1) Can I vary the gaps between the tracks from 0 to ? seconds in the DiscLayoutStructure?
2) What's the difference between StarBurn_CdvdBurnerGrabber_DiscAtOnceRawPWFromFile and StarBurn_CdvdBurnerGrabber_DiscAtOncePQFromFile ?
3) Havn't found a sample for writing multiple (wav-)files with SessionAtOnce_FromFile??

anton (staff) wrote:
And I'm still checking your "0 track" issue. Can you try to write the code in the way you'll not allow next session? AudioCD are expected to be CLOSED (no next session possible). Stand alone boxes can skip opened AudioCDs and refuse to play them.


That's it! I now call StarBurn_CdvdBurnerGrabber_TrackAtOnceFromFile with FALSE for p__BOOLEAN__IsNextSessionAllowed and the resulting disc is OK...I think, there is no (more) need for an explicit StarBurn_CdvdBurnerGrabber_CloseSession, is it?

Many thanks
Spin
Back to top
SpinDoctor



Joined: 08 Jul 2004
Posts: 51
Location: Germany

PostPosted: Tue Jul 27, 2004 10:41 pm    Post subject: got it!

just made my first "1:1" copy from an Audio CD with:

StarBurn_CdvdBurnerGrabber_DiscAtOnceRawPWFromFile and
TRUE for MODE2/Form1 and
TRUE for Do NOT repair broken subchannel

that's it!
The source disc was a classic one with "smooth" track changes (no gap at all) and the resulting disc is an exact copy (starting and ending LBA's are exactly the same) - even CDDB says so!

what do you think, may I resume that all writers of the end-users should support DAO or do I also have to deal with the need of writing SAO ???

anyway...subtracting the time, needed for all the GUI-stuff and all the time, that I needed, to understand the API and also to understand the samples (I'm great as an application programmer but I'm the greatest SCSI-Dummy world ever seen), I implemented a simple "Copy Audio CD" functionality in a few hours work (me, as an SCSI/Audio CD/CD Writer-Dummy!!)...THAT IS GREAT!!!!!

congratualions on you and good night
Spin
Back to top
anton (staff)
Site Admin


Joined: 18 Jun 2004
Posts: 1459
Location: Ukraine

PostPosted: Wed Jul 28, 2004 8:04 am    Post subject: Re: show me the way..

1) No, it's not currenlty supported. Actually you're the first one who have asked for longer pauses between tracks Smile

2) 96 or 16 bytes of subchannel data. Old devices support only 16 bytes or subchannel. Newer ones either both or only 96. You need to probe write modes and pick up supported method. That's all...

3) I think SessionAtOnceFromFile is required sample Smile

4) No, you still need to call _CloseSession(...) after all of the tracks are written in the Track-At-Once mode sequentially.

SpinDoctor wrote:
anton (staff) wrote:
You're getting data disc just b/s you're asking the library to create data disc


didn't knew I did so... Confused Very Happy

the rest sounds simple...maybe 2 questions:

1) Can I vary the gaps between the tracks from 0 to ? seconds in the DiscLayoutStructure?
2) What's the difference between StarBurn_CdvdBurnerGrabber_DiscAtOnceRawPWFromFile and StarBurn_CdvdBurnerGrabber_DiscAtOncePQFromFile ?
3) Havn't found a sample for writing multiple (wav-)files with SessionAtOnce_FromFile??

anton (staff) wrote:
And I'm still checking your "0 track" issue. Can you try to write the code in the way you'll not allow next session? AudioCD are expected to be CLOSED (no next session possible). Stand alone boxes can skip opened AudioCDs and refuse to play them.


That's it! I now call StarBurn_CdvdBurnerGrabber_TrackAtOnceFromFile with FALSE for p__BOOLEAN__IsNextSessionAllowed and the resulting disc is OK...I think, there is no (more) need for an explicit StarBurn_CdvdBurnerGrabber_CloseSession, is it?

Many thanks
Spin

_________________
Regards,
Anton Kolomyeytsev

Rocket Division Software
Back to top
anton (staff)
Site Admin


Joined: 18 Jun 2004
Posts: 1459
Location: Ukraine

PostPosted: Wed Jul 28, 2004 8:12 am    Post subject: Re: got it!

Congratulations! Looks like I've forgot I've implemented multitrack DAO Smile

Quite a lot of DVD burners do not support DAO at all (only newer ones do). First generation can hardly made raw SAO also (PIONEERs up to 104). That's why I've recommended you to stick with track-by-track copy of grabbed WAV files -- this way is expected to work virtually everywhere (I do not know where it can *NOT* work).

Good luck with your software! Smile

Thanks!

SpinDoctor wrote:
just made my first "1:1" copy from an Audio CD with:

StarBurn_CdvdBurnerGrabber_DiscAtOnceRawPWFromFile and
TRUE for MODE2/Form1 and
TRUE for Do NOT repair broken subchannel

that's it!
The source disc was a classic one with "smooth" track changes (no gap at all) and the resulting disc is an exact copy (starting and ending LBA's are exactly the same) - even CDDB says so!

what do you think, may I resume that all writers of the end-users should support DAO or do I also have to deal with the need of writing SAO ???

anyway...subtracting the time, needed for all the GUI-stuff and all the time, that I needed, to understand the API and also to understand the samples (I'm great as an application programmer but I'm the greatest SCSI-Dummy world ever seen), I implemented a simple "Copy Audio CD" functionality in a few hours work (me, as an SCSI/Audio CD/CD Writer-Dummy!!)...THAT IS GREAT!!!!!

congratualions on you and good night
Spin

_________________
Regards,
Anton Kolomyeytsev

Rocket Division Software
Back to top
      RocketDivision.Com Forum Index -> StarBurn SDK
Page 1 of 1