[C#/WINFORM/.NET5] 마이크 입력 스펙트로그램 표시하기
■ 마이크 입력 스펙트로그램을 표시하는 방법을 보여준다. ▶ ArgoColorMap.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
using System; namespace TestLibrary { /// <summary> /// 아르고 색상 맵 /// </summary> public class ArgoColorMap : IColorMap { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// RGB 배열 /// </summary> private readonly int[] rgbArray = { 00000000, 00000004, 00000264, 00000267, 00000527, 00000530, 00000789, 00066328, 00066588, 00066591, 00066849, 00132388, 00132647, 00132650, 00132908, 00198447, 00198706, 00198708, 00264503, 00264505, 00330299, 00330557, 00330560, 00396354, 00396612, 00462150, 00462408, 00527946, 00528204, 00593998, 00594000, 00659794, 00660052, 00725590, 00791383, 00791641, 00857435, 00857437, 00923230, 00989024, 00989026, 01054819, 01120613, 01120870, 01186408, 01252201, 01252459, 01318252, 01384046, 01384047, 01449841, 01515634, 01515892, 01581429, 01647222, 01713016, 01713273, 01779066, 01844860, 01910397, 01976190, 01976447, 02042241, 02108034, 02173827, 02239364, 02239621, 02305415, 02371208, 02437001, 02502794, 02568587, 02568844, 02634381, 02700174, 02765968, 02831761, 02897554, 02963347, 03029140, 03029397, 03095190, 03160983, 03226520, 03292313, 03358106, 03423899, 03489692, 03555485, 03621278, 03687071, 03752864, 03818656, 03884449, 03950242, 04016035, 04081828, 04147621, 04147878, 04213671, 04279464, 04345256, 04411049, 04476842, 04542635, 04608428, 04739757, 04805550, 04871342, 04937135, 05002928, 05068721, 05134514, 05200306, 05266099, 05331892, 05397685, 05463477, 05529270, 05595063, 05660856, 05726648, 05792441, 05858234, 05924027, 05989819, 06121148, 06186941, 06252734, 06318526, 06384319, 06450112, 06515904, 06581953, 06647746, 06779074, 06844867, 06910660, 06976452, 07042245, 07108038, 07173830, 07239623, 07370952, 07436744, 07502793, 07568586, 07634378, 07700171, 07765964, 07897292, 07963085, 08028877, 08094670, 08160719, 08226511, 08357840, 08423632, 08489425, 08555218, 08621010, 08752339, 08818387, 08884180, 08949973, 09015765, 09147094, 09212886, 09278679, 09344727, 09410520, 09541849, 09607641, 09673434, 09739226, 09870555, 09936603, 10002396, 10068188, 10133981, 10265309, 10331102, 10397150, 10462943, 10594272, 10660064, 10725857, 10791905, 10923234, 10989026, 11054819, 11120611, 11251940, 11317988, 11383781, 11515109, 11580902, 11646694, 11712743, 11844071, 11909864, 11975656, 12106985, 12173033, 12238826, 12304618, 12435947, 12501995, 12567787, 12699116, 12764908, 12830701, 12962285, 13028078, 13093870, 13159663, 13291247, 13357040, 13422832, 13554161, 13619953, 13686001, 13817330, 13883122, 13948915, 14080499, 14146292, 14212084, 14343412, 14409461, 14475253, 14606582, 14672374, 14738423, 14869751, 14935543, 15066872, 15132920, 15198713, 15330041, 15396090, 15461882, 15593210, 15659003, 15725051, 15856380, 15922172, 16053500, 16119549, 16185341, 16316670, 16382718, 16448510, 16579839, 16645631, 16777215, }; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region RGB 구하기 - GetRGB(value) /// <summary> /// RGB 구하기 /// </summary> /// <param name="value">값</param> /// <returns>RGB 튜플</returns> public (byte r, byte g, byte b) GetRGB(byte value) { byte[] byteArray = BitConverter.GetBytes(this.rgbArray[value]); return (byteArray[2], byteArray[1], byteArray[0]); } #endregion } } |
▶ BlueColorMap.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
using System; namespace TestLibrary { /// <summary> /// 청색 색상 맵 /// </summary> public class BlueColorMap : IColorMap { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// ARGB 배열 /// </summary> private readonly int[] argbArray = { -16767403, -16767402, -16767144, -16766887, -16701093, -16700835, -16700578, -16634784, -16634527, -16634269, -16568476, -16568218, -16568216, -16567959, -16502165, -16501908, -16501650, -16435856, -16435599, -16435341, -16369548, -16369290, -16369033, -16303495, -16303238, -16302980, -16237186, -16236929, -16236671, -16236414, -16170620, -16170363, -16170105, -16104312, -16104054, -16103797, -16038259, -16038002, -16037745, -15971951, -15971694, -15971436, -15905643, -15905385, -15905128, -15839335, -15839077, -15838820, -15773027, -15772769, -15772512, -15706718, -15706717, -15706460, -15706203, -15640409, -15640152, -15574359, -15574101, -15573844, -15508051, -15507794, -15507537, -15441743, -15441486, -15441229, -15375436, -15375179, -15309386, -15309128, -15308871, -15243078, -15242821, -15177284, -15177027, -15111234, -15110977, -15045184, -15044927, -14979134, -14978877, -14913084, -14912827, -14847034, -14781241, -14780984, -14715191, -14715190, -14649397, -14583605, -14517812, -14517555, -14451762, -14385969, -14320176, -14319920, -14254383, -14188590, -14122797, -14057005, -13991212, -13925419, -13859626, -13859626, -13793833, -13662505, -13596712, -13530919, -13465383, -13399590, -13333797, -13268005, -13202212, -13136676, -13005347, -12939555, -12873762, -12808226, -12676897, -12611105, -12545312, -12414240, -12348447, -12282655, -12151327, -12085790, -12019998, -11888669, -11822877, -11757341, -11626012, -11560220, -11429148, -11363355, -11232027, -11166235, -11035162, -10969370, -10903578, -10772505, -10706713, -10575385, -10509592, -10378520, -10312728, -10181400, -10115863, -09984535, -09918743, -09787414, -09721878, -09590550, -09524758, -09393429, -09327893, -09262101, -09130773, -09065237, -08933908, -08868116, -08736788, -08671252, -08605459, -08474131, -08408339, -08277267, -08211475, -08145682, -08014354, -07948818, -07817490, -07751698, -07685905, -07554833, -07489041, -07357713, -07291921, -07226128, -07095056, -07029264, -06897936, -06832144, -06766351, -06635279, -06569487, -06503695, -06372367, -06306575, -06175502, -06109710, -06043918, -05912590, -05846798, -05781261, -05649933, -05584141, -05518349, -05387021, -05321485, -05190156, -05124364, -05058572, -04927244, -04861452, -04730123, -04664587, -04598795, -04467467, -04401675, -04335883, -04204554, -04139018, -04007690, -03941898, -03876106, -03744777, -03678985, -03547657, -03481865, -03416329, -03285000, -03219208, -03087880, -03022088, -02956296, -02824968, -02759175, -02628103, -02562311, -02430983, -02365191, -02299398, -02168070, -02102278, -01970950, -01905158, -01839621, -01708293, -01642501, -01511173, -01445381, -01314052, -01248260, -01182468, -01051140, -00985604, -00854275, -00788483, -00657155, -00591363, -00525571, -00394242, -00328450, -00197122, -00131330, -00000001, }; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region RGB 구하기 - GetRGB(value) /// <summary> /// RGB 구하기 /// </summary> /// <param name="value">값</param> /// <returns>RGB 튜플</returns> public (byte r, byte g, byte b) GetRGB(byte value) { byte[] byteArray = BitConverter.GetBytes(this.argbArray[value]); return (byteArray[2], byteArray[1], byteArray[0]); } #endregion } } |
▶ GrayscaleColorMap.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
namespace TestLibrary { /// <summary> /// 회색조 색상 맵 /// </summary> public class GrayscaleColorMap : IColorMap { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region RGB 구하기 - GetRGB(value) /// <summary> /// RGB 구하기 /// </summary> /// <param name="value">값</param> /// <returns>RGB</returns> public (byte r, byte g, byte b) GetRGB(byte value) { return (value, value, value); } #endregion } } |
▶ GrayscaleReversedColorMap.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
namespace TestLibrary { /// <summary> /// 회색조 반전 색상 맵 /// </summary> public class GrayscaleReversedColorMap : IColorMap { //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region RGB 구하기 - GetRGB(value) /// <summary> /// RGB 구하기 /// </summary> /// <param name="value">값</param> /// <returns>RGB</returns> public (byte r, byte g, byte b) GetRGB(byte value) { value = (byte)(255 - value); return (value, value, value); } #endregion } } |
▶ GreenColorMap.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
using System; namespace TestLibrary { /// <summary> /// 녹색 색상 맵 /// </summary> public class GreenColorMap : IColorMap { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Private #region Field /// <summary> /// ARGB 배열 /// </summary> private readonly int[] argbArray = { -16761088, -16760832, -16760575, -16760318, -16760061, -16759804, -16759547, -16759290, -16759033, -16758776, -16758519, -16758006, -16757749, -16757492, -16757235, -16756979, -16756722, -16756465, -16756208, -16755951, -16755694, -16755437, -16755180, -16754667, -16754410, -16688617, -16688360, -16688104, -16687847, -16687590, -16687333, -16687076, -16621283, -16621026, -16620769, -16620512, -16620256, -16554463, -16554206, -16553949, -16553692, -16487899, -16487642, -16487385, -16421336, -16421080, -16420823, -16355030, -16354773, -16288980, -16288723, -16222930, -16222930, -16222673, -16156880, -16156623, -16090830, -16025038, -16024781, -15958988, -15958731, -15892938, -15827145, -15826889, -15761096, -15695303, -15695046, -15629254, -15563461, -15497924, -15497667, -15431875, -15366082, -15300289, -15234496, -15234240, -15168447, -15102654, -15037118, -14971325, -14905532, -14839740, -14773947, -14708154, -14642618, -14576825, -14511033, -14445240, -14379447, -14313655, -14248118, -14182326, -14116533, -14050741, -13985204, -13919412, -13853619, -13722291, -13656498, -13590962, -13525169, -13459377, -13328048, -13262512, -13196720, -13130927, -13065391, -12934063, -12868270, -12802478, -12671406, -12605613, -12539821, -12408749, -12342957, -12277164, -12146092, -12080300, -12014508, -11883435, -11817643, -11686315, -11620779, -11554986, -11423914, -11358122, -11226794, -11161258, -11029929, -10964137, -10833065, -10767273, -10636201, -10570408, -10439080, -10373544, -10242216, -10176680, -10045351, -09914023, -09848487, -09717159, -09651623, -09520294, -09389222, -09323430, -09192102, -09061029, -08995237, -08864165, -08798372, -08667300, -08535972, -08404643, -08339107, -08207779, -08076706, -08010914, -07879842, -07748513, -07682977, -07551648, -07420576, -07289248, -07223711, -07092383, -06961054, -06895518, -06764189, -06633116, -06501788, -06436251, -06304923, -06173850, -06108057, -05976984, -05845656, -05714583, -05648790, -05517717, -05386389, -05320596, -05189523, -05123730, -04992657, -04861328, -04795791, -04664462, -04598925, -04467596, -04336523, -04270730, -04139400, -04073863, -03942534, -03876997, -03745667, -03680130, -03614337, -03483007, -03417470, -03286140, -03220603, -03154809, -03023479, -02957942, -02892148, -02826610, -02760817, -02629487, -02563949, -02498155, -02432617, -02366823, -02301029, -02235491, -02169697, -02103903, -02038365, -01972571, -01906777, -01841239, -01775444, -01709650, -01644112, -01578318, -01512523, -01446985, -01381191, -01315396, -01249858, -01249599, -01183805, -01118266, -01052472, -00986678, -00986675, -00920880, -00855086, -00789547, -00723753, -00723494, -00657956, -00592161, -00526367, -00526108, -00460569, -00394775, -00394516, -00328977, -00263183, -00197388, -00197385, -00131591, -00065796, -00000001, }; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Public #region RGB 구하기 - GetRGB(value) /// <summary> /// RGB 구하기 /// </summary> /// <param name="value">값</param> /// <returns>RGB</returns> public (byte r, byte g, byte b) GetRGB(byte value) { byte[] byteArray = BitConverter.GetBytes(this.argbArray[value]); return (byteArray[2], byteArray[1], byteArray[0]); } #endregion } } |