00001 /*! \file 00002 * X-Forge Util <br> 00003 * Copyright 2000-2003 Fathammer Ltd 00004 * 00005 * \brief Toolkit for vibrator effects 00006 * 00007 * $Id: XFuVibratorToolkit.cpp,v 1.9 2003/09/18 10:28:09 mikko Exp $ 00008 * $Date: 2003/09/18 10:28:09 $ 00009 * $Revision: 1.9 $ 00010 */ 00011 #include <xforge.h> 00012 #include <xfcore/XFcVibrate.h> 00013 #include <xfutil/XFuVibratorToolkit.h> 00014 00015 00016 static const UINT8 xfuVibratorPattern[256] = 00017 { 00018 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, 00019 0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0, 00020 0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,0,0,1,0, 00021 0,0,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,1,0,0,1,0,1,0,1,0,1,0,0,1,0, 00022 0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1, 00023 0,1,1,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,1,1, 00024 1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1, 00025 1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 00026 }; 00027 00028 00029 void XFuVibratorToolkit::playDitheredNote(UINT8 aDuration, UINT8 aMagnitude) 00030 { 00031 INT32 offset = ((INT32)aMagnitude) - 8; 00032 INT32 songlength = aDuration; 00033 if (offset < 0) offset = 0; 00034 if (offset > 239) offset = 239; 00035 if (songlength > 500) songlength = 500; 00036 // UINT8 *song = new(XFCMEMORY_TEMPORARY) UINT8[songlength * 2]; 00037 UINT8 *song = new UINT8[songlength * 2]; 00038 if (song == NULL) 00039 return; 00040 INT i, j; 00041 for (i = 0, j = 0; i < songlength; i++) 00042 { 00043 song[i * 2 + 0] = xfuVibratorPattern[j + offset] ? (UINT8)0xff : (UINT8)0; 00044 song[i * 2 + 1] = 1; 00045 j++; 00046 if (j >= 16) 00047 j = 0; 00048 } 00049 XFcVibrate::playSong(song, songlength, 0); 00050 delete[] song; 00051 }
![]() | ||||
![]() |
Confidential Copyright © 2002-2003 Fathammer | with doxygen by Dimitri van Heesch |