Recently, for a pet project, I wanted to create an animation of a waveform based on the varying decibel level of the microphone input. I was thinking about a really simple way to accomplish this with SVG and JavaScript. Given below is the first sample code I did on the Codepen. You can change this code to use with any framework of your choice.
For this sample code, I am using a random number as the microphone input. You can replace it with any other time based input.
Code Pen : https://codepen.io/nadeeth/pen/vmaYXw
For this example, you need an HTML code snippet like the one given below. It’s just an SVG with a Polyline element inside.
For this sample code, I am using a random number as the microphone input. You can replace it with any other time based input.
Code Pen : https://codepen.io/nadeeth/pen/vmaYXw
For this example, you need an HTML code snippet like the one given below. It’s just an SVG with a Polyline element inside.
<div style="text-align:center"> <svg height="150" width="400" id='svg'> <polyline id="polyline-id" fill="none" stroke="#005c66" stroke-width="1" /> </svg> </div>And then the plain Javascript code to animate the polyline. You can replace the setInterval function and the statement that generates the random number based on your actual need.
var svg = document.getElementById('svg'); var polyline= document.getElementById('polyline-id'); var width = 400; var height = 150; var x = 0; setInterval(function(){ //Create the new point and increment the x for the next point var point = svg.createSVGPoint(); point.x = x; point.y = height - Math.floor((Math.random() * height)); polyline.points.appendItem(point); x++; //Reset the x axis points when the line reaches the width if (polyline.points.length > width) { //Remove the first point to make space for the last point polyline.points.removeItem(0); //Reset x points for (var j=0; j<width; j++) { polyline.points[j].x = j; } } }, 100);
I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much.
ReplyDeleteHTML Training in Chennai
ReplyDeleteHey, very nice site. I came across this on Google, and I am stoked that I did. I will definitely be coming back here more often. Wish I could add to the conversation and bring a bit more to the table,but am just taking in as much info as I can at the moment. Thanks for sharing.
Vissco Aluminium Wheelchair with Fixed Wheels
This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance knowledge. I like it and help me to development very well. Thank you for this brief explanation and very nice information. Well, got good knowledge.
ReplyDeleteWordPress development company in Chennai
Nice blog!! Hope you share more infor like this!!
ReplyDeleteSoftware testing training in chennai
JAVA Training in Chennai
Hadoop Training in Chennai
Selenium Training in Chennai
German Classes in chennai
Android Course in Chennai
Android Training Chennai
I have gone through your blog, it was very much useful for me and because of your blog, and also I gained many unknown information, the way you have clearly explained is really fantastic. Kindly post more like this, Thank You.
ReplyDeleteAviation Academy in Chennai
Air hostess training in Chennai
Airport management courses in Chennai
Ground staff training in Chennai
best aviation academy in Chennai
best air hostess training institute in Chennai
airline management courses in Chennai
airport ground staff training in Chennai
Thanks for taking the time to discuss this, I feel happy about it and love to learn more on this topic.
ReplyDeleteui ux design course in Chennai
ux design course in chennai
ui ux course in chennai
Web Designing Course in chennai
web designing training in chennai
AngularJS Training in Chennai
ccna course in Chennai
ui ux design course in Velachery
ui ux design course in T Nagar
ui ux design course in OMR
The article is so informative. This is more helpful for our
ReplyDeletesoftware testing training institute in chennai with placement
selenium training in chennai
software testing course in chennai with placement
magento training course in chennai
Thanks for sharing.
ReplyDeletethanks for your information really good and very nice web design company in velachery
Great blog thanks for sharing Leaders in the branding business - Adhuntt Media is now creating a buzz among marketing circles in Chennai. Global standard content creation, SEO and Web Development are the pillars of our brand building tactics. Through smart strategies and customer analysis, we can find the perfect audience following for you right now through Facebook and Instagram marketing. Click here 360 your brand journey Adhuntt Media.
ReplyDeletesocial media marketing company in chennai
Nice blog thanks for sharing Out of creative ways to set up a vegetable garden? Karuna Nursery is run by the best gardeners in chennai who are ready to offer you with amazing terrace vegetable garden ideas. Visit us right now to learn more and enjoy the experience.
ReplyDeleteplant nursery in chennai
Excellent blog thanks for sharing Buy the best beauty parlour products wholesale in Chennai at Pixies Beauty Shop. Thousands of global top-tier brands to choose from and friendly faces all over, we would love to make your Salon journey, one the world recognizes.
ReplyDeletebeauty Shop in Chennai
Very useful blog thanks for sharing IndPac India the German technology Packaging and sealing machines in India is the leading manufacturer and exporter of Packing Machines in India.
ReplyDeleteI am glad that I have visited this blog. Really helpful, eagerly waiting for more updates.keep up!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
I am glad to post a worthy article about the German Language Course and IELTS Coaching from KCR consultants, this may change your career growth and language skill.
ReplyDeleteKCR CONSULTANTS
KCR CONSULTANTS