use approx::assert_relative_eq; use pacmog::{ imaadpcm::{ImaAdpcmPlayer, I1F15}, AudioFormat, PcmPlayer, PcmReader, }; const SINEWAVE: [f32; 3000] = [ 0f32, 0.05130394f32, 0.10243774f32, 0.15323183f32, 0.20351772f32, 0.2531287f32, 0.3019002f32, 0.34967047f32, 0.39628112f32, 0.44157755f32, 0.4854096f32, 0.52763176f32, 0.56810415f32, 0.6066925f32, 0.6432688f32, 0.67771184f32, 0.7099073f32, 0.7397485f32, 0.7671364f32, 0.79198015f32, 0.8141974f32, 0.83371454f32, 0.8504667f32, 0.8643985f32, 0.87546355f32, 0.8836253f32, 0.88885653f32, 0.8911401f32, 0.8904683f32, 0.8868433f32, 0.8802773f32, 0.8707919f32, 0.85841864f32, 0.8431986f32, 0.8251822f32, 0.8044292f32, 0.78100836f32, 0.75499743f32, 0.7264827f32, 0.69555867f32, 0.6623278f32, 0.62690055f32, 0.5893942f32, 0.54993325f32, 0.5086485f32, 0.46567684f32, 0.4211609f32, 0.3752482f32, 0.32809103f32, 0.2798458f32, 0.23067248f32, 0.18073419f32, 0.13019651f32, 0.07922705f32, 0.02799484f32, -0.023330206f32, -0.07457788f32, -0.12557824f32, -0.17616212f32, -0.2261618f32, -0.27541143f32, -0.3237477f32, -0.3710103f32, -0.41704246f32, -0.4616916f32, -0.5048096f32, -0.54625344f32, -0.5858857f32, -0.623575f32, -0.65919626f32, -0.6926314f32, -0.7237695f32, -0.7525073f32, -0.7787495f32, -0.8024091f32, -0.82340765f32, -0.84167546f32, -0.857152f32, -0.86978585f32, -0.87953526f32, -0.8863677f32, -0.89026064f32, -0.8912012f32, -0.8891862f32, -0.88422227f32, -0.87632596f32, -0.8655235f32, -0.85185057f32, -0.8353526f32, -0.8160843f32, -0.7941096f32, -0.7695013f32, -0.7423411f32, -0.71271896f32, -0.68073326f32, -0.64649f32, -0.61010265f32, -0.571692f32, -0.5313855f32, -0.48931658f32, -0.44562504f32, -0.4004556f32, -0.35395807f32, -0.30628672f32, -0.25759962f32, -0.2080582f32, -0.15782678f32, -0.107071966f32, -0.055962056f32, -0.0046665533f32, 0.046644423f32, 0.09780071f32, 0.14863265f32, 0.19897167f32, 0.24865083f32, 0.29750538f32, 0.34537327f32, 0.3920958f32, 0.437518f32, 0.48148924f32, 0.5238636f32, 0.56450075f32, 0.6032657f32, 0.6400301f32, 0.6746719f32, 0.7070762f32, 0.7371356f32, 0.76475036f32, 0.789829f32, 0.8122882f32, 0.8320536f32, 0.8490596f32, 0.8632498f32, 0.87457716f32, 0.88300407f32, 0.8885026f32, 0.8910546f32, 0.89065146f32, 0.88729465f32, 0.8809952f32, 0.87177414f32, 0.8596618f32, 0.8446986f32, 0.8269341f32, 0.8064272f32, 0.7832458f32, 0.7574669f32, 0.729176f32, 0.69846684f32, 0.66544133f32, 0.63020897f32, 0.59288657f32, 0.553598f32, 0.51247346f32, 0.46964937f32, 0.42526776f32, 0.3794758f32, 0.3324254f32, 0.2842725f32, 0.23517686f32, 0.1853013f32, 0.13481122f32, 0.08387404f32, 0.032658707f32, -0.018664932f32, -0.06992668f32, -0.12095651f32, -0.1715852f32, -0.22164488f32, -0.27096948f32, -0.31939545f32, -0.3667622f32, -0.4129126f32, -0.4576937f32, -0.50095683f32, -0.54255867f32, -0.58236116f32, -0.6202323f32, -0.65604657f32, -0.6896851f32, -0.72103643f32, -0.74999654f32, -0.77646935f32, -0.8003671f32, -0.82161057f32, -0.84012926f32, -0.85586184f32, -0.86875594f32, -0.878769f32, -0.8858678f32, -0.8900286f32, -0.89123785f32, -0.8894914f32, -0.884795f32, -0.87716436f32, -0.8666247f32, -0.85321105f32, -0.83696777f32, -0.8179489f32, -0.7962173f32, -0.77184516f32, -0.7449134f32, -0.7155111f32, -0.68373597f32, -0.6496933f32, -0.613496f32, -0.5752642f32, -0.53512454f32, -0.49321026f32, -0.44966027f32, -0.40461904f32, -0.35823596f32, -0.31066486f32, -0.26206344f32, -0.21259294f32, -0.16241743f32, -0.111703254f32, -0.06061863f32, -0.009332978f32, 0.041983627f32, 0.093161f32, 0.14402941f32, 0.19442017f32, 0.24416617f32, 0.2931024f32, 0.34106663f32, 0.38789973f32, 0.4334464f32, 0.47755566f32, 0.52008116f32, 0.5608818f32, 0.5998224f32, 0.63677377f32, 0.6716134f32, 0.70422566f32, 0.7345025f32, 0.76234347f32, 0.7876562f32, 0.81035674f32, 0.83036983f32, 0.8476292f32, 0.8620774f32, 0.8736667f32, 0.8823587f32, 0.8881243f32, 0.89094466f32, 0.89081025f32, 0.88772166f32, 0.881689f32, 0.8727324f32, 0.86088145f32, 0.8461755f32, 0.82866335f32, 0.808403f32, 0.7854617f32, 0.7599156f32, 0.7318493f32, 0.7013559f32, 0.6685365f32, 0.63350004f32, 0.5963627f32, 0.5572475f32, 0.51628435f32, 0.47360903f32, 0.42936298f32, 0.38369304f32, 0.33675063f32, 0.2886914f32, 0.2396748f32, 0.18986334f32, 0.13942222f32, 0.08851873f32, 0.03732168f32, -0.013999147f32, -0.065273546f32, -0.116331466f32, -0.1670036f32, -0.2171219f32, -0.2665201f32, -0.31503448f32, -0.36250407f32, -0.40877143f32, -0.4536832f32, -0.49709034f32, -0.538849f32, -0.5788206f32, -0.61687267f32, -0.6528789f32, -0.68671995f32, -0.71828365f32, -0.7474652f32, -0.7741679f32, -0.7983032f32, -0.81979096f32, -0.83856004f32, -0.85454816f32, -0.86770225f32, -0.87797874f32, -0.8853435f32, -0.8897722f32, -0.8912501f32, -0.8897722f32, -0.8853435f32, -0.87797874f32, -0.86770225f32, -0.85454816f32, -0.83856004f32, -0.81979096f32, -0.7983032f32, -0.7741679f32, -0.7474652f32, -0.71828365f32, -0.68671995f32, -0.6528789f32, -0.61687267f32, -0.5788206f32, -0.538849f32, -0.49709034f32, -0.4536832f32, -0.40877143f32, -0.36250407f32, -0.31503448f32, -0.2665201f32, -0.2171219f32, -0.1670036f32, -0.116331466f32, -0.065273546f32, -0.013999147f32, 0.03732168f32, 0.08851873f32, 0.13942222f32, 0.18986334f32, 0.2396748f32, 0.2886914f32, 0.33675063f32, 0.38369304f32, 0.42936298f32, 0.47360903f32, 0.51628435f32, 0.5572475f32, 0.5963627f32, 0.63350004f32, 0.6685365f32, 0.7013559f32, 0.7318493f32, 0.7599156f32, 0.7854617f32, 0.808403f32, 0.82866335f32, 0.8461755f32, 0.86088145f32, 0.8727324f32, 0.881689f32, 0.88772166f32, 0.89081025f32, 0.89094466f32, 0.8881243f32, 0.8823587f32, 0.8736667f32, 0.8620774f32, 0.8476292f32, 0.83036983f32, 0.81035674f32, 0.7876562f32, 0.76234347f32, 0.7345025f32, 0.70422566f32, 0.6716134f32, 0.63677377f32, 0.5998224f32, 0.5608818f32, 0.52008116f32, 0.47755566f32, 0.4334464f32, 0.38789973f32, 0.34106663f32, 0.2931024f32, 0.24416617f32, 0.19442017f32, 0.14402941f32, 0.093161f32, 0.041983627f32, -0.009332978f32, -0.06061863f32, -0.111703254f32, -0.16241743f32, -0.21259294f32, -0.26206344f32, -0.31066486f32, -0.35823596f32, -0.40461904f32, -0.44966027f32, -0.49321026f32, -0.53512454f32, -0.5752642f32, -0.613496f32, -0.6496933f32, -0.68373597f32, -0.7155111f32, -0.7449134f32, -0.77184516f32, -0.7962173f32, -0.8179489f32, -0.83696777f32, -0.85321105f32, -0.8666247f32, -0.87716436f32, -0.884795f32, -0.8894914f32, -0.89123785f32, -0.8900286f32, -0.8858678f32, -0.878769f32, -0.86875594f32, -0.85586184f32, -0.84012926f32, -0.82161057f32, -0.8003671f32, -0.77646935f32, -0.74999654f32, -0.72103643f32, -0.6896851f32, -0.65604657f32, -0.6202323f32, -0.58236116f32, -0.54255867f32, -0.50095683f32, -0.4576937f32, -0.4129126f32, -0.3667622f32, -0.31939545f32, -0.27096948f32, -0.22164488f32, -0.1715852f32, -0.12095651f32, -0.06992668f32, -0.018664932f32, 0.032658707f32, 0.08387404f32, 0.13481122f32, 0.1853013f32, 0.23517686f32, 0.2842725f32, 0.3324254f32, 0.3794758f32, 0.42526776f32, 0.46964937f32, 0.51247346f32, 0.553598f32, 0.59288657f32, 0.63020897f32, 0.66544133f32, 0.69846684f32, 0.729176f32, 0.7574669f32, 0.7832458f32, 0.8064272f32, 0.8269341f32, 0.8446986f32, 0.8596618f32, 0.87177414f32, 0.8809952f32, 0.88729465f32, 0.89065146f32, 0.8910546f32, 0.8885026f32, 0.88300407f32, 0.87457716f32, 0.8632498f32, 0.8490596f32, 0.8320536f32, 0.8122882f32, 0.789829f32, 0.76475036f32, 0.7371356f32, 0.7070762f32, 0.6746719f32, 0.6400301f32, 0.6032657f32, 0.56450075f32, 0.5238636f32, 0.48148924f32, 0.437518f32, 0.3920958f32, 0.34537327f32, 0.29750538f32, 0.24865083f32, 0.19897167f32, 0.14863265f32, 0.09780071f32, 0.046644423f32, -0.0046665533f32, -0.055962056f32, -0.107071966f32, -0.15782678f32, -0.2080582f32, -0.25759962f32, -0.30628672f32, -0.35395807f32, -0.4004556f32, -0.44562504f32, -0.48931658f32, -0.5313855f32, -0.571692f32, -0.61010265f32, -0.64649f32, -0.68073326f32, -0.71271896f32, -0.7423411f32, -0.7695013f32, -0.7941096f32, -0.8160843f32, -0.8353526f32, -0.85185057f32, -0.8655235f32, -0.87632596f32, -0.88422227f32, -0.8891862f32, -0.8912012f32, -0.89026064f32, -0.8863677f32, -0.87953526f32, -0.86978585f32, -0.857152f32, -0.84167546f32, -0.82340765f32, -0.8024091f32, -0.7787495f32, -0.7525073f32, -0.7237695f32, -0.6926314f32, -0.65919626f32, -0.623575f32, -0.5858857f32, -0.54625344f32, -0.5048096f32, -0.4616916f32, -0.41704246f32, -0.3710103f32, -0.3237477f32, -0.27541143f32, -0.2261618f32, -0.17616212f32, -0.12557824f32, -0.07457788f32, -0.023330206f32, 0.02799484f32, 0.07922705f32, 0.13019651f32, 0.18073419f32, 0.23067248f32, 0.2798458f32, 0.32809103f32, 0.3752482f32, 0.4211609f32, 0.46567684f32, 0.5086485f32, 0.54993325f32, 0.5893942f32, 0.62690055f32, 0.6623278f32, 0.69555867f32, 0.7264827f32, 0.75499743f32, 0.78100836f32, 0.8044292f32, 0.8251822f32, 0.8431986f32, 0.85841864f32, 0.8707919f32, 0.8802773f32, 0.8868433f32, 0.8904683f32, 0.8911401f32, 0.88885653f32, 0.8836253f32, 0.87546355f32, 0.8643985f32, 0.8504667f32, 0.83371454f32, 0.8141974f32, 0.79198015f32, 0.7671364f32, 0.7397485f32, 0.7099073f32, 0.67771184f32, 0.6432688f32, 0.6066925f32, 0.56810415f32, 0.52763176f32, 0.4854096f32, 0.44157755f32, 0.39628112f32, 0.34967047f32, 0.3019002f32, 0.2531287f32, 0.20351772f32, 0.15323183f32, 0.10243774f32, 0.05130394f32, -0.000000000000001965743f32, -0.05130394f32, -0.10243774f32, -0.15323183f32, -0.20351772f32, -0.2531287f32, -0.3019002f32, -0.34967047f32, -0.39628112f32, -0.44157755f32, -0.4854096f32, -0.52763176f32, -0.56810415f32, -0.6066925f32, -0.6432688f32, -0.67771184f32, -0.7099073f32, -0.7397485f32, -0.7671364f32, -0.79198015f32, -0.8141974f32, -0.83371454f32, -0.8504667f32, -0.8643985f32, -0.87546355f32, -0.8836253f32, -0.88885653f32, -0.8911401f32, -0.8904683f32, -0.8868433f32, -0.8802773f32, -0.8707919f32, -0.85841864f32, -0.8431986f32, -0.8251822f32, -0.8044292f32, -0.78100836f32, -0.75499743f32, -0.7264827f32, -0.69555867f32, -0.6623278f32, -0.62690055f32, -0.5893942f32, -0.54993325f32, -0.5086485f32, -0.46567684f32, -0.4211609f32, -0.3752482f32, -0.32809103f32, -0.2798458f32, -0.23067248f32, -0.18073419f32, -0.13019651f32, -0.07922705f32, -0.02799484f32, 0.023330206f32, 0.07457788f32, 0.12557824f32, 0.17616212f32, 0.2261618f32, 0.27541143f32, 0.3237477f32, 0.3710103f32, 0.41704246f32, 0.4616916f32, 0.5048096f32, 0.54625344f32, 0.5858857f32, 0.623575f32, 0.65919626f32, 0.6926314f32, 0.7237695f32, 0.7525073f32, 0.7787495f32, 0.8024091f32, 0.82340765f32, 0.84167546f32, 0.857152f32, 0.86978585f32, 0.87953526f32, 0.8863677f32, 0.89026064f32, 0.8912012f32, 0.8891862f32, 0.88422227f32, 0.87632596f32, 0.8655235f32, 0.85185057f32, 0.8353526f32, 0.8160843f32, 0.7941096f32, 0.7695013f32, 0.7423411f32, 0.71271896f32, 0.68073326f32, 0.64649f32, 0.61010265f32, 0.571692f32, 0.5313855f32, 0.48931658f32, 0.44562504f32, 0.4004556f32, 0.35395807f32, 0.30628672f32, 0.25759962f32, 0.2080582f32, 0.15782678f32, 0.107071966f32, 0.055962056f32, 0.0046665533f32, -0.046644423f32, -0.09780071f32, -0.14863265f32, -0.19897167f32, -0.24865083f32, -0.29750538f32, -0.34537327f32, -0.3920958f32, -0.437518f32, -0.48148924f32, -0.5238636f32, -0.56450075f32, -0.6032657f32, -0.6400301f32, -0.6746719f32, -0.7070762f32, -0.7371356f32, -0.76475036f32, -0.789829f32, -0.8122882f32, -0.8320536f32, -0.8490596f32, -0.8632498f32, -0.87457716f32, -0.88300407f32, -0.8885026f32, -0.8910546f32, -0.89065146f32, -0.88729465f32, -0.8809952f32, -0.87177414f32, -0.8596618f32, -0.8446986f32, -0.8269341f32, -0.8064272f32, -0.7832458f32, -0.7574669f32, -0.729176f32, -0.69846684f32, -0.66544133f32, -0.63020897f32, -0.59288657f32, -0.553598f32, -0.51247346f32, -0.46964937f32, -0.42526776f32, -0.3794758f32, -0.3324254f32, -0.2842725f32, -0.23517686f32, -0.1853013f32, -0.13481122f32, -0.08387404f32, -0.032658707f32, 0.018664932f32, 0.06992668f32, 0.12095651f32, 0.1715852f32, 0.22164488f32, 0.27096948f32, 0.31939545f32, 0.3667622f32, 0.4129126f32, 0.4576937f32, 0.50095683f32, 0.54255867f32, 0.58236116f32, 0.6202323f32, 0.65604657f32, 0.6896851f32, 0.72103643f32, 0.74999654f32, 0.77646935f32, 0.8003671f32, 0.82161057f32, 0.84012926f32, 0.85586184f32, 0.86875594f32, 0.878769f32, 0.8858678f32, 0.8900286f32, 0.89123785f32, 0.8894914f32, 0.884795f32, 0.87716436f32, 0.8666247f32, 0.85321105f32, 0.83696777f32, 0.8179489f32, 0.7962173f32, 0.77184516f32, 0.7449134f32, 0.7155111f32, 0.68373597f32, 0.6496933f32, 0.613496f32, 0.5752642f32, 0.53512454f32, 0.49321026f32, 0.44966027f32, 0.40461904f32, 0.35823596f32, 0.31066486f32, 0.26206344f32, 0.21259294f32, 0.16241743f32, 0.111703254f32, 0.06061863f32, 0.009332978f32, -0.041983627f32, -0.093161f32, -0.14402941f32, -0.19442017f32, -0.24416617f32, -0.2931024f32, -0.34106663f32, -0.38789973f32, -0.4334464f32, -0.47755566f32, -0.52008116f32, -0.5608818f32, -0.5998224f32, -0.63677377f32, -0.6716134f32, -0.70422566f32, -0.7345025f32, -0.76234347f32, -0.7876562f32, -0.81035674f32, -0.83036983f32, -0.8476292f32, -0.8620774f32, -0.8736667f32, -0.8823587f32, -0.8881243f32, -0.89094466f32, -0.89081025f32, -0.88772166f32, -0.881689f32, -0.8727324f32, -0.86088145f32, -0.8461755f32, -0.82866335f32, -0.808403f32, -0.7854617f32, -0.7599156f32, -0.7318493f32, -0.7013559f32, -0.6685365f32, -0.63350004f32, -0.5963627f32, -0.5572475f32, -0.51628435f32, -0.47360903f32, -0.42936298f32, -0.38369304f32, -0.33675063f32, -0.2886914f32, -0.2396748f32, -0.18986334f32, -0.13942222f32, -0.08851873f32, -0.03732168f32, 0.013999147f32, 0.065273546f32, 0.116331466f32, 0.1670036f32, 0.2171219f32, 0.2665201f32, 0.31503448f32, 0.36250407f32, 0.40877143f32, 0.4536832f32, 0.49709034f32, 0.538849f32, 0.5788206f32, 0.61687267f32, 0.6528789f32, 0.68671995f32, 0.71828365f32, 0.7474652f32, 0.7741679f32, 0.7983032f32, 0.81979096f32, 0.83856004f32, 0.85454816f32, 0.86770225f32, 0.87797874f32, 0.8853435f32, 0.8897722f32, 0.8912501f32, 0.8897722f32, 0.8853435f32, 0.87797874f32, 0.86770225f32, 0.85454816f32, 0.83856004f32, 0.81979096f32, 0.7983032f32, 0.7741679f32, 0.7474652f32, 0.71828365f32, 0.68671995f32, 0.6528789f32, 0.61687267f32, 0.5788206f32, 0.538849f32, 0.49709034f32, 0.4536832f32, 0.40877143f32, 0.36250407f32, 0.31503448f32, 0.2665201f32, 0.2171219f32, 0.1670036f32, 0.116331466f32, 0.065273546f32, 0.013999147f32, -0.03732168f32, -0.08851873f32, -0.13942222f32, -0.18986334f32, -0.2396748f32, -0.2886914f32, -0.33675063f32, -0.38369304f32, -0.42936298f32, -0.47360903f32, -0.51628435f32, -0.5572475f32, -0.5963627f32, -0.63350004f32, -0.6685365f32, -0.7013559f32, -0.7318493f32, -0.7599156f32, -0.7854617f32, -0.808403f32, -0.82866335f32, -0.8461755f32, -0.86088145f32, -0.8727324f32, -0.881689f32, -0.88772166f32, -0.89081025f32, -0.89094466f32, -0.8881243f32, -0.8823587f32, -0.8736667f32, -0.8620774f32, -0.8476292f32, -0.83036983f32, -0.81035674f32, -0.7876562f32, -0.76234347f32, -0.7345025f32, -0.70422566f32, -0.6716134f32, -0.63677377f32, -0.5998224f32, -0.5608818f32, -0.52008116f32, -0.47755566f32, -0.4334464f32, -0.38789973f32, -0.34106663f32, -0.2931024f32, -0.24416617f32, -0.19442017f32, -0.14402941f32, -0.093161f32, -0.041983627f32, 0.009332978f32, 0.06061863f32, 0.111703254f32, 0.16241743f32, 0.21259294f32, 0.26206344f32, 0.31066486f32, 0.35823596f32, 0.40461904f32, 0.44966027f32, 0.49321026f32, 0.53512454f32, 0.5752642f32, 0.613496f32, 0.6496933f32, 0.68373597f32, 0.7155111f32, 0.7449134f32, 0.77184516f32, 0.7962173f32, 0.8179489f32, 0.83696777f32, 0.85321105f32, 0.8666247f32, 0.87716436f32, 0.884795f32, 0.8894914f32, 0.89123785f32, 0.8900286f32, 0.8858678f32, 0.878769f32, 0.86875594f32, 0.85586184f32, 0.84012926f32, 0.82161057f32, 0.8003671f32, 0.77646935f32, 0.74999654f32, 0.72103643f32, 0.6896851f32, 0.65604657f32, 0.6202323f32, 0.58236116f32, 0.54255867f32, 0.50095683f32, 0.4576937f32, 0.4129126f32, 0.3667622f32, 0.31939545f32, 0.27096948f32, 0.22164488f32, 0.1715852f32, 0.12095651f32, 0.06992668f32, 0.018664932f32, -0.032658707f32, -0.08387404f32, -0.13481122f32, -0.1853013f32, -0.23517686f32, -0.2842725f32, -0.3324254f32, -0.3794758f32, -0.42526776f32, -0.46964937f32, -0.51247346f32, -0.553598f32, -0.59288657f32, -0.63020897f32, -0.66544133f32, -0.69846684f32, -0.729176f32, -0.7574669f32, -0.7832458f32, -0.8064272f32, -0.8269341f32, -0.8446986f32, -0.8596618f32, -0.87177414f32, -0.8809952f32, -0.88729465f32, -0.89065146f32, -0.8910546f32, -0.8885026f32, -0.88300407f32, -0.87457716f32, -0.8632498f32, -0.8490596f32, -0.8320536f32, -0.8122882f32, -0.789829f32, -0.76475036f32, -0.7371356f32, -0.7070762f32, -0.6746719f32, -0.6400301f32, -0.6032657f32, -0.56450075f32, -0.5238636f32, -0.48148924f32, -0.437518f32, -0.3920958f32, -0.34537327f32, -0.29750538f32, -0.24865083f32, -0.19897167f32, -0.14863265f32, -0.09780071f32, -0.046644423f32, 0.0046665533f32, 0.055962056f32, 0.107071966f32, 0.15782678f32, 0.2080582f32, 0.25759962f32, 0.30628672f32, 0.35395807f32, 0.4004556f32, 0.44562504f32, 0.48931658f32, 0.5313855f32, 0.571692f32, 0.61010265f32, 0.64649f32, 0.68073326f32, 0.71271896f32, 0.7423411f32, 0.7695013f32, 0.7941096f32, 0.8160843f32, 0.8353526f32, 0.85185057f32, 0.8655235f32, 0.87632596f32, 0.88422227f32, 0.8891862f32, 0.8912012f32, 0.89026064f32, 0.8863677f32, 0.87953526f32, 0.86978585f32, 0.857152f32, 0.84167546f32, 0.82340765f32, 0.8024091f32, 0.7787495f32, 0.7525073f32, 0.7237695f32, 0.6926314f32, 0.65919626f32, 0.623575f32, 0.5858857f32, 0.54625344f32, 0.5048096f32, 0.4616916f32, 0.41704246f32, 0.3710103f32, 0.3237477f32, 0.27541143f32, 0.2261618f32, 0.17616212f32, 0.12557824f32, 0.07457788f32, 0.023330206f32, -0.02799484f32, -0.07922705f32, -0.13019651f32, -0.18073419f32, -0.23067248f32, -0.2798458f32, -0.32809103f32, -0.3752482f32, -0.4211609f32, -0.46567684f32, -0.5086485f32, -0.54993325f32, -0.5893942f32, -0.62690055f32, -0.6623278f32, -0.69555867f32, -0.7264827f32, -0.75499743f32, -0.78100836f32, -0.8044292f32, -0.8251822f32, -0.8431986f32, -0.85841864f32, -0.8707919f32, -0.8802773f32, -0.8868433f32, -0.8904683f32, -0.8911401f32, -0.88885653f32, -0.8836253f32, -0.87546355f32, -0.8643985f32, -0.8504667f32, -0.83371454f32, -0.8141974f32, -0.79198015f32, -0.7671364f32, -0.7397485f32, -0.7099073f32, -0.67771184f32, -0.6432688f32, -0.6066925f32, -0.56810415f32, -0.52763176f32, -0.4854096f32, -0.44157755f32, -0.39628112f32, -0.34967047f32, -0.3019002f32, -0.2531287f32, -0.20351772f32, -0.15323183f32, -0.10243774f32, -0.05130394f32, 0.000000000000003931486f32, 0.05130394f32, 0.10243774f32, 0.15323183f32, 0.20351772f32, 0.2531287f32, 0.3019002f32, 0.34967047f32, 0.39628112f32, 0.44157755f32, 0.4854096f32, 0.52763176f32, 0.56810415f32, 0.6066925f32, 0.6432688f32, 0.67771184f32, 0.7099073f32, 0.7397485f32, 0.7671364f32, 0.79198015f32, 0.8141974f32, 0.83371454f32, 0.8504667f32, 0.8643985f32, 0.87546355f32, 0.8836253f32, 0.88885653f32, 0.8911401f32, 0.8904683f32, 0.8868433f32, 0.8802773f32, 0.8707919f32, 0.85841864f32, 0.8431986f32, 0.8251822f32, 0.8044292f32, 0.78100836f32, 0.75499743f32, 0.7264827f32, 0.69555867f32, 0.6623278f32, 0.62690055f32, 0.5893942f32, 0.54993325f32, 0.5086485f32, 0.46567684f32, 0.4211609f32, 0.3752482f32, 0.32809103f32, 0.2798458f32, 0.23067248f32, 0.18073419f32, 0.13019651f32, 0.07922705f32, 0.02799484f32, -0.023330206f32, -0.07457788f32, -0.12557824f32, -0.17616212f32, -0.2261618f32, -0.27541143f32, -0.3237477f32, -0.3710103f32, -0.41704246f32, -0.4616916f32, -0.5048096f32, -0.54625344f32, -0.5858857f32, -0.623575f32, -0.65919626f32, -0.6926314f32, -0.7237695f32, -0.7525073f32, -0.7787495f32, -0.8024091f32, -0.82340765f32, -0.84167546f32, -0.857152f32, -0.86978585f32, -0.87953526f32, -0.8863677f32, -0.89026064f32, -0.8912012f32, -0.8891862f32, -0.88422227f32, -0.87632596f32, -0.8655235f32, -0.85185057f32, -0.8353526f32, -0.8160843f32, -0.7941096f32, -0.7695013f32, -0.7423411f32, -0.71271896f32, -0.68073326f32, -0.64649f32, -0.61010265f32, -0.571692f32, -0.5313855f32, -0.48931658f32, -0.44562504f32, -0.4004556f32, -0.35395807f32, -0.30628672f32, -0.25759962f32, -0.2080582f32, -0.15782678f32, -0.107071966f32, -0.055962056f32, -0.0046665533f32, 0.046644423f32, 0.09780071f32, 0.14863265f32, 0.19897167f32, 0.24865083f32, 0.29750538f32, 0.34537327f32, 0.3920958f32, 0.437518f32, 0.48148924f32, 0.5238636f32, 0.56450075f32, 0.6032657f32, 0.6400301f32, 0.6746719f32, 0.7070762f32, 0.7371356f32, 0.76475036f32, 0.789829f32, 0.8122882f32, 0.8320536f32, 0.8490596f32, 0.8632498f32, 0.87457716f32, 0.88300407f32, 0.8885026f32, 0.8910546f32, 0.89065146f32, 0.88729465f32, 0.8809952f32, 0.87177414f32, 0.8596618f32, 0.8446986f32, 0.8269341f32, 0.8064272f32, 0.7832458f32, 0.7574669f32, 0.729176f32, 0.69846684f32, 0.66544133f32, 0.63020897f32, 0.59288657f32, 0.553598f32, 0.51247346f32, 0.46964937f32, 0.42526776f32, 0.3794758f32, 0.3324254f32, 0.2842725f32, 0.23517686f32, 0.1853013f32, 0.13481122f32, 0.08387404f32, 0.032658707f32, -0.018664932f32, -0.06992668f32, -0.12095651f32, -0.1715852f32, -0.22164488f32, -0.27096948f32, -0.31939545f32, -0.3667622f32, -0.4129126f32, -0.4576937f32, -0.50095683f32, -0.54255867f32, -0.58236116f32, -0.6202323f32, -0.65604657f32, -0.6896851f32, -0.72103643f32, -0.74999654f32, -0.77646935f32, -0.8003671f32, -0.82161057f32, -0.84012926f32, -0.85586184f32, -0.86875594f32, -0.878769f32, -0.8858678f32, -0.8900286f32, -0.89123785f32, -0.8894914f32, -0.884795f32, -0.87716436f32, -0.8666247f32, -0.85321105f32, -0.83696777f32, -0.8179489f32, -0.7962173f32, -0.77184516f32, -0.7449134f32, -0.7155111f32, -0.68373597f32, -0.6496933f32, -0.613496f32, -0.5752642f32, -0.53512454f32, -0.49321026f32, -0.44966027f32, -0.40461904f32, -0.35823596f32, -0.31066486f32, -0.26206344f32, -0.21259294f32, -0.16241743f32, -0.111703254f32, -0.06061863f32, -0.009332978f32, 0.041983627f32, 0.093161f32, 0.14402941f32, 0.19442017f32, 0.24416617f32, 0.2931024f32, 0.34106663f32, 0.38789973f32, 0.4334464f32, 0.47755566f32, 0.52008116f32, 0.5608818f32, 0.5998224f32, 0.63677377f32, 0.6716134f32, 0.70422566f32, 0.7345025f32, 0.76234347f32, 0.7876562f32, 0.81035674f32, 0.83036983f32, 0.8476292f32, 0.8620774f32, 0.8736667f32, 0.8823587f32, 0.8881243f32, 0.89094466f32, 0.89081025f32, 0.88772166f32, 0.881689f32, 0.8727324f32, 0.86088145f32, 0.8461755f32, 0.82866335f32, 0.808403f32, 0.7854617f32, 0.7599156f32, 0.7318493f32, 0.7013559f32, 0.6685365f32, 0.63350004f32, 0.5963627f32, 0.5572475f32, 0.51628435f32, 0.47360903f32, 0.42936298f32, 0.38369304f32, 0.33675063f32, 0.2886914f32, 0.2396748f32, 0.18986334f32, 0.13942222f32, 0.08851873f32, 0.03732168f32, -0.013999147f32, -0.065273546f32, -0.116331466f32, -0.1670036f32, -0.2171219f32, -0.2665201f32, -0.31503448f32, -0.36250407f32, -0.40877143f32, -0.4536832f32, -0.49709034f32, -0.538849f32, -0.5788206f32, -0.61687267f32, -0.6528789f32, -0.68671995f32, -0.71828365f32, -0.7474652f32, -0.7741679f32, -0.7983032f32, -0.81979096f32, -0.83856004f32, -0.85454816f32, -0.86770225f32, -0.87797874f32, -0.8853435f32, -0.8897722f32, -0.8912501f32, -0.8897722f32, -0.8853435f32, -0.87797874f32, -0.86770225f32, -0.85454816f32, -0.83856004f32, -0.81979096f32, -0.7983032f32, -0.7741679f32, -0.7474652f32, -0.71828365f32, -0.68671995f32, -0.6528789f32, -0.61687267f32, -0.5788206f32, -0.538849f32, -0.49709034f32, -0.4536832f32, -0.40877143f32, -0.36250407f32, -0.31503448f32, -0.2665201f32, -0.2171219f32, -0.1670036f32, -0.116331466f32, -0.065273546f32, -0.013999147f32, 0.03732168f32, 0.08851873f32, 0.13942222f32, 0.18986334f32, 0.2396748f32, 0.2886914f32, 0.33675063f32, 0.38369304f32, 0.42936298f32, 0.47360903f32, 0.51628435f32, 0.5572475f32, 0.5963627f32, 0.63350004f32, 0.6685365f32, 0.7013559f32, 0.7318493f32, 0.7599156f32, 0.7854617f32, 0.808403f32, 0.82866335f32, 0.8461755f32, 0.86088145f32, 0.8727324f32, 0.881689f32, 0.88772166f32, 0.89081025f32, 0.89094466f32, 0.8881243f32, 0.8823587f32, 0.8736667f32, 0.8620774f32, 0.8476292f32, 0.83036983f32, 0.81035674f32, 0.7876562f32, 0.76234347f32, 0.7345025f32, 0.70422566f32, 0.6716134f32, 0.63677377f32, 0.5998224f32, 0.5608818f32, 0.52008116f32, 0.47755566f32, 0.4334464f32, 0.38789973f32, 0.34106663f32, 0.2931024f32, 0.24416617f32, 0.19442017f32, 0.14402941f32, 0.093161f32, 0.041983627f32, -0.009332978f32, -0.06061863f32, -0.111703254f32, -0.16241743f32, -0.21259294f32, -0.26206344f32, -0.31066486f32, -0.35823596f32, -0.40461904f32, -0.44966027f32, -0.49321026f32, -0.53512454f32, -0.5752642f32, -0.613496f32, -0.6496933f32, -0.68373597f32, -0.7155111f32, -0.7449134f32, -0.77184516f32, -0.7962173f32, -0.8179489f32, -0.83696777f32, -0.85321105f32, -0.8666247f32, -0.87716436f32, -0.884795f32, -0.8894914f32, -0.89123785f32, -0.8900286f32, -0.8858678f32, -0.878769f32, -0.86875594f32, -0.85586184f32, -0.84012926f32, -0.82161057f32, -0.8003671f32, -0.77646935f32, -0.74999654f32, -0.72103643f32, -0.6896851f32, -0.65604657f32, -0.6202323f32, -0.58236116f32, -0.54255867f32, -0.50095683f32, -0.4576937f32, -0.4129126f32, -0.3667622f32, -0.31939545f32, -0.27096948f32, -0.22164488f32, -0.1715852f32, -0.12095651f32, -0.06992668f32, -0.018664932f32, 0.032658707f32, 0.08387404f32, 0.13481122f32, 0.1853013f32, 0.23517686f32, 0.2842725f32, 0.3324254f32, 0.3794758f32, 0.42526776f32, 0.46964937f32, 0.51247346f32, 0.553598f32, 0.59288657f32, 0.63020897f32, 0.66544133f32, 0.69846684f32, 0.729176f32, 0.7574669f32, 0.7832458f32, 0.8064272f32, 0.8269341f32, 0.8446986f32, 0.8596618f32, 0.87177414f32, 0.8809952f32, 0.88729465f32, 0.89065146f32, 0.8910546f32, 0.8885026f32, 0.88300407f32, 0.87457716f32, 0.8632498f32, 0.8490596f32, 0.8320536f32, 0.8122882f32, 0.789829f32, 0.76475036f32, 0.7371356f32, 0.7070762f32, 0.6746719f32, 0.6400301f32, 0.6032657f32, 0.56450075f32, 0.5238636f32, 0.48148924f32, 0.437518f32, 0.3920958f32, 0.34537327f32, 0.29750538f32, 0.24865083f32, 0.19897167f32, 0.14863265f32, 0.09780071f32, 0.046644423f32, -0.0046665533f32, -0.055962056f32, -0.107071966f32, -0.15782678f32, -0.2080582f32, -0.25759962f32, -0.30628672f32, -0.35395807f32, -0.4004556f32, -0.44562504f32, -0.48931658f32, -0.5313855f32, -0.571692f32, -0.61010265f32, -0.64649f32, -0.68073326f32, -0.71271896f32, -0.7423411f32, -0.7695013f32, -0.7941096f32, -0.8160843f32, -0.8353526f32, -0.85185057f32, -0.8655235f32, -0.87632596f32, -0.88422227f32, -0.8891862f32, -0.8912012f32, -0.89026064f32, -0.8863677f32, -0.87953526f32, -0.86978585f32, -0.857152f32, -0.84167546f32, -0.82340765f32, -0.8024091f32, -0.7787495f32, -0.7525073f32, -0.7237695f32, -0.6926314f32, -0.65919626f32, -0.623575f32, -0.5858857f32, -0.54625344f32, -0.5048096f32, -0.4616916f32, -0.41704246f32, -0.3710103f32, -0.3237477f32, -0.27541143f32, -0.2261618f32, -0.17616212f32, -0.12557824f32, -0.07457788f32, -0.023330206f32, 0.02799484f32, 0.07922705f32, 0.13019651f32, 0.18073419f32, 0.23067248f32, 0.2798458f32, 0.32809103f32, 0.3752482f32, 0.4211609f32, 0.46567684f32, 0.5086485f32, 0.54993325f32, 0.5893942f32, 0.62690055f32, 0.6623278f32, 0.69555867f32, 0.7264827f32, 0.75499743f32, 0.78100836f32, 0.8044292f32, 0.8251822f32, 0.8431986f32, 0.85841864f32, 0.8707919f32, 0.8802773f32, 0.8868433f32, 0.8904683f32, 0.8911401f32, 0.88885653f32, 0.8836253f32, 0.87546355f32, 0.8643985f32, 0.8504667f32, 0.83371454f32, 0.8141974f32, 0.79198015f32, 0.7671364f32, 0.7397485f32, 0.7099073f32, 0.67771184f32, 0.6432688f32, 0.6066925f32, 0.56810415f32, 0.52763176f32, 0.4854096f32, 0.44157755f32, 0.39628112f32, 0.34967047f32, 0.3019002f32, 0.2531287f32, 0.20351772f32, 0.15323183f32, 0.10243774f32, 0.05130394f32, 0.000000000000013100909f32, -0.05130394f32, -0.10243774f32, -0.15323183f32, -0.20351772f32, -0.2531287f32, -0.3019002f32, -0.34967047f32, -0.39628112f32, -0.44157755f32, -0.4854096f32, -0.52763176f32, -0.56810415f32, -0.6066925f32, -0.6432688f32, -0.67771184f32, -0.7099073f32, -0.7397485f32, -0.7671364f32, -0.79198015f32, -0.8141974f32, -0.83371454f32, -0.8504667f32, -0.8643985f32, -0.87546355f32, -0.8836253f32, -0.88885653f32, -0.8911401f32, -0.8904683f32, -0.8868433f32, -0.8802773f32, -0.8707919f32, -0.85841864f32, -0.8431986f32, -0.8251822f32, -0.8044292f32, -0.78100836f32, -0.75499743f32, -0.7264827f32, -0.69555867f32, -0.6623278f32, -0.62690055f32, -0.5893942f32, -0.54993325f32, -0.5086485f32, -0.46567684f32, -0.4211609f32, -0.3752482f32, -0.32809103f32, -0.2798458f32, -0.23067248f32, -0.18073419f32, -0.13019651f32, -0.07922705f32, -0.02799484f32, 0.023330206f32, 0.07457788f32, 0.12557824f32, 0.17616212f32, 0.2261618f32, 0.27541143f32, 0.3237477f32, 0.3710103f32, 0.41704246f32, 0.4616916f32, 0.5048096f32, 0.54625344f32, 0.5858857f32, 0.623575f32, 0.65919626f32, 0.6926314f32, 0.7237695f32, 0.7525073f32, 0.7787495f32, 0.8024091f32, 0.82340765f32, 0.84167546f32, 0.857152f32, 0.86978585f32, 0.87953526f32, 0.8863677f32, 0.89026064f32, 0.8912012f32, 0.8891862f32, 0.88422227f32, 0.87632596f32, 0.8655235f32, 0.85185057f32, 0.8353526f32, 0.8160843f32, 0.7941096f32, 0.7695013f32, 0.7423411f32, 0.71271896f32, 0.68073326f32, 0.64649f32, 0.61010265f32, 0.571692f32, 0.5313855f32, 0.48931658f32, 0.44562504f32, 0.4004556f32, 0.35395807f32, 0.30628672f32, 0.25759962f32, 0.2080582f32, 0.15782678f32, 0.107071966f32, 0.055962056f32, 0.0046665533f32, -0.046644423f32, -0.09780071f32, -0.14863265f32, -0.19897167f32, -0.24865083f32, -0.29750538f32, -0.34537327f32, -0.3920958f32, -0.437518f32, -0.48148924f32, -0.5238636f32, -0.56450075f32, -0.6032657f32, -0.6400301f32, -0.6746719f32, -0.7070762f32, -0.7371356f32, -0.76475036f32, -0.789829f32, -0.8122882f32, -0.8320536f32, -0.8490596f32, -0.8632498f32, -0.87457716f32, -0.88300407f32, -0.8885026f32, -0.8910546f32, -0.89065146f32, -0.88729465f32, -0.8809952f32, -0.87177414f32, -0.8596618f32, -0.8446986f32, -0.8269341f32, -0.8064272f32, -0.7832458f32, -0.7574669f32, -0.729176f32, -0.69846684f32, -0.66544133f32, -0.63020897f32, -0.59288657f32, -0.553598f32, -0.51247346f32, -0.46964937f32, -0.42526776f32, -0.3794758f32, -0.3324254f32, -0.2842725f32, -0.23517686f32, -0.1853013f32, -0.13481122f32, -0.08387404f32, -0.032658707f32, 0.018664932f32, 0.06992668f32, 0.12095651f32, 0.1715852f32, 0.22164488f32, 0.27096948f32, 0.31939545f32, 0.3667622f32, 0.4129126f32, 0.4576937f32, 0.50095683f32, 0.54255867f32, 0.58236116f32, 0.6202323f32, 0.65604657f32, 0.6896851f32, 0.72103643f32, 0.74999654f32, 0.77646935f32, 0.8003671f32, 0.82161057f32, 0.84012926f32, 0.85586184f32, 0.86875594f32, 0.878769f32, 0.8858678f32, 0.8900286f32, 0.89123785f32, 0.8894914f32, 0.884795f32, 0.87716436f32, 0.8666247f32, 0.85321105f32, 0.83696777f32, 0.8179489f32, 0.7962173f32, 0.77184516f32, 0.7449134f32, 0.7155111f32, 0.68373597f32, 0.6496933f32, 0.613496f32, 0.5752642f32, 0.53512454f32, 0.49321026f32, 0.44966027f32, 0.40461904f32, 0.35823596f32, 0.31066486f32, 0.26206344f32, 0.21259294f32, 0.16241743f32, 0.111703254f32, 0.06061863f32, 0.009332978f32, -0.041983627f32, -0.093161f32, -0.14402941f32, -0.19442017f32, -0.24416617f32, -0.2931024f32, -0.34106663f32, -0.38789973f32, -0.4334464f32, -0.47755566f32, -0.52008116f32, -0.5608818f32, -0.5998224f32, -0.63677377f32, -0.6716134f32, -0.70422566f32, -0.7345025f32, -0.76234347f32, -0.7876562f32, -0.81035674f32, -0.83036983f32, -0.8476292f32, -0.8620774f32, -0.8736667f32, -0.8823587f32, -0.8881243f32, -0.89094466f32, -0.89081025f32, -0.88772166f32, -0.881689f32, -0.8727324f32, -0.86088145f32, -0.8461755f32, -0.82866335f32, -0.808403f32, -0.7854617f32, -0.7599156f32, -0.7318493f32, -0.7013559f32, -0.6685365f32, -0.63350004f32, -0.5963627f32, -0.5572475f32, -0.51628435f32, -0.47360903f32, -0.42936298f32, -0.38369304f32, -0.33675063f32, -0.2886914f32, -0.2396748f32, -0.18986334f32, -0.13942222f32, -0.08851873f32, -0.03732168f32, 0.013999147f32, 0.065273546f32, 0.116331466f32, 0.1670036f32, 0.2171219f32, 0.2665201f32, 0.31503448f32, 0.36250407f32, 0.40877143f32, 0.4536832f32, 0.49709034f32, 0.538849f32, 0.5788206f32, 0.61687267f32, 0.6528789f32, 0.68671995f32, 0.71828365f32, 0.7474652f32, 0.7741679f32, 0.7983032f32, 0.81979096f32, 0.83856004f32, 0.85454816f32, 0.86770225f32, 0.87797874f32, 0.8853435f32, 0.8897722f32, 0.8912501f32, 0.8897722f32, 0.8853435f32, 0.87797874f32, 0.86770225f32, 0.85454816f32, 0.83856004f32, 0.81979096f32, 0.7983032f32, 0.7741679f32, 0.7474652f32, 0.71828365f32, 0.68671995f32, 0.6528789f32, 0.61687267f32, 0.5788206f32, 0.538849f32, 0.49709034f32, 0.4536832f32, 0.40877143f32, 0.36250407f32, 0.31503448f32, 0.2665201f32, 0.2171219f32, 0.1670036f32, 0.116331466f32, 0.065273546f32, 0.013999147f32, -0.03732168f32, -0.08851873f32, -0.13942222f32, -0.18986334f32, -0.2396748f32, -0.2886914f32, -0.33675063f32, -0.38369304f32, -0.42936298f32, -0.47360903f32, -0.51628435f32, -0.5572475f32, -0.5963627f32, -0.63350004f32, -0.6685365f32, -0.7013559f32, -0.7318493f32, -0.7599156f32, -0.7854617f32, -0.808403f32, -0.82866335f32, -0.8461755f32, -0.86088145f32, -0.8727324f32, -0.881689f32, -0.88772166f32, -0.89081025f32, -0.89094466f32, -0.8881243f32, -0.8823587f32, -0.8736667f32, -0.8620774f32, -0.8476292f32, -0.83036983f32, -0.81035674f32, -0.7876562f32, -0.76234347f32, -0.7345025f32, -0.70422566f32, -0.6716134f32, -0.63677377f32, -0.5998224f32, -0.5608818f32, -0.52008116f32, -0.47755566f32, -0.4334464f32, -0.38789973f32, -0.34106663f32, -0.2931024f32, -0.24416617f32, -0.19442017f32, -0.14402941f32, -0.093161f32, -0.041983627f32, 0.009332978f32, 0.06061863f32, 0.111703254f32, 0.16241743f32, 0.21259294f32, 0.26206344f32, 0.31066486f32, 0.35823596f32, 0.40461904f32, 0.44966027f32, 0.49321026f32, 0.53512454f32, 0.5752642f32, 0.613496f32, 0.6496933f32, 0.68373597f32, 0.7155111f32, 0.7449134f32, 0.77184516f32, 0.7962173f32, 0.8179489f32, 0.83696777f32, 0.85321105f32, 0.8666247f32, 0.87716436f32, 0.884795f32, 0.8894914f32, 0.89123785f32, 0.8900286f32, 0.8858678f32, 0.878769f32, 0.86875594f32, 0.85586184f32, 0.84012926f32, 0.82161057f32, 0.8003671f32, 0.77646935f32, 0.74999654f32, 0.72103643f32, 0.6896851f32, 0.65604657f32, 0.6202323f32, 0.58236116f32, 0.54255867f32, 0.50095683f32, 0.4576937f32, 0.4129126f32, 0.3667622f32, 0.31939545f32, 0.27096948f32, 0.22164488f32, 0.1715852f32, 0.12095651f32, 0.06992668f32, 0.018664932f32, -0.032658707f32, -0.08387404f32, -0.13481122f32, -0.1853013f32, -0.23517686f32, -0.2842725f32, -0.3324254f32, -0.3794758f32, -0.42526776f32, -0.46964937f32, -0.51247346f32, -0.553598f32, -0.59288657f32, -0.63020897f32, -0.66544133f32, -0.69846684f32, -0.729176f32, -0.7574669f32, -0.7832458f32, -0.8064272f32, -0.8269341f32, -0.8446986f32, -0.8596618f32, -0.87177414f32, -0.8809952f32, -0.88729465f32, -0.89065146f32, -0.8910546f32, -0.8885026f32, -0.88300407f32, -0.87457716f32, -0.8632498f32, -0.8490596f32, -0.8320536f32, -0.8122882f32, -0.789829f32, -0.76475036f32, -0.7371356f32, -0.7070762f32, -0.6746719f32, -0.6400301f32, -0.6032657f32, -0.56450075f32, -0.5238636f32, -0.48148924f32, -0.437518f32, -0.3920958f32, -0.34537327f32, -0.29750538f32, -0.24865083f32, -0.19897167f32, -0.14863265f32, -0.09780071f32, -0.046644423f32, 0.0046665533f32, 0.055962056f32, 0.107071966f32, 0.15782678f32, 0.2080582f32, 0.25759962f32, 0.30628672f32, 0.35395807f32, 0.4004556f32, 0.44562504f32, 0.48931658f32, 0.5313855f32, 0.571692f32, 0.61010265f32, 0.64649f32, 0.68073326f32, 0.71271896f32, 0.7423411f32, 0.7695013f32, 0.7941096f32, 0.8160843f32, 0.8353526f32, 0.85185057f32, 0.8655235f32, 0.87632596f32, 0.88422227f32, 0.8891862f32, 0.8912012f32, 0.89026064f32, 0.8863677f32, 0.87953526f32, 0.86978585f32, 0.857152f32, 0.84167546f32, 0.82340765f32, 0.8024091f32, 0.7787495f32, 0.7525073f32, 0.7237695f32, 0.6926314f32, 0.65919626f32, 0.623575f32, 0.5858857f32, 0.54625344f32, 0.5048096f32, 0.4616916f32, 0.41704246f32, 0.3710103f32, 0.3237477f32, 0.27541143f32, 0.2261618f32, 0.17616212f32, 0.12557824f32, 0.07457788f32, 0.023330206f32, -0.02799484f32, -0.07922705f32, -0.13019651f32, -0.18073419f32, -0.23067248f32, -0.2798458f32, -0.32809103f32, -0.3752482f32, -0.4211609f32, -0.46567684f32, -0.5086485f32, -0.54993325f32, -0.5893942f32, -0.62690055f32, -0.6623278f32, -0.69555867f32, -0.7264827f32, -0.75499743f32, -0.78100836f32, -0.8044292f32, -0.8251822f32, -0.8431986f32, -0.85841864f32, -0.8707919f32, -0.8802773f32, -0.8868433f32, -0.8904683f32, -0.8911401f32, -0.88885653f32, -0.8836253f32, -0.87546355f32, -0.8643985f32, -0.8504667f32, -0.83371454f32, -0.8141974f32, -0.79198015f32, -0.7671364f32, -0.7397485f32, -0.7099073f32, -0.67771184f32, -0.6432688f32, -0.6066925f32, -0.56810415f32, -0.52763176f32, -0.4854096f32, -0.44157755f32, -0.39628112f32, -0.34967047f32, -0.3019002f32, -0.2531287f32, -0.20351772f32, -0.15323183f32, -0.10243774f32, -0.05130394f32, 0.000000000000007862972f32, 0.05130394f32, 0.10243774f32, 0.15323183f32, 0.20351772f32, 0.2531287f32, 0.3019002f32, 0.34967047f32, 0.39628112f32, 0.44157755f32, 0.4854096f32, 0.52763176f32, 0.56810415f32, 0.6066925f32, 0.6432688f32, 0.67771184f32, 0.7099073f32, 0.7397485f32, 0.7671364f32, 0.79198015f32, 0.8141974f32, 0.83371454f32, 0.8504667f32, 0.8643985f32, 0.87546355f32, 0.8836253f32, 0.88885653f32, 0.8911401f32, 0.8904683f32, 0.8868433f32, 0.8802773f32, 0.8707919f32, 0.85841864f32, 0.8431986f32, 0.8251822f32, 0.8044292f32, 0.78100836f32, 0.75499743f32, 0.7264827f32, 0.69555867f32, 0.6623278f32, 0.62690055f32, 0.5893942f32, 0.54993325f32, 0.5086485f32, 0.46567684f32, 0.4211609f32, 0.3752482f32, 0.32809103f32, 0.2798458f32, 0.23067248f32, 0.18073419f32, 0.13019651f32, 0.07922705f32, 0.02799484f32, -0.023330206f32, -0.07457788f32, -0.12557824f32, -0.17616212f32, -0.2261618f32, -0.27541143f32, -0.3237477f32, -0.3710103f32, -0.41704246f32, -0.4616916f32, -0.5048096f32, -0.54625344f32, -0.5858857f32, -0.623575f32, -0.65919626f32, -0.6926314f32, -0.7237695f32, -0.7525073f32, -0.7787495f32, -0.8024091f32, -0.82340765f32, -0.84167546f32, -0.857152f32, -0.86978585f32, -0.87953526f32, -0.8863677f32, -0.89026064f32, -0.8912012f32, -0.8891862f32, -0.88422227f32, -0.87632596f32, -0.8655235f32, -0.85185057f32, -0.8353526f32, -0.8160843f32, -0.7941096f32, -0.7695013f32, -0.7423411f32, -0.71271896f32, -0.68073326f32, -0.64649f32, -0.61010265f32, -0.571692f32, -0.5313855f32, -0.48931658f32, -0.44562504f32, -0.4004556f32, -0.35395807f32, -0.30628672f32, -0.25759962f32, -0.2080582f32, -0.15782678f32, -0.107071966f32, -0.055962056f32, -0.0046665533f32, 0.046644423f32, 0.09780071f32, 0.14863265f32, 0.19897167f32, 0.24865083f32, 0.29750538f32, 0.34537327f32, 0.3920958f32, 0.437518f32, 0.48148924f32, 0.5238636f32, 0.56450075f32, 0.6032657f32, 0.6400301f32, 0.6746719f32, 0.7070762f32, 0.7371356f32, 0.76475036f32, 0.789829f32, 0.8122882f32, 0.8320536f32, 0.8490596f32, 0.8632498f32, 0.87457716f32, 0.88300407f32, 0.8885026f32, 0.8910546f32, 0.89065146f32, 0.88729465f32, 0.8809952f32, 0.87177414f32, 0.8596618f32, 0.8446986f32, 0.8269341f32, 0.8064272f32, 0.7832458f32, 0.7574669f32, 0.729176f32, 0.69846684f32, 0.66544133f32, 0.63020897f32, 0.59288657f32, 0.553598f32, 0.51247346f32, 0.46964937f32, 0.42526776f32, 0.3794758f32, 0.3324254f32, 0.2842725f32, 0.23517686f32, 0.1853013f32, 0.13481122f32, 0.08387404f32, 0.032658707f32, -0.018664932f32, -0.06992668f32, -0.12095651f32, -0.1715852f32, -0.22164488f32, -0.27096948f32, -0.31939545f32, -0.3667622f32, -0.4129126f32, -0.4576937f32, -0.50095683f32, -0.54255867f32, -0.58236116f32, -0.6202323f32, -0.65604657f32, -0.6896851f32, -0.72103643f32, -0.74999654f32, -0.77646935f32, -0.8003671f32, -0.82161057f32, -0.84012926f32, -0.85586184f32, -0.86875594f32, -0.878769f32, -0.8858678f32, -0.8900286f32, -0.89123785f32, -0.8894914f32, -0.884795f32, -0.87716436f32, -0.8666247f32, -0.85321105f32, -0.83696777f32, -0.8179489f32, -0.7962173f32, -0.77184516f32, -0.7449134f32, -0.7155111f32, -0.68373597f32, -0.6496933f32, -0.613496f32, -0.5752642f32, -0.53512454f32, -0.49321026f32, -0.44966027f32, -0.40461904f32, -0.35823596f32, -0.31066486f32, -0.26206344f32, -0.21259294f32, -0.16241743f32, -0.111703254f32, -0.06061863f32, -0.009332978f32, 0.041983627f32, 0.093161f32, 0.14402941f32, 0.19442017f32, 0.24416617f32, 0.2931024f32, 0.34106663f32, 0.38789973f32, 0.4334464f32, 0.47755566f32, 0.52008116f32, 0.5608818f32, 0.5998224f32, 0.63677377f32, 0.6716134f32, 0.70422566f32, 0.7345025f32, 0.76234347f32, 0.7876562f32, 0.81035674f32, 0.83036983f32, 0.8476292f32, 0.8620774f32, 0.8736667f32, 0.8823587f32, 0.8881243f32, 0.89094466f32, 0.89081025f32, 0.88772166f32, 0.881689f32, 0.8727324f32, 0.86088145f32, 0.8461755f32, 0.82866335f32, 0.808403f32, 0.7854617f32, 0.7599156f32, 0.7318493f32, 0.7013559f32, 0.6685365f32, 0.63350004f32, 0.5963627f32, 0.5572475f32, 0.51628435f32, 0.47360903f32, 0.42936298f32, 0.38369304f32, 0.33675063f32, 0.2886914f32, 0.2396748f32, 0.18986334f32, 0.13942222f32, 0.08851873f32, 0.03732168f32, -0.013999147f32, -0.065273546f32, -0.116331466f32, -0.1670036f32, -0.2171219f32, -0.2665201f32, -0.31503448f32, -0.36250407f32, -0.40877143f32, -0.4536832f32, -0.49709034f32, -0.538849f32, -0.5788206f32, -0.61687267f32, -0.6528789f32, -0.68671995f32, -0.71828365f32, -0.7474652f32, -0.7741679f32, -0.7983032f32, -0.81979096f32, -0.83856004f32, -0.85454816f32, -0.86770225f32, -0.87797874f32, -0.8853435f32, -0.8897722f32, -0.8912501f32, -0.8897722f32, -0.8853435f32, -0.87797874f32, -0.86770225f32, -0.85454816f32, -0.83856004f32, -0.81979096f32, -0.7983032f32, -0.7741679f32, -0.7474652f32, -0.71828365f32, -0.68671995f32, -0.6528789f32, -0.61687267f32, -0.5788206f32, -0.538849f32, -0.49709034f32, -0.4536832f32, -0.40877143f32, -0.36250407f32, -0.31503448f32, -0.2665201f32, -0.2171219f32, -0.1670036f32, -0.116331466f32, -0.065273546f32, -0.013999147f32, 0.03732168f32, 0.08851873f32, 0.13942222f32, 0.18986334f32, 0.2396748f32, 0.2886914f32, 0.33675063f32, 0.38369304f32, 0.42936298f32, 0.47360903f32, 0.51628435f32, 0.5572475f32, 0.5963627f32, 0.63350004f32, 0.6685365f32, 0.7013559f32, 0.7318493f32, 0.7599156f32, 0.7854617f32, 0.808403f32, 0.82866335f32, 0.8461755f32, 0.86088145f32, 0.8727324f32, 0.881689f32, 0.88772166f32, 0.89081025f32, 0.89094466f32, 0.8881243f32, 0.8823587f32, 0.8736667f32, 0.8620774f32, 0.8476292f32, 0.83036983f32, 0.81035674f32, 0.7876562f32, 0.76234347f32, 0.7345025f32, 0.70422566f32, 0.6716134f32, 0.63677377f32, 0.5998224f32, 0.5608818f32, 0.52008116f32, 0.47755566f32, 0.4334464f32, 0.38789973f32, 0.34106663f32, 0.2931024f32, 0.24416617f32, 0.19442017f32, 0.14402941f32, 0.093161f32, 0.041983627f32, -0.009332978f32, -0.06061863f32, -0.111703254f32, -0.16241743f32, -0.21259294f32, -0.26206344f32, -0.31066486f32, -0.35823596f32, -0.40461904f32, -0.44966027f32, -0.49321026f32, -0.53512454f32, -0.5752642f32, -0.613496f32, -0.6496933f32, -0.68373597f32, -0.7155111f32, -0.7449134f32, -0.77184516f32, -0.7962173f32, -0.8179489f32, -0.83696777f32, -0.85321105f32, -0.8666247f32, -0.87716436f32, -0.884795f32, -0.8894914f32, -0.89123785f32, -0.8900286f32, -0.8858678f32, -0.878769f32, -0.86875594f32, -0.85586184f32, -0.84012926f32, -0.82161057f32, -0.8003671f32, -0.77646935f32, -0.74999654f32, -0.72103643f32, -0.6896851f32, -0.65604657f32, -0.6202323f32, -0.58236116f32, -0.54255867f32, -0.50095683f32, -0.4576937f32, -0.4129126f32, -0.3667622f32, -0.31939545f32, -0.27096948f32, -0.22164488f32, -0.1715852f32, -0.12095651f32, -0.06992668f32, -0.018664932f32, 0.032658707f32, 0.08387404f32, 0.13481122f32, 0.1853013f32, 0.23517686f32, 0.2842725f32, 0.3324254f32, 0.3794758f32, 0.42526776f32, 0.46964937f32, 0.51247346f32, 0.553598f32, 0.59288657f32, 0.63020897f32, 0.66544133f32, 0.69846684f32, 0.729176f32, 0.7574669f32, 0.7832458f32, 0.8064272f32, 0.8269341f32, 0.8446986f32, 0.8596618f32, 0.87177414f32, 0.8809952f32, 0.88729465f32, 0.89065146f32, 0.8910546f32, 0.8885026f32, 0.88300407f32, 0.87457716f32, 0.8632498f32, 0.8490596f32, 0.8320536f32, 0.8122882f32, 0.789829f32, 0.76475036f32, 0.7371356f32, 0.7070762f32, 0.6746719f32, 0.6400301f32, 0.6032657f32, 0.56450075f32, 0.5238636f32, 0.48148924f32, 0.437518f32, 0.3920958f32, 0.34537327f32, 0.29750538f32, 0.24865083f32, 0.19897167f32, 0.14863265f32, 0.09780071f32, 0.046644423f32, -0.0046665533f32, -0.055962056f32, -0.107071966f32, -0.15782678f32, -0.2080582f32, -0.25759962f32, -0.30628672f32, -0.35395807f32, -0.4004556f32, -0.44562504f32, -0.48931658f32, -0.5313855f32, -0.571692f32, -0.61010265f32, -0.64649f32, -0.68073326f32, -0.71271896f32, -0.7423411f32, -0.7695013f32, -0.7941096f32, -0.8160843f32, -0.8353526f32, -0.85185057f32, -0.8655235f32, -0.87632596f32, -0.88422227f32, -0.8891862f32, -0.8912012f32, -0.89026064f32, -0.8863677f32, -0.87953526f32, -0.86978585f32, -0.857152f32, -0.84167546f32, -0.82340765f32, -0.8024091f32, -0.7787495f32, -0.7525073f32, -0.7237695f32, -0.6926314f32, -0.65919626f32, -0.623575f32, -0.5858857f32, -0.54625344f32, -0.5048096f32, -0.4616916f32, -0.41704246f32, -0.3710103f32, -0.3237477f32, -0.27541143f32, -0.2261618f32, -0.17616212f32, -0.12557824f32, -0.07457788f32, -0.023330206f32, 0.02799484f32, 0.07922705f32, 0.13019651f32, 0.18073419f32, 0.23067248f32, 0.2798458f32, 0.32809103f32, 0.3752482f32, 0.4211609f32, 0.46567684f32, 0.5086485f32, 0.54993325f32, 0.5893942f32, 0.62690055f32, 0.6623278f32, 0.69555867f32, 0.7264827f32, 0.75499743f32, 0.78100836f32, 0.8044292f32, 0.8251822f32, 0.8431986f32, 0.85841864f32, 0.8707919f32, 0.8802773f32, 0.8868433f32, 0.8904683f32, 0.8911401f32, 0.88885653f32, 0.8836253f32, 0.87546355f32, 0.8643985f32, 0.8504667f32, 0.83371454f32, 0.8141974f32, 0.79198015f32, 0.7671364f32, 0.7397485f32, 0.7099073f32, 0.67771184f32, 0.6432688f32, 0.6066925f32, 0.56810415f32, 0.52763176f32, 0.4854096f32, 0.44157755f32, 0.39628112f32, 0.34967047f32, 0.3019002f32, 0.2531287f32, 0.20351772f32, 0.15323183f32, 0.10243774f32, 0.05130394f32, ]; /// Decode the given wave file using Symphonia and return the decoded samples. /// /// # Arguments /// * `data` - The wave file data /// /// # Returns /// * A tuple of the decoded samples, sample rate and number of channels /// fn decode_with_symphonia(data: &'static [u8]) -> (Vec, u32, usize) { use std::io::Cursor; use symphonia::core::audio::SampleBuffer; use symphonia::core::codecs::DecoderOptions; use symphonia::core::errors::Error; use symphonia::core::formats::FormatOptions; use symphonia::core::io::MediaSourceStream; use symphonia::core::meta::MetadataOptions; use symphonia::default::get_probe; // Decode using Symphonia let mss = MediaSourceStream::new(Box::new(Cursor::new(data)), Default::default()); let probed = get_probe() .format( &Default::default(), mss, &FormatOptions::default(), &MetadataOptions::default(), ) .expect("Failed to probe format"); let mut format = probed.format; let track = format .tracks() .iter() .find(|t| t.codec_params.codec != symphonia::core::codecs::CODEC_TYPE_NULL) .expect("no supported track found"); let dec_opts: DecoderOptions = Default::default(); let mut decoder = symphonia::default::get_codecs() .make(&track.codec_params, &dec_opts) .expect("unsupported codec"); let track_id = track.id; let mut sample_buf = None; let mut symphonia_decoded_samples = Vec::::new(); let mut sample_rate = None; let mut num_channels = None; loop { let Ok(packet) = format.next_packet() else { break; }; // Consume any new metadata that has been read since the last packet. while !format.metadata().is_latest() { // Pop the old head of the metadata queue. format.metadata().pop(); // Consume the new metadata at the head of the metadata queue. } // If the packet does not belong to the selected track, skip over it. if packet.track_id() != track_id { continue; } // Decode the packet into audio samples. match decoder.decode(&packet) { Ok(decoded) => { // Consume the decoded audio samples (see below). if sample_buf.is_none() { let spec = *decoded.spec(); sample_rate = Some(spec.rate); num_channels = Some(spec.channels.count()); let duration = decoded.capacity(); sample_buf = Some(SampleBuffer::::new(duration as u64, spec)); } if let Some(buf) = &mut sample_buf { buf.copy_interleaved_ref(decoded); for e in buf.samples().iter() { symphonia_decoded_samples.push(*e); } } } Err(Error::IoError(_)) => { // The packet failed to decode due to an IO error, skip the packet. continue; } Err(Error::DecodeError(_)) => { // The packet failed to decode due to invalid data, skip the packet. continue; } Err(err) => { // An unrecoverable error occurred, halt decoding. panic!("{}", err); } } } ( symphonia_decoded_samples, sample_rate.unwrap(), num_channels.unwrap(), ) } #[test] fn wav_specs() { let wav = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_16.wav"); let mut reader = PcmReader::new(wav).unwrap(); // 1ch 48kHz 16bit { let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 16); assert_eq!(spec.audio_format, AudioFormat::LinearPcmLe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 24bit { let wav = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_24.wav"); reader.reload(wav).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 24); assert_eq!(spec.audio_format, AudioFormat::LinearPcmLe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 32bit { let wav = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32.wav"); reader.reload(wav).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 32); assert_eq!(spec.audio_format, AudioFormat::LinearPcmLe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 32bit float { let wav = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32FP.wav"); reader.reload(wav).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 32); assert_eq!(spec.audio_format, AudioFormat::IeeeFloatLe); // Little endian assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 64bit float { let wav = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_64FP.wav"); reader.reload(wav).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 64); assert_eq!(spec.audio_format, AudioFormat::IeeeFloatLe); // Little endian assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 22.05kHz 16bit { let wav = include_bytes!("./resources/MLKDream.wav"); // https://archive.org/details/MLKDream reader.reload(wav).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 16); assert_eq!(spec.audio_format, AudioFormat::LinearPcmLe); // Little endian assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 22050); assert_eq!(spec.num_samples, 21_772_800); } } #[test] fn aiff_specs() { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_16.aif"); let mut reader = PcmReader::new(data).unwrap(); // 1ch 48kHz 16bit { let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 16); assert_eq!(spec.audio_format, AudioFormat::LinearPcmBe); //Big endian assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 24bit { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_24.aif"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 24); assert_eq!(spec.audio_format, AudioFormat::LinearPcmBe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 32bit { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32.aif"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 32); assert_eq!(spec.audio_format, AudioFormat::LinearPcmBe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 32bit float { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32FP.aif"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 32); assert_eq!(spec.audio_format, AudioFormat::IeeeFloatBe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } // 1ch 48kHz 64bit float { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_64FP.aif"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.bit_depth, 64); assert_eq!(spec.audio_format, AudioFormat::IeeeFloatBe); assert_eq!(spec.num_channels, 1); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_samples, 240000); } } #[test] fn wav_compare_with_symphonia() { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_16.wav"); let mut reader = PcmReader::new(data).unwrap(); // 1ch 48kHz 16bit { let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // 1ch 48kHz 24bit { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_24.wav"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // 1ch 48kHz 32bit { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32.wav"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // 1ch 48kHz 32bit float { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32FP.wav"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // 1ch 48kHz 64bit float { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_64FP.wav"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } { let data = include_bytes!("./resources/MLKDream.wav"); // https://archive.org/details/MLKDream reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } { let data = include_bytes!("./resources/Tank_Low17.wav"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } } #[test] fn aiff_compare_with_symphonia() { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_16.aif"); let mut reader = PcmReader::new(data).unwrap(); // 1ch 48kHz 16bit { let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // 1ch 48kHz 24bit { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_24.aif"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // 1ch 48kHz 32bit { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32.aif"); reader.reload(data).unwrap(); let spec = reader.get_pcm_specs(); let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); assert_eq!(spec.sample_rate, sample_rate); assert_eq!(spec.num_channels as usize, num_channels); let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; assert_eq!(symphonia_buf.len(), num_total_samples); for samp in 0..spec.num_samples as usize { for ch in 0..num_channels { let sample = reader.read_sample(ch as u16, samp as u32).unwrap(); assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); } } } // TODO symphonia does not support 32bit float AIFF // // 1ch 48kHz 32bit float // { // let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32FP.aif"); // reader.reload(data).unwrap(); // let spec = reader.get_pcm_specs(); // let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); // assert_eq!(spec.sample_rate, sample_rate); // assert_eq!(spec.num_channels as usize, num_channels); // let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; // assert_eq!(symphonia_buf.len(), num_total_samples); // for samp in 0..spec.num_samples as usize { // for ch in 0..num_channels { // let sample = reader.read_sample(ch as u32, samp as u32).unwrap(); // assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); // } // } // } // // 1ch 48kHz 64bit float // { // let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_64FP.aif"); // reader.reload(data).unwrap(); // let spec = reader.get_pcm_specs(); // let (symphonia_buf, sample_rate, num_channels) = decode_with_symphonia(data); // assert_eq!(spec.sample_rate, sample_rate); // assert_eq!(spec.num_channels as usize, num_channels); // let num_total_samples = spec.num_channels as usize * spec.num_samples as usize; // assert_eq!(symphonia_buf.len(), num_total_samples); // for samp in 0..spec.num_samples as usize { // for ch in 0..num_channels { // let sample = reader.read_sample(ch as u32, samp as u32).unwrap(); // assert_relative_eq!(sample, symphonia_buf[samp * num_channels + ch]); // } // } // } } // TODO SymphoniaがAIFF 32bit floatをサポートしたら比較テストに置き換える #[test] fn aiff_32bit_float() { let aiff = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32FP.aif"); let reader = PcmReader::new(aiff).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.num_samples, 240000); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_channels, 1); assert_eq!(spec.audio_format, AudioFormat::IeeeFloatBe); assert_eq!(spec.bit_depth, 32); for i in 0..SINEWAVE.len() as u32 { let sample = reader.read_sample(0, i).unwrap(); assert_relative_eq!(sample, SINEWAVE[i as usize]); } } // TODO SymphoniaがAIFF 64bit floatをサポートしたら比較テストに置き換える #[test] fn aiff_64bit_float() { let aiff = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_64FP.aif"); let reader = PcmReader::new(aiff).unwrap(); let spec = reader.get_pcm_specs(); assert_eq!(spec.num_samples, 240000); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_channels, 1); assert_eq!(spec.audio_format, AudioFormat::IeeeFloatBe); assert_eq!(spec.bit_depth, 64); for i in 0..SINEWAVE.len() as u32 { let sample = reader.read_sample(0, i).unwrap(); assert_relative_eq!(sample, SINEWAVE[i as usize]); } } #[test] fn wav_player_32bit() { let wav = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_32.wav"); let reader = PcmReader::new(wav).unwrap(); let mut player = PcmPlayer::new(reader); let spec = player.reader.get_pcm_specs(); player.set_position(0).unwrap(); player.set_loop_playing(false); let mut buffer: [f32; 2] = [0f32, 0f32]; let b = buffer.as_mut_slice(); // test first 10 samples for i in 0..10 { if player.get_next_frame(b).is_ok() { assert_relative_eq!(b[0], SINEWAVE[i as usize]); } } // set_positionが正しいかをtest player.set_position(0).unwrap(); for i in 0..10 { if player.get_next_frame(b).is_ok() { assert_relative_eq!(b[0], SINEWAVE[i as usize]); } } player.set_position(0).unwrap(); //末尾まで再生 for _ in 0..spec.num_samples { player.get_next_frame(b).unwrap(); } // 末尾まで再生した後は正しくErrを返すかをテスト for _ in 0..10 { let e = player.get_next_frame(b); match e { Ok(_) => unreachable!(), Err(_) => continue, } } player.set_loop_playing(true); player.set_position(0).unwrap(); // 末尾まで再生 for _ in 0..spec.num_samples { player.get_next_frame(b).unwrap(); } // ループ再生が正しく機能するかをtest for i in 0..10 { if player.get_next_frame(b).is_ok() { assert_relative_eq!(b[0], SINEWAVE[i as usize]); } } } #[test] fn ima_adpcm_4bit() { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_4bit_IMAADPCM.wav"); let mut player = ImaAdpcmPlayer::new(data); let spec = player.reader.get_pcm_specs(); assert_eq!(spec.num_samples, 240838); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_channels, 1); assert_eq!(spec.audio_format, AudioFormat::ImaAdpcmLe); assert_eq!(spec.bit_depth, 4); let mut buffer: [I1F15; 2] = [I1F15::ZERO, I1F15::ZERO]; let buf = buffer.as_mut_slice(); for i in 0..10 { player.get_next_frame(buf).unwrap(); let s = buf[0].to_num::(); assert_relative_eq!(s, SINEWAVE[i as usize], epsilon = 0.3f32); } } #[test] fn ima_adpcm_4bit_play_to_end() { let data = include_bytes!("./resources/Sine440Hz_1ch_48000Hz_4bit_IMAADPCM.wav"); let mut player = ImaAdpcmPlayer::new(data); let spec = player.reader.get_pcm_specs(); assert_eq!(spec.num_samples, 240838); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_channels, 1); assert_eq!(spec.audio_format, AudioFormat::ImaAdpcmLe); assert_eq!(spec.bit_depth, 4); let mut buffer: [I1F15; 2] = [I1F15::ZERO, I1F15::ZERO]; let buf = buffer.as_mut_slice(); // Play to the end for _ in 0..spec.num_samples { player.get_next_frame(buf).unwrap(); } //Error let e = player.get_next_frame(buf); assert!(e.is_err()); //再生位置を先頭に戻す player.rewind(); // Play to the end for _ in 0..spec.num_samples { player.get_next_frame(buf).unwrap(); } //Error let e = player.get_next_frame(buf); assert!(e.is_err()); } #[test] fn ima_adpcm_4bit_2ch() { let data = include_bytes!("./resources/Sine440Hz_2ch_48000Hz_4bit_IMAADPCM.wav"); let mut player = ImaAdpcmPlayer::new(data); let spec = player.reader.get_pcm_specs(); assert_eq!(spec.num_samples, 240838); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_channels, 2); assert_eq!(spec.audio_format, AudioFormat::ImaAdpcmLe); assert_eq!(spec.bit_depth, 4); let mut buffer: [I1F15; 2] = [I1F15::ZERO, I1F15::ZERO]; let buf = buffer.as_mut_slice(); for i in 0..SINEWAVE.len() as u32 { player.get_next_frame(buf).unwrap(); let l = buf[0].to_num::(); let r = buf[1].to_num::(); assert_relative_eq!(l, SINEWAVE[i as usize], epsilon = 0.3f32); assert_relative_eq!(r, SINEWAVE[i as usize], epsilon = 0.3f32); } } #[test] fn ima_adpcm_4bit_2ch_play_to_end() { let data = include_bytes!("./resources/Sine440Hz_2ch_48000Hz_4bit_IMAADPCM.wav"); let mut player = ImaAdpcmPlayer::new(data); let spec = player.reader.get_pcm_specs(); assert_eq!(spec.num_samples, 240838); assert_eq!(spec.sample_rate, 48000); assert_eq!(spec.num_channels, 2); assert_eq!(spec.audio_format, AudioFormat::ImaAdpcmLe); assert_eq!(spec.bit_depth, 4); let mut buffer: [I1F15; 2] = [I1F15::ZERO, I1F15::ZERO]; let buf = buffer.as_mut_slice(); // Play to the end for _ in 0..spec.num_samples { player.get_next_frame(buf).unwrap(); } // Error let e = player.get_next_frame(buf); assert!(e.is_err()); // 再生位置を先頭に戻す. player.rewind(); // Play to the end for _ in 0..spec.num_samples { player.get_next_frame(buf).unwrap(); } // Error let e = player.get_next_frame(buf); assert!(e.is_err()); }