home *** CD-ROM | disk | FTP | other *** search
/ Large Pack of OldSkool DOS MOD Trackers / beaversweeper_v101.zip / src / DSPEffectTemplate.cpp < prev    next >
C/C++ Source or Header  |  2003-01-06  |  4KB  |  185 lines

  1. // DSPEffectTemplate.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tracker.h"
  6.  
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. #include "DSPEffectTemplate.h"
  14. #include "isStereoFX.h"
  15. #include "isEffectChain.h"
  16. #include "SendFxChorus.h"
  17. #include "SendFxDelay.h"
  18.  
  19. #include <mmsystem.h>
  20. #include "isPlayer.h"
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CDSPEffectTemplate dialog
  24.  
  25.  
  26. CDSPEffectTemplate::CDSPEffectTemplate(CWnd* pParent /*=NULL*/)
  27.     : CDialog(CDSPEffectTemplate::IDD, pParent)
  28. {
  29.     //{{AFX_DATA_INIT(CDSPEffectTemplate)
  30.         // NOTE: the ClassWizard will add member initialization here
  31.     //}}AFX_DATA_INIT
  32.  
  33.     m_chain = 0;
  34.     m_chainpos = 0;
  35.     m_current_insert = 0;
  36.     m_current_fx = 0;
  37.     m_player = 0;
  38. }
  39.  
  40.  
  41.  
  42. void CDSPEffectTemplate::DoDataExchange(CDataExchange* pDX)
  43. {
  44.     CDialog::DoDataExchange(pDX);
  45.     //{{AFX_DATA_MAP(CDSPEffectTemplate)
  46.     DDX_Control(pDX, IDC_COMBO1, m_effect_list);
  47.     //}}AFX_DATA_MAP
  48. }
  49.  
  50.  
  51. BEGIN_MESSAGE_MAP(CDSPEffectTemplate, CDialog)
  52.     //{{AFX_MSG_MAP(CDSPEffectTemplate)
  53.     ON_COMMAND(ID_APP_EXIT, OnAppExit)
  54.     ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  55.     //}}AFX_MSG_MAP
  56. END_MESSAGE_MAP()
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // CDSPEffectTemplate message handlers
  60.  
  61. void CDSPEffectTemplate::setChain( isEffectChain *chain, int chainpos )
  62. {
  63.     m_chain = chain;
  64.     m_chainpos = chainpos;
  65. }
  66.  
  67. void CDSPEffectTemplate::setPlayer( isPlayer *player )
  68. {
  69.     m_player = player;
  70. }
  71.  
  72. BOOL CDSPEffectTemplate::OnInitDialog() 
  73. {
  74.     CDialog::OnInitDialog();
  75.     
  76.     // TODO: Add extra initialization here
  77.     m_effect_list.AddString( _T("No effect") );
  78.     m_effect_list.AddString( _T("Delay") );
  79.     m_effect_list.AddString( _T("Chorus") );
  80.     m_effect_list.SetCurSel(0);
  81.  
  82.     if (m_player)
  83.         m_player->Pause();
  84.     updateInsert();
  85.     if (m_player)
  86.         m_player->Resume();
  87.     
  88.     return TRUE;  // return TRUE unless you set the focus to a control
  89.                   // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91.  
  92. void CDSPEffectTemplate::updateInsert(void)
  93. {
  94.  
  95.     m_current_fx = 0;
  96.  
  97.     if (m_current_insert) {
  98.         delete m_current_insert;
  99.         m_current_insert = 0;
  100.     }
  101.  
  102.     if (!m_chain) {
  103.         return;
  104.     }
  105.  
  106.     m_effect_list.SetCurSel(0);        
  107.  
  108.     // ─ndra m_current_fx
  109.     m_current_fx = m_chain->GetEffect( m_chainpos );
  110.  
  111.     if (!m_current_fx) {
  112.         m_effect_list.SetCurSel( 0 ); // SΣtt "No effect" som vald
  113.         return;
  114.     } else {
  115.         switch (m_current_fx->GetType()) {
  116.             case is_DELAY:
  117.                 m_effect_list.SetCurSel( 1 );
  118.                 m_current_insert = new CSendFxDelay( this );
  119.                 ((CSendFxDelay*) m_current_insert)->setDelay( (isDelay*) m_current_fx );
  120.                 m_current_insert->Create( IDD_SENDFX_DELAY, this );
  121.                 break;
  122.             case is_CHORUS:
  123.                 m_effect_list.SetCurSel( 2 );
  124.                 m_current_insert = new CSendFxChorus( this );
  125.                 ((CSendFxChorus*) m_current_insert)->setChorus( (isChorus*) m_current_fx );
  126.                 m_current_insert->Create( IDD_SENDFX_CHORUS, this );
  127.                 break;
  128.         }
  129.     }
  130.  
  131.     if (!m_current_insert) {
  132.         return;
  133.     }
  134.  
  135.     m_current_insert->SetWindowPos( 0, 160, 7, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW );
  136.  
  137. }
  138.  
  139. void CDSPEffectTemplate::OnAppExit() 
  140. {
  141.     // TODO: Add your command handler code here
  142.     
  143. }
  144.  
  145. BOOL CDSPEffectTemplate::OnCommand(WPARAM wParam, LPARAM lParam) 
  146. {
  147.     // TODO: Add your specialized code here and/or call the base class
  148.     if (wParam == IDCANCEL || wParam == IDOK)
  149.         return FALSE;
  150.     
  151.     return CDialog::OnCommand(wParam, lParam);
  152. }
  153.  
  154. void CDSPEffectTemplate::OnSelchangeCombo1() 
  155. {
  156.     if (m_player)
  157.         m_player->Pause();
  158.  
  159.     if (!m_chain)
  160.         return;
  161.  
  162.     if (m_chain->GetEffect( m_chainpos ))
  163.         m_chain->DelEffect( m_chainpos );
  164.  
  165.     // TODO: Add your control notification handler code here
  166.     int n = m_effect_list.GetCurSel();
  167.     if (n == 1) {
  168.         m_chain->SetEffect( is_DELAY, m_chainpos );
  169.         m_chain->GetEffect( m_chainpos )->Update();
  170.     }
  171.     if (n == 2) {
  172.         m_chain->SetEffect( is_CHORUS, m_chainpos );
  173.         m_chain->GetEffect( m_chainpos )->Update();
  174.     }
  175.  
  176.     m_chain->Update();
  177.  
  178.     updateInsert();
  179.  
  180.     if (m_player)
  181.         m_player->Resume();
  182.  
  183.     
  184. }
  185.