English Amiga Board


Go Back   English Amiga Board > Coders > Coders. System

 
 
Thread Tools
Old 08 January 2017, 02:22   #1
LuigiThirty
Registered User
 
Join Date: Dec 2016
Location: USA
Posts: 101
Looking inside a directory: The final frontier

I'm making a little tool to search through my Protracker sample files and I'm a little confused about dos.library. I want to create a list of the files in a directory. I'm passing in an Exec list and a path ("ST-XX:ST-01") to this function:

Code:
void DoSearch(struct List *resultsList, UBYTE *dirName){
    BPTR dirLock = Lock((STRPTR)dirName, ACCESS_READ);
    if(BADDR(dirLock) == NULL){
        printf("Couldn't obtain lock on %s!\n", dirName);
        return;
    }
    
    struct FileInfoBlock *fib = AllocDosObject(DOS_FIB, TAG_DONE);
    if(Examine(dirLock, fib)){
        /* make a Node and add it to resultsList, then ExNext(dirLock, fib) and do the same until out of locks */        
    }
}
But Examine() is giving me the actual directory object on the hard drive. I need to traverse into it. Right now ExNext just gives me ST-01, ST-02, ST-03... instead of the contents of the ST-01 folder. I'm obviously overlooking something... what do I need to do to get a lock on the first file inside the folder with the assumption that I don't know the filename?
LuigiThirty is offline  
Old 08 January 2017, 03:39   #2
LuigiThirty
Registered User
 
Join Date: Dec 2016
Location: USA
Posts: 101
Nevermind, I had a typo that was making ExNext not work properly... you can lock/delete this thread.
LuigiThirty is offline  
Old 08 January 2017, 04:50   #3
Pat the Cat
Banned
 
Join Date: Dec 2016
Location: Nottingham, UK
Posts: 481
I guess it's a pretty big collection.

I usually just search by hand with wildcards at the Shell, but I understand that's a pretty basic way of trying to organize big complex things. Like mod collections.
Pat the Cat is offline  
Old 08 January 2017, 06:00   #4
LuigiThirty
Registered User
 
Join Date: Dec 2016
Location: USA
Posts: 101
Quote:
Originally Posted by Pat the Cat View Post
I guess it's a pretty big collection.

I usually just search by hand with wildcards at the Shell, but I understand that's a pretty basic way of trying to organize big complex things. Like mod collections.
Yeah, I've got the whole set from ST-01 to ST-4F or whatever it was. It's a lot of files. It's basically just a way for me to learn Gadtools.
LuigiThirty is offline  
Old 08 January 2017, 20:17   #5
LuigiThirty
Registered User
 
Join Date: Dec 2016
Location: USA
Posts: 101
Playing the 8SVX samples is easy enough with datatypes.library but I'm having some trouble with audio.device trying to play the raw 8-bit PCM samples. I'm following the example in the Devices manual but can't seem to get my sample to play. All this code does is freeze the application at WaitPort. The sample I have is 9900 bytes long, is that too long for audio.device to play in one shot?

Code:
void PB_PlayPCM(char *fileName){
    //Open the file and load it into chipmem.
    BPTR audioFile = Open(fileName, MODE_OLDFILE);
    BYTE *pcmData = (BYTE*)AllocMem(16384, MEMF_CHIP|MEMF_CLEAR); //TODO: get actual size. one i'm testing is 9900 bytes
    LONG sampleCount = Read(audioFile, pcmData, 16384);
    printf("Loaded %s as %d samples at %p. Playing as raw 8-bit PCM.\n", fileName, sampleCount, pcmData);

    UBYTE channelPriority[] = { 1, 2, 4, 8 }; //request any available channel
    struct IOAudio *AudioIO; //I/O block for I/O commands
    struct MsgPort *AudioMP; //Message port for replies
    struct Message *AudioMSG;//Reply message ptr

    ULONG device;
    LONG clock = 3579545; //NTSC
    LONG frequency = 440; //reference frequency
    LONG duration;
    LONG sampleCycles = 1; //cycle count

    //Set up AudioIO to access the audio device.
    AudioIO = (struct IOAudio *)AllocMem(sizeof(struct IOAudio), MEMF_PUBLIC|MEMF_CLEAR);
    if(AudioIO == NULL){
        printf("Error initializing AudioIO\n");
        return;
    }

    //Create the reply port
    AudioMP = CreatePort(0, 0);
    if(AudioMP == NULL){
        printf("Error creating AudioMP\n");
        return;
    }

    //Set up the I/O block
    AudioIO->ioa_Request.io_Message.mn_ReplyPort    = AudioMP;
    AudioIO->ioa_Request.io_Message.mn_Node.ln_Pri  = 0;
    AudioIO->ioa_Request.io_Command                 = ADCMD_ALLOCATE;
    AudioIO->ioa_Request.io_Flags                   = ADIOF_NOWAIT;
    AudioIO->ioa_AllocKey                           = 0;
    AudioIO->ioa_Data                               = channelPriority;
    AudioIO->ioa_Length                             = sizeof(channelPriority);
    printf("I/O block initialized. Trying to open the audio device.\n");

    device = OpenDevice(AUDIONAME, 0L, (struct IORequest *)AudioIO, 0L);
    if(device != 0){
        printf("Error opening audio device.\n");
        return;
    }
    printf("Device %s opened. Allocated a channel.\n", AUDIONAME);

    //Set up the Audio I/O block to play our sound
    AudioIO->ioa_Request.io_Message.mn_ReplyPort    = AudioMP;
    AudioIO->ioa_Request.io_Command                 = CMD_WRITE;
    AudioIO->ioa_Request.io_Flags                   = ADIOF_PERVOL;
    AudioIO->ioa_Data                               = pcmData;
    AudioIO->ioa_Length                             = sampleCount;
    AudioIO->ioa_Period                             = clock*sampleCycles/(sampleCount*frequency);
    AudioIO->ioa_Volume                             = 64;
    AudioIO->ioa_Cycles                             = 1;

    printf("Playing PCM sound %s\n", fileName);
    BeginIO((struct IORequest *)AudioIO);
    WaitPort(AudioMP);
    AudioMSG = GetMsg(AudioMP);

    printf("Sound finished playing\n");

    if(pcmData != 0) FreeMem(pcmData, sampleCount);
    if(device == 0)  CloseDevice((struct IORequest *)AudioIO);
    if(AudioMP != 0) DeletePort(AudioMP);
    if(AudioIO != 0) FreeMem(AudioIO, sizeof(struct IOAudio));
}
LuigiThirty is offline  
Old 09 January 2017, 09:55   #6
voxel
Amiga Nuts!
 
voxel's Avatar
 
Join Date: Sep 2006
Location: Le Mayet d'Ecole, 03800, FRANCE
Posts: 176
Happy st-xx disks :)

Quote:
Originally Posted by LuigiThirty View Post
Yeah, I've got the whole set from ST-01 to ST-4F or whatever it was. It's a lot of files.
Do you still have all these disks ? at least as adf files ?

I never had the opportunity to collect all the st-xxx disks (i'm sure I'm not the sole in this case) so it would be very cool if you could send it all to "the zone" or an ftp so we can get it ^^)

Thanks a lot by advance


61
voxel is offline  
Old 09 January 2017, 12:19   #7
Anakirob
Unregistered User
 
Anakirob's Avatar
 
Join Date: Nov 2005
Location: Tasmania
Age: 42
Posts: 893
Lha's of all the ST sample disks can be found on Aminet.
Anakirob is offline  
Old 10 January 2017, 10:55   #8
voxel
Amiga Nuts!
 
voxel's Avatar
 
Join Date: Sep 2006
Location: Le Mayet d'Ecole, 03800, FRANCE
Posts: 176
thanks for the tip (had forgotten about it) ^^)

btw, there is st-01 to st-b6 (116 disks) only there.

do yours really go upto st-4F ???
voxel is offline  
Old 10 January 2017, 15:02   #9
LuigiThirty
Registered User
 
Join Date: Dec 2016
Location: USA
Posts: 101
I've got the Aminet package of disks. I also got PCM audio playback working in my program!
LuigiThirty is offline  
Old 11 January 2017, 11:08   #10
voxel
Amiga Nuts!
 
voxel's Avatar
 
Join Date: Sep 2006
Location: Le Mayet d'Ecole, 03800, FRANCE
Posts: 176
cool ! I'll be happy to betatest your soft (have all amigas there, classic and NG) ^^)
voxel is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Star Trek V: The Final Frontier derSammler project.aGTW 13 09 June 2023 10:00
FinalWriter 97; FinalCalc 1.04; Final Data 2.00 & Final Copy aebrown-u request.Apps 20 12 July 2009 11:19
Directory Opus 4.12 Final Blip request.Apps 13 16 November 2008 18:38
carvup final frontier ???? turrican3 request.Old Rare Games 37 09 February 2008 14:57
CarVup: The Final Frontier jrom request.Old Rare Games 3 18 June 2006 11:57

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 13:31.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.07650 seconds with 13 queries