Subversion Repositories Kolibri OS

Rev

Rev 333 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 333 Rev 342
Line 46... Line 46...
46
#include "m_misc.h"
46
#include "m_misc.h"
47
#include "w_wad.h"
47
#include "w_wad.h"
Line 48... Line 48...
48
 
48
 
Line -... Line 49...
-
 
49
#include "doomdef.h"
-
 
50
 
49
#include "doomdef.h"
51
#include "kolibri.h"
50
 
52
 
51
// The number of internal mixing channels,
53
// The number of internal mixing channels,
52
//  the samples calculated for each mixing step,
54
//  the samples calculated for each mixing step,
Line 53... Line 55...
53
//  the size of the 16bit, 2 hardware channel (stereo)
55
//  the size of the 16bit, 2 hardware channel (stereo)
54
//  mixing buffer, and the samplerate of the raw data.
56
//  mixing buffer, and the samplerate of the raw data.
55
 
57
 
56
 
58
 
57
// Needed for calling the actual sound output.
59
// Needed for calling the actual sound output.
58
#define SAMPLECOUNT             512
60
#define SAMPLECOUNT     8192
Line 330... Line 332...
330
  for (i=0; i
332
  for (i=0; i
331
  {
333
  {
332
    channels[i] = 0;
334
    channels[i] = 0;
333
  }
335
  }
Line 334... Line 336...
334
 
336
 
335
//  for (i=-128 ; i<128 ; i++)
337
  for (i=-128 ; i<128 ; i++)
Line 336... Line 338...
336
//    steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
338
    steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0);
337
  
339
  
338
  // Generates volume lookup tables
340
  // Generates volume lookup tables
339
  //  which also turn the unsigned samples
341
  //  which also turn the unsigned samples
Line 421... Line 423...
421
//  contents of the mixbuffer to the (two)
423
//  contents of the mixbuffer to the (two)
422
//  hardware channels (left and right, that is).
424
//  hardware channels (left and right, that is).
423
//
425
//
424
// This function currently supports only 16bit.
426
// This function currently supports only 16bit.
425
//
427
//
-
 
428
 
-
 
429
extern DWORD hMixBuff[4];
-
 
430
extern int mix_ptr;
-
 
431
 
426
void I_UpdateSound( void )
432
void I_UpdateSound( void )
427
{
433
{
Line 428... Line 434...
428
  
434
  
429
  // Mix current sound data.
435
  // Mix current sound data.
Line 439... Line 445...
439
  // Step in mixbuffer, left and right, thus two.
445
  // Step in mixbuffer, left and right, thus two.
440
  int                           step;
446
  int                           step;
Line 441... Line 447...
441
 
447
 
442
  // Mixing channel index.
448
  // Mixing channel index.
-
 
449
  int                           chan;
-
 
450
  int i;
-
 
451
  int flags;
Line 443... Line 452...
443
  int                           chan;
452
  flags = 0;
444
    
453
    
445
    // Left and right channel
454
    // Left and right channel
446
    //  are in global mixbuffer, alternating.
455
    //  are in global mixbuffer, alternating.
Line 453... Line 462...
453
    leftend = mixbuffer + SAMPLECOUNT*step;
462
    leftend = mixbuffer + SAMPLECOUNT*step;
Line 454... Line 463...
454
 
463
 
455
    // Mix sounds into the mixing buffer.
464
    // Mix sounds into the mixing buffer.
456
    // Loop over step*SAMPLECOUNT,
465
    // Loop over step*SAMPLECOUNT,
457
    //  that is 512 values for two channels.
466
    //  that is 512 values for two channels.
458
    while (leftout != leftend)
467
    for (i=0; i < 8192; i++)
459
    {
468
    {
460
        // Reset left/right value. 
469
        // Reset left/right value. 
461
        dl = 0;
470
        dl = 0;
Line 467... Line 476...
467
        for ( chan = 0; chan < NUM_CHANNELS; chan++ )
476
        for ( chan = 0; chan < NUM_CHANNELS; chan++ )
468
        {
477
        {
469
            // Check channel, if active.
478
            // Check channel, if active.
470
            if (channels[ chan ])
479
            if (channels[ chan ])
471
            {
480
            {
-
 
481
                flags=1;
-
 
482
                
472
                // Get the raw data from the channel. 
483
                // Get the raw data from the channel. 
473
                sample = *channels[ chan ];
484
                sample = *channels[ chan ];
474
                // Add left and right part
485
                // Add left and right part
475
                //  for this channel (sound)
486
                //  for this channel (sound)
476
                //  to the current data.
487
                //  to the current data.
Line 513... Line 524...
513
 
524
 
514
        // Increment current pointers in mixbuffer.
525
        // Increment current pointers in mixbuffer.
515
        leftout += step;
526
        leftout += step;
516
        rightout += step;
527
        rightout += step;
-
 
528
    }
-
 
529
    if(flags)
517
    }
530
    { WaveOut(hMixBuff[mix_ptr],(char*)&mixbuffer[0],32768);
-
 
531
      mix_ptr= (mix_ptr+1)&3;
518
 //   I_SubmitSound(mixbuffer);
532
    };  
Line 519... Line 533...
519
}
533
}
520
 
534