Gunshot sounds are common in crimes, particularly those involving threats, harassment, or killing. The gunshot sounds in crimes can create fear and panic among victims, often leading to psychological trauma. Gunshot sounds are associated with a significant mortality rate, especially in cases of gun violence. The sound of gunshots can serve as evidence in criminal investigations, allowing law enforcement officials to determine the number of shots fired, the caliber of the gun used, and the distance from which the shots were fired. Efficient gunshot detection is necessary to address the issue of gun violence in society. This study aims to detect gunshot sounds using an efficient approach to prevent crimes. The frequency-time domain spectrum analysis is performed to understand the patterns of signals related to each target class. A novel Discrete Wavelet Transform Random Forest Probabilistic (DWT-RFP) feature engineering approach is proposed, which takes Mel-frequency cepstral coefficients (MFCC) extracted from gunshot sound data as input for feature extraction. A novel meta-learning-based Meta-RF-KN (MRK) is proposed to detect gunshots based on newly created ensemble features with a DWT-RFP approach. For experiments, the gunshot sounds dataset containing 851 audio clips collected from public videos on YouTube from eight kinds of gun models, is used. Advanced machine learning and deep learning techniques are applied in comparison to evaluate the performance of the proposed approach. Extensive experiments show that the proposed MRK approach achieves 99% k-fold accuracy for detecting gunshots and outperforms state-of-the-art approaches. The proposed approach can potentially be used for accurate gunshot detection and to help prevent crimes.